kinetis k12: 50mhz cortex-m4 up to 320kb flash (48 pin)

1143
K12 Sub-Family Reference Manual Supports: MK12DX128VLF5, MK12DX256VLF5 Document Number: K12P48M50SF4RM Rev. 4, February 2013

Upload: phamliem

Post on 13-Feb-2017

243 views

Category:

Documents


6 download

TRANSCRIPT

  • K12 Sub-Family Reference ManualSupports: MK12DX128VLF5, MK12DX256VLF5

    Document Number: K12P48M50SF4RMRev. 4, February 2013

  • K12 Sub-Family Reference Manual, Rev. 4, February 2013

    2 Freescale Semiconductor, Inc.

  • Contents

    Section number Title Page

    Chapter 1About This Document

    1.1 Overview.......................................................................................................................................................................45

    1.1.1 Purpose.........................................................................................................................................................45

    1.1.2 Audience......................................................................................................................................................45

    1.2 Conventions..................................................................................................................................................................45

    1.2.1 Numbering systems......................................................................................................................................45

    1.2.2 Typographic notation...................................................................................................................................46

    1.2.3 Special terms................................................................................................................................................46

    Chapter 2Introduction

    2.1 Overview.......................................................................................................................................................................47

    2.2 Module Functional Categories......................................................................................................................................47

    2.2.1 ARM Cortex-M4 Core Modules...........................................................................................................48

    2.2.2 System Modules...........................................................................................................................................49

    2.2.3 Memories and Memory Interfaces...............................................................................................................49

    2.2.4 Clocks...........................................................................................................................................................50

    2.2.5 Security and Integrity modules....................................................................................................................51

    2.2.6 Analog modules...........................................................................................................................................51

    2.2.7 Timer modules.............................................................................................................................................51

    2.2.8 Communication interfaces...........................................................................................................................53

    2.2.9 Human-machine interfaces..........................................................................................................................53

    2.3 Orderable part numbers.................................................................................................................................................53

    Chapter 3Chip Configuration

    3.1 Introduction...................................................................................................................................................................55

    K12 Sub-Family Reference Manual, Rev. 4, February 2013

    Freescale Semiconductor, Inc. 3

  • Section number Title Page

    3.2 Core modules................................................................................................................................................................55

    3.2.1 ARM Cortex-M4 Core Configuration..........................................................................................................55

    3.2.2 Nested Vectored Interrupt Controller (NVIC) Configuration......................................................................57

    3.2.3 Asynchronous Wake-up Interrupt Controller (AWIC) Configuration.........................................................62

    3.2.4 JTAG Controller Configuration...................................................................................................................64

    3.3 System modules............................................................................................................................................................64

    3.3.1 SIM Configuration.......................................................................................................................................64

    3.3.2 System Mode Controller (SMC) Configuration...........................................................................................65

    3.3.3 PMC Configuration......................................................................................................................................66

    3.3.4 Low-Leakage Wake-up Unit (LLWU) Configuration.................................................................................66

    3.3.5 MCM Configuration....................................................................................................................................68

    3.3.6 Crossbar-Light Switch Configuration..........................................................................................................69

    3.3.7 Peripheral Bridge Configuration..................................................................................................................70

    3.3.8 DMA request multiplexer configuration......................................................................................................71

    3.3.9 DMA Controller Configuration...................................................................................................................74

    3.3.10 External Watchdog Monitor (EWM) Configuration....................................................................................75

    3.3.11 Watchdog Configuration..............................................................................................................................77

    3.4 Clock modules..............................................................................................................................................................78

    3.4.1 MCG Configuration.....................................................................................................................................78

    3.4.2 OSC Configuration......................................................................................................................................79

    3.4.3 RTC OSC configuration...............................................................................................................................80

    K12 Sub-Family Reference Manual, Rev. 4, February 2013

    4 Freescale Semiconductor, Inc.

  • Section number Title Page

    3.5 Memories and memory interfaces.................................................................................................................................80

    3.5.1 Flash Memory Configuration.......................................................................................................................80

    3.5.2 Flash Memory Controller Configuration.....................................................................................................84

    3.5.3 SRAM Configuration...................................................................................................................................85

    3.5.4 System Register File Configuration.............................................................................................................87

    3.5.5 VBAT Register File Configuration..............................................................................................................88

    3.5.6 EzPort Configuration...................................................................................................................................89

    3.6 Security.........................................................................................................................................................................90

    3.6.1 CRC Configuration......................................................................................................................................90

    K12 Sub-Family Reference Manual, Rev. 4, February 2013

    Freescale Semiconductor, Inc. 5

  • Section number Title Page

    3.7 Analog...........................................................................................................................................................................91

    3.7.1 16-bit SAR ADC Configuration..................................................................................................................91

    3.7.2 CMP Configuration......................................................................................................................................95

    3.7.3 VREF Configuration....................................................................................................................................96

    3.8 Timers...........................................................................................................................................................................97

    3.8.1 PDB Configuration......................................................................................................................................97

    3.8.2 FlexTimer Configuration.............................................................................................................................100

    3.8.3 PIT Configuration........................................................................................................................................103

    3.8.4 Low-power timer configuration...................................................................................................................104

    3.8.5 CMT Configuration......................................................................................................................................106

    3.8.6 RTC configuration.......................................................................................................................................107

    3.9 Communication interfaces............................................................................................................................................108

    3.9.1 SPI configuration.........................................................................................................................................108

    3.9.2 I2C Configuration........................................................................................................................................111

    3.9.3 UART Configuration...................................................................................................................................112

    3.9.4 I2S configuration..........................................................................................................................................114

    3.10 Human-machine interfaces...........................................................................................................................................117

    3.10.1 GPIO configuration......................................................................................................................................117

    Chapter 4Memory Map

    4.1 Introduction...................................................................................................................................................................119

    4.2 System memory map.....................................................................................................................................................119

    4.2.1 Aliased bit-band regions..............................................................................................................................120

    4.3 Flash Memory Map.......................................................................................................................................................121

    4.3.1 Alternate Non-Volatile IRC User Trim Description....................................................................................122

    4.4 SRAM memory map.....................................................................................................................................................122

    4.5 Peripheral bridge (AIPS-Lite) memory map.................................................................................................................123

    4.5.1 Read-after-write sequence and required serialization of memory operations..............................................123

    4.5.2 Peripheral Bridge 0 (AIPS-Lite 0) Memory Map........................................................................................123

    K12 Sub-Family Reference Manual, Rev. 4, February 2013

    6 Freescale Semiconductor, Inc.

  • Section number Title Page

    4.6 Private Peripheral Bus (PPB) memory map..................................................................................................................127

    Chapter 5Clock Distribution

    5.1 Introduction...................................................................................................................................................................129

    5.2 Programming model......................................................................................................................................................129

    5.3 High-Level device clocking diagram............................................................................................................................129

    5.4 Clock definitions...........................................................................................................................................................130

    5.4.1 Device clock summary.................................................................................................................................131

    5.5 Internal clocking requirements.....................................................................................................................................132

    5.5.1 Clock divider values after reset....................................................................................................................133

    5.5.2 VLPR mode clocking...................................................................................................................................133

    5.6 Clock Gating.................................................................................................................................................................134

    5.7 Module clocks...............................................................................................................................................................134

    5.7.1 PMC 1-kHz LPO clock................................................................................................................................135

    5.7.2 WDOG clocking..........................................................................................................................................136

    5.7.3 Debug trace clock.........................................................................................................................................136

    5.7.4 PORT digital filter clocking.........................................................................................................................137

    5.7.5 LPTMR clocking..........................................................................................................................................137

    5.7.6 UART clocking............................................................................................................................................138

    5.7.7 I2S/SAI clocking..........................................................................................................................................138

    Chapter 6Reset and Boot

    6.1 Introduction...................................................................................................................................................................139

    6.2 Reset..............................................................................................................................................................................140

    6.2.1 Power-on reset (POR)..................................................................................................................................140

    6.2.2 System reset sources....................................................................................................................................140

    6.2.3 MCU Resets.................................................................................................................................................144

    6.2.4 Reset Pin .....................................................................................................................................................146

    K12 Sub-Family Reference Manual, Rev. 4, February 2013

    Freescale Semiconductor, Inc. 7

  • Section number Title Page

    6.2.5 Debug resets.................................................................................................................................................146

    6.3 Boot...............................................................................................................................................................................147

    6.3.1 Boot sources.................................................................................................................................................147

    6.3.2 Boot options.................................................................................................................................................147

    6.3.3 FOPT boot options.......................................................................................................................................148

    6.3.4 Boot sequence..............................................................................................................................................149

    Chapter 7Power Management

    7.1 Introduction...................................................................................................................................................................151

    7.2 Power modes.................................................................................................................................................................151

    7.3 Entering and exiting power modes...............................................................................................................................153

    7.4 Power mode transitions.................................................................................................................................................154

    7.5 Power modes shutdown sequencing.............................................................................................................................155

    7.6 Module Operation in Low Power Modes......................................................................................................................156

    7.7 Clock Gating.................................................................................................................................................................159

    Chapter 8Security

    8.1 Introduction...................................................................................................................................................................161

    8.2 Flash Security...............................................................................................................................................................161

    8.3 Security Interactions with other Modules.....................................................................................................................162

    8.3.1 Security Interactions with EzPort................................................................................................................162

    8.3.2 Security Interactions with Debug.................................................................................................................162

    Chapter 9Debug

    9.1 Introduction...................................................................................................................................................................163

    9.1.1 References....................................................................................................................................................165

    9.2 The Debug Port.............................................................................................................................................................165

    9.2.1 JTAG-to-SWD change sequence.................................................................................................................166

    9.2.2 JTAG-to-cJTAG change sequence...............................................................................................................166

    9.3 Debug Port Pin Descriptions.........................................................................................................................................167

    K12 Sub-Family Reference Manual, Rev. 4, February 2013

    8 Freescale Semiconductor, Inc.

  • Section number Title Page

    9.4 System TAP connection................................................................................................................................................167

    9.4.1 IR Codes.......................................................................................................................................................167

    9.5 JTAG status and control registers.................................................................................................................................168

    9.5.1 MDM-AP Control Register..........................................................................................................................169

    9.5.2 MDM-AP Status Register............................................................................................................................171

    9.6 Debug Resets................................................................................................................................................................172

    9.7 AHB-AP........................................................................................................................................................................173

    9.8 ITM...............................................................................................................................................................................173

    9.9 Core Trace Connectivity...............................................................................................................................................174

    9.10 Embedded Trace Macrocell v3.5 (ETM)......................................................................................................................174

    9.11 TPIU..............................................................................................................................................................................174

    9.12 DWT.............................................................................................................................................................................175

    9.13 Debug in Low Power Modes........................................................................................................................................175

    9.13.1 Debug Module State in Low Power Modes.................................................................................................176

    9.14 Debug & Security.........................................................................................................................................................177

    Chapter 10Signal Multiplexing and Signal Descriptions

    10.1 Introduction...................................................................................................................................................................179

    10.2 Signal Multiplexing Integration....................................................................................................................................179

    10.2.1 Port control and interrupt module features..................................................................................................180

    10.2.2 PCRn reset values for port A.......................................................................................................................180

    10.2.3 Clock gating.................................................................................................................................................180

    10.2.4 Signal multiplexing constraints....................................................................................................................180

    10.3 Pinout............................................................................................................................................................................181

    10.3.1 K12 Signal Multiplexing and Pin Assignments...........................................................................................181

    10.3.2 K12 Pinouts..................................................................................................................................................183

    10.4 Module Signal Description Tables................................................................................................................................184

    10.4.1 Core Modules...............................................................................................................................................185

    10.4.2 System Modules...........................................................................................................................................185

    K12 Sub-Family Reference Manual, Rev. 4, February 2013

    Freescale Semiconductor, Inc. 9

  • Section number Title Page

    10.4.3 Clock Modules.............................................................................................................................................186

    10.4.4 Memories and Memory Interfaces...............................................................................................................186

    10.4.5 Analog..........................................................................................................................................................186

    10.4.6 Timer Modules.............................................................................................................................................187

    10.4.7 Communication Interfaces...........................................................................................................................189

    10.4.8 Human-Machine Interfaces (HMI)..............................................................................................................190

    Chapter 11Port control and interrupts (PORT)

    11.1 Introduction...................................................................................................................................................................191

    11.2 Overview.......................................................................................................................................................................191

    11.2.1 Features........................................................................................................................................................191

    11.2.2 Modes of operation......................................................................................................................................192

    11.3 External signal description............................................................................................................................................193

    11.4 Detailed signal description............................................................................................................................................193

    11.5 Memory map and register definition.............................................................................................................................193

    11.5.1 Pin Control Register n (PORTx_PCRn).......................................................................................................200

    11.5.2 Global Pin Control Low Register (PORTx_GPCLR)..................................................................................202

    11.5.3 Global Pin Control High Register (PORTx_GPCHR).................................................................................203

    11.5.4 Interrupt Status Flag Register (PORTx_ISFR)............................................................................................204

    11.5.5 Digital Filter Enable Register (PORTx_DFER)...........................................................................................204

    11.5.6 Digital Filter Clock Register (PORTx_DFCR)............................................................................................205

    11.5.7 Digital Filter Width Register (PORTx_DFWR)..........................................................................................205

    11.6 Functional description...................................................................................................................................................206

    11.6.1 Pin control....................................................................................................................................................206

    11.6.2 Global pin control........................................................................................................................................207

    11.6.3 External interrupts........................................................................................................................................207

    11.6.4 Digital filter..................................................................................................................................................208

    K12 Sub-Family Reference Manual, Rev. 4, February 2013

    10 Freescale Semiconductor, Inc.

  • Section number Title Page

    Chapter 12System Integration Module (SIM)

    12.1 Introduction...................................................................................................................................................................209

    12.1.1 Features........................................................................................................................................................209

    12.2 Memory map and register definition.............................................................................................................................210

    12.2.1 System Options Register 1 (SIM_SOPT1)..................................................................................................211

    12.2.2 System Options Register 2 (SIM_SOPT2)..................................................................................................212

    12.2.3 System Options Register 4 (SIM_SOPT4)..................................................................................................214

    12.2.4 System Options Register 5 (SIM_SOPT5)..................................................................................................216

    12.2.5 System Options Register 7 (SIM_SOPT7)..................................................................................................217

    12.2.6 System Device Identification Register (SIM_SDID)...................................................................................218

    12.2.7 System Clock Gating Control Register 4 (SIM_SCGC4)............................................................................220

    12.2.8 System Clock Gating Control Register 5 (SIM_SCGC5)............................................................................222

    12.2.9 System Clock Gating Control Register 6 (SIM_SCGC6)............................................................................223

    12.2.10 System Clock Gating Control Register 7 (SIM_SCGC7)............................................................................226

    12.2.11 System Clock Divider Register 1 (SIM_CLKDIV1)...................................................................................227

    12.2.12 System Clock Divider Register 2 (SIM_CLKDIV2)...................................................................................229

    12.2.13 Flash Configuration Register 1 (SIM_FCFG1)...........................................................................................229

    12.2.14 Flash Configuration Register 2 (SIM_FCFG2)...........................................................................................232

    12.2.15 Unique Identification Register High (SIM_UIDH).....................................................................................233

    12.2.16 Unique Identification Register Mid-High (SIM_UIDMH)..........................................................................234

    12.2.17 Unique Identification Register Mid Low (SIM_UIDML)...........................................................................234

    12.2.18 Unique Identification Register Low (SIM_UIDL)......................................................................................235

    12.3 Functional description...................................................................................................................................................235

    Chapter 13Reset Control Module (RCM)

    13.1 Introduction...................................................................................................................................................................237

    13.2 Reset memory map and register descriptions...............................................................................................................237

    13.2.1 System Reset Status Register 0 (RCM_SRS0)............................................................................................238

    K12 Sub-Family Reference Manual, Rev. 4, February 2013

    Freescale Semiconductor, Inc. 11

  • Section number Title Page

    13.2.2 System Reset Status Register 1 (RCM_SRS1)............................................................................................239

    13.2.3 Reset Pin Filter Control register (RCM_RPFC)..........................................................................................241

    13.2.4 Reset Pin Filter Width register (RCM_RPFW)...........................................................................................242

    13.2.5 Mode Register (RCM_MR).........................................................................................................................243

    Chapter 14System Mode Controller (SMC)

    14.1 Introduction...................................................................................................................................................................245

    14.2 Modes of operation.......................................................................................................................................................245

    14.3 Memory map and register descriptions.........................................................................................................................247

    14.3.1 Power Mode Protection register (SMC_PMPROT).....................................................................................248

    14.3.2 Power Mode Control register (SMC_PMCTRL).........................................................................................249

    14.3.3 VLLS Control register (SMC_VLLSCTRL)...............................................................................................251

    14.3.4 Power Mode Status register (SMC_PMSTAT)...........................................................................................252

    14.4 Functional description...................................................................................................................................................253

    14.4.1 Power mode transitions................................................................................................................................253

    14.4.2 Power mode entry/exit sequencing..............................................................................................................255

    14.4.3 Run modes....................................................................................................................................................257

    14.4.4 Wait modes..................................................................................................................................................259

    14.4.5 Stop modes...................................................................................................................................................260

    14.4.6 Debug in low power modes.........................................................................................................................263

    Chapter 15Power Management Controller (PMC)

    15.1 Introduction...................................................................................................................................................................265

    15.2 Features.........................................................................................................................................................................265

    15.3 Low-voltage detect (LVD) system................................................................................................................................265

    15.3.1 LVD reset operation.....................................................................................................................................266

    15.3.2 LVD interrupt operation...............................................................................................................................266

    15.3.3 Low-voltage warning (LVW) interrupt operation.......................................................................................266

    15.4 I/O retention..................................................................................................................................................................267

    K12 Sub-Family Reference Manual, Rev. 4, February 2013

    12 Freescale Semiconductor, Inc.

  • Section number Title Page

    15.5 Memory map and register descriptions.........................................................................................................................267

    15.5.1 Low Voltage Detect Status And Control 1 register (PMC_LVDSC1)........................................................268

    15.5.2 Low Voltage Detect Status And Control 2 register (PMC_LVDSC2)........................................................269

    15.5.3 Regulator Status And Control register (PMC_REGSC)..............................................................................270

    Chapter 16Low-Leakage Wakeup Unit (LLWU)

    16.1 Introduction...................................................................................................................................................................273

    16.1.1 Features........................................................................................................................................................273

    16.1.2 Modes of operation......................................................................................................................................274

    16.1.3 Block diagram..............................................................................................................................................275

    16.2 LLWU signal descriptions............................................................................................................................................276

    16.3 Memory map/register definition...................................................................................................................................277

    16.3.1 LLWU Pin Enable 1 register (LLWU_PE1)................................................................................................278

    16.3.2 LLWU Pin Enable 2 register (LLWU_PE2)................................................................................................279

    16.3.3 LLWU Pin Enable 3 register (LLWU_PE3)................................................................................................280

    16.3.4 LLWU Pin Enable 4 register (LLWU_PE4)................................................................................................281

    16.3.5 LLWU Module Enable register (LLWU_ME)............................................................................................282

    16.3.6 LLWU Flag 1 register (LLWU_F1).............................................................................................................284

    16.3.7 LLWU Flag 2 register (LLWU_F2).............................................................................................................285

    16.3.8 LLWU Flag 3 register (LLWU_F3).............................................................................................................287

    16.3.9 LLWU Pin Filter 1 register (LLWU_FILT1)..............................................................................................289

    16.3.10 LLWU Pin Filter 2 register (LLWU_FILT2)..............................................................................................290

    16.3.11 LLWU Reset Enable register (LLWU_RST)...............................................................................................291

    16.4 Functional description...................................................................................................................................................292

    16.4.1 LLS mode.....................................................................................................................................................292

    16.4.2 VLLS modes................................................................................................................................................292

    16.4.3 Initialization.................................................................................................................................................293

    K12 Sub-Family Reference Manual, Rev. 4, February 2013

    Freescale Semiconductor, Inc. 13

  • Section number Title Page

    Chapter 17Miscellaneous Control Module (MCM)

    17.1 Introduction...................................................................................................................................................................295

    17.1.1 Features........................................................................................................................................................295

    17.2 Memory map/register descriptions...............................................................................................................................295

    17.2.1 Crossbar Switch (AXBS) Slave Configuration (MCM_PLASC)................................................................296

    17.2.2 Crossbar Switch (AXBS) Master Configuration (MCM_PLAMC)............................................................296

    17.2.3 Crossbar Switch (AXBS) Control Register (MCM_PLACR).....................................................................297

    Chapter 18Crossbar Switch Lite (AXBS-Lite)

    18.1 Introduction...................................................................................................................................................................299

    18.1.1 Features........................................................................................................................................................299

    18.2 Memory Map / Register Definition...............................................................................................................................299

    18.3 Functional Description..................................................................................................................................................300

    18.3.1 General operation.........................................................................................................................................300

    18.3.2 Arbitration....................................................................................................................................................301

    18.4 Initialization/application information...........................................................................................................................302

    Chapter 19Peripheral Bridge (AIPS-Lite)

    19.1 Introduction...................................................................................................................................................................303

    19.1.1 Features........................................................................................................................................................303

    19.1.2 General operation.........................................................................................................................................303

    19.2 Functional description...................................................................................................................................................304

    19.2.1 Access support.............................................................................................................................................304

    Chapter 20Direct Memory Access Multiplexer (DMAMUX)

    20.1 Introduction...................................................................................................................................................................305

    20.1.1 Overview......................................................................................................................................................305

    20.1.2 Features........................................................................................................................................................306

    20.1.3 Modes of operation......................................................................................................................................306

    K12 Sub-Family Reference Manual, Rev. 4, February 2013

    14 Freescale Semiconductor, Inc.

  • Section number Title Page

    20.2 External signal description............................................................................................................................................307

    20.3 Memory map/register definition...................................................................................................................................307

    20.3.1 Channel Configuration register (DMAMUX_CHCFGn)............................................................................308

    20.4 Functional description...................................................................................................................................................309

    20.4.1 DMA channels with periodic triggering capability......................................................................................309

    20.4.2 DMA channels with no triggering capability...............................................................................................311

    20.4.3 Always-enabled DMA sources....................................................................................................................311

    20.5 Initialization/application information...........................................................................................................................313

    20.5.1 Reset.............................................................................................................................................................313

    20.5.2 Enabling and configuring sources................................................................................................................313

    Chapter 21Direct Memory Access Controller (eDMA)

    21.1 Introduction...................................................................................................................................................................317

    21.1.1 Block diagram..............................................................................................................................................317

    21.1.2 Block parts...................................................................................................................................................318

    21.1.3 Features........................................................................................................................................................319

    21.2 Modes of operation.......................................................................................................................................................321

    21.3 Memory map/register definition...................................................................................................................................321

    21.3.1 Control Register (DMA_CR).......................................................................................................................333

    21.3.2 Error Status Register (DMA_ES)................................................................................................................335

    21.3.3 Enable Request Register (DMA_ERQ).......................................................................................................337

    21.3.4 Enable Error Interrupt Register (DMA_EEI)...............................................................................................339

    21.3.5 Clear Enable Error Interrupt Register (DMA_CEEI)..................................................................................341

    21.3.6 Set Enable Error Interrupt Register (DMA_SEEI)......................................................................................342

    21.3.7 Clear Enable Request Register (DMA_CERQ)...........................................................................................343

    21.3.8 Set Enable Request Register (DMA_SERQ)...............................................................................................344

    21.3.9 Clear DONE Status Bit Register (DMA_CDNE)........................................................................................345

    21.3.10 Set START Bit Register (DMA_SSRT)......................................................................................................346

    21.3.11 Clear Error Register (DMA_CERR)............................................................................................................347

    K12 Sub-Family Reference Manual, Rev. 4, February 2013

    Freescale Semiconductor, Inc. 15

  • Section number Title Page

    21.3.12 Clear Interrupt Request Register (DMA_CINT).........................................................................................348

    21.3.13 Interrupt Request Register (DMA_INT)......................................................................................................349

    21.3.14 Error Register (DMA_ERR)........................................................................................................................351

    21.3.15 Hardware Request Status Register (DMA_HRS)........................................................................................354

    21.3.16 Channel n Priority Register (DMA_DCHPRIn)..........................................................................................356

    21.3.17 TCD Source Address (DMA_TCDn_SADDR)...........................................................................................357

    21.3.18 TCD Signed Source Address Offset (DMA_TCDn_SOFF)........................................................................357

    21.3.19 TCD Transfer Attributes (DMA_TCDn_ATTR).........................................................................................358

    21.3.20 TCD Minor Byte Count (Minor Loop Disabled) (DMA_TCDn_NBYTES_MLNO).................................359

    21.3.21 TCD Signed Minor Loop Offset (Minor Loop Enabled and Offset Disabled)

    (DMA_TCDn_NBYTES_MLOFFNO).......................................................................................................359

    21.3.22 TCD Signed Minor Loop Offset (Minor Loop and Offset Enabled)

    (DMA_TCDn_NBYTES_MLOFFYES).....................................................................................................361

    21.3.23 TCD Last Source Address Adjustment (DMA_TCDn_SLAST).................................................................362

    21.3.24 TCD Destination Address (DMA_TCDn_DADDR)...................................................................................362

    21.3.25 TCD Signed Destination Address Offset (DMA_TCDn_DOFF)................................................................363

    21.3.26 TCD Current Minor Loop Link, Major Loop Count (Channel Linking Enabled)

    (DMA_TCDn_CITER_ELINKYES)...........................................................................................................363

    21.3.27 TCD Current Minor Loop Link, Major Loop Count (Channel Linking Disabled)

    (DMA_TCDn_CITER_ELINKNO)............................................................................................................365

    21.3.28 TCD Last Destination Address Adjustment/Scatter Gather Address (DMA_TCDn_DLASTSGA)..........366

    21.3.29 TCD Control and Status (DMA_TCDn_CSR)............................................................................................366

    21.3.30 TCD Beginning Minor Loop Link, Major Loop Count (Channel Linking Enabled)

    (DMA_TCDn_BITER_ELINKYES)...........................................................................................................369

    21.3.31 TCD Beginning Minor Loop Link, Major Loop Count (Channel Linking Disabled)

    (DMA_TCDn_BITER_ELINKNO)............................................................................................................370

    21.4 Functional description...................................................................................................................................................371

    21.4.1 eDMA basic data flow.................................................................................................................................371

    21.4.2 Error reporting and handling........................................................................................................................374

    21.4.3 Channel preemption.....................................................................................................................................375

    K12 Sub-Family Reference Manual, Rev. 4, February 2013

    16 Freescale Semiconductor, Inc.

  • Section number Title Page

    21.4.4 Performance.................................................................................................................................................376

    21.5 Initialization/application information...........................................................................................................................380

    21.5.1 eDMA initialization.....................................................................................................................................380

    21.5.2 Programming errors.....................................................................................................................................382

    21.5.3 Arbitration mode considerations..................................................................................................................383

    21.5.4 Performing DMA transfers (examples)........................................................................................................383

    21.5.5 Monitoring transfer descriptor status...........................................................................................................387

    21.5.6 Channel Linking...........................................................................................................................................389

    21.5.7 Dynamic programming................................................................................................................................390

    Chapter 22External Watchdog Monitor (EWM)

    22.1 Introduction...................................................................................................................................................................395

    22.1.1 Features........................................................................................................................................................395

    22.1.2 Modes of Operation.....................................................................................................................................396

    22.1.3 Block Diagram.............................................................................................................................................397

    22.2 EWM Signal Descriptions............................................................................................................................................398

    22.3 Memory Map/Register Definition.................................................................................................................................398

    22.3.1 Control Register (EWM_CTRL).................................................................................................................398

    22.3.2 Service Register (EWM_SERV)..................................................................................................................399

    22.3.3 Compare Low Register (EWM_CMPL)......................................................................................................399

    22.3.4 Compare High Register (EWM_CMPH).....................................................................................................400

    22.4 Functional Description..................................................................................................................................................401

    22.4.1 The EWM_out Signal..................................................................................................................................401

    22.4.2 The EWM_in Signal....................................................................................................................................402

    22.4.3 EWM Counter..............................................................................................................................................402

    22.4.4 EWM Compare Registers............................................................................................................................402

    22.4.5 EWM Refresh Mechanism...........................................................................................................................403

    22.4.6 EWM Interrupt.............................................................................................................................................403

    K12 Sub-Family Reference Manual, Rev. 4, February 2013

    Freescale Semiconductor, Inc. 17

  • Section number Title Page

    Chapter 23Watchdog Timer (WDOG)

    23.1 Introduction...................................................................................................................................................................405

    23.2 Features.........................................................................................................................................................................405

    23.3 Functional overview......................................................................................................................................................407

    23.3.1 Unlocking and updating the watchdog.........................................................................................................408

    23.3.2 Watchdog configuration time (WCT)..........................................................................................................409

    23.3.3 Refreshing the watchdog..............................................................................................................................410

    23.3.4 Windowed mode of operation......................................................................................................................410

    23.3.5 Watchdog disabled mode of operation.........................................................................................................410

    23.3.6 Low-power modes of operation...................................................................................................................411

    23.3.7 Debug modes of operation...........................................................................................................................411

    23.4 Testing the watchdog....................................................................................................................................................412

    23.4.1 Quick test.....................................................................................................................................................412

    23.4.2 Byte test........................................................................................................................................................413

    23.5 Backup reset generator..................................................................................................................................................414

    23.6 Generated resets and interrupts.....................................................................................................................................414

    23.7 Memory map and register definition.............................................................................................................................415

    23.7.1 Watchdog Status and Control Register High (WDOG_STCTRLH)...........................................................416

    23.7.2 Watchdog Status and Control Register Low (WDOG_STCTRLL)............................................................417

    23.7.3 Watchdog Time-out Value Register High (WDOG_TOVALH).................................................................418

    23.7.4 Watchdog Time-out Value Register Low (WDOG_TOVALL)..................................................................418

    23.7.5 Watchdog Window Register High (WDOG_WINH)..................................................................................419

    23.7.6 Watchdog Window Register Low (WDOG_WINL)...................................................................................419

    23.7.7 Watchdog Refresh register (WDOG_REFRESH).......................................................................................420

    23.7.8 Watchdog Unlock register (WDOG_UNLOCK).........................................................................................420

    23.7.9 Watchdog Timer Output Register High (WDOG_TMROUTH).................................................................420

    23.7.10 Watchdog Timer Output Register Low (WDOG_TMROUTL)..................................................................421

    23.7.11 Watchdog Reset Count register (WDOG_RSTCNT)..................................................................................421

    K12 Sub-Family Reference Manual, Rev. 4, February 2013

    18 Freescale Semiconductor, Inc.

  • Section number Title Page

    23.7.12 Watchdog Prescaler register (WDOG_PRESC)..........................................................................................422

    23.8 Watchdog operation with 8-bit access..........................................................................................................................422

    23.8.1 General guideline.........................................................................................................................................422

    23.8.2 Refresh and unlock operations with 8-bit access.........................................................................................422

    23.9 Restrictions on watchdog operation..............................................................................................................................423

    Chapter 24Multipurpose Clock Generator (MCG)

    24.1 Introduction...................................................................................................................................................................427

    24.1.1 Features........................................................................................................................................................427

    24.1.2 Modes of Operation.....................................................................................................................................430

    24.2 External Signal Description..........................................................................................................................................431

    24.3 Memory Map/Register Definition.................................................................................................................................431

    24.3.1 MCG Control 1 Register (MCG_C1)...........................................................................................................432

    24.3.2 MCG Control 2 Register (MCG_C2)...........................................................................................................433

    24.3.3 MCG Control 3 Register (MCG_C3)...........................................................................................................434

    24.3.4 MCG Control 4 Register (MCG_C4)...........................................................................................................435

    24.3.5 MCG Control 5 Register (MCG_C5)...........................................................................................................436

    24.3.6 MCG Control 6 Register (MCG_C6)...........................................................................................................437

    24.3.7 MCG Status Register (MCG_S)..................................................................................................................439

    24.3.8 MCG Status and Control Register (MCG_SC)............................................................................................440

    24.3.9 MCG Auto Trim Compare Value High Register (MCG_ATCVH)............................................................442

    24.3.10 MCG Auto Trim Compare Value Low Register (MCG_ATCVL)..............................................................442

    24.3.11 MCG Control 7 Register (MCG_C7)...........................................................................................................442

    24.3.12 MCG Control 8 Register (MCG_C8)...........................................................................................................443

    24.3.13 MCG Control 9 Register (MCG_C9)...........................................................................................................444

    24.3.14 MCG Control 10 Register (MCG_C10).......................................................................................................444

    24.4 Functional Description..................................................................................................................................................445

    24.4.1 MCG mode state diagram............................................................................................................................445

    24.4.2 Low Power Bit Usage..................................................................................................................................449

    K12 Sub-Family Reference Manual, Rev. 4, February 2013

    Freescale Semiconductor, Inc. 19

  • Section number Title Page

    24.4.3 MCG Internal Reference Clocks..................................................................................................................449

    24.4.4 External Reference Clock............................................................................................................................450

    24.4.5 MCG Fixed frequency clock .......................................................................................................................450

    24.4.6 MCG PLL clock ..........................................................................................................................................451

    24.4.7 MCG Auto TRIM (ATM)............................................................................................................................451

    24.5 Initialization / Application information........................................................................................................................452

    24.5.1 MCG module initialization sequence...........................................................................................................452

    24.5.2 Using a 32.768 kHz reference......................................................................................................................455

    24.5.3 MCG mode switching..................................................................................................................................455

    Chapter 25Oscillator (OSC)

    25.1 Introduction...................................................................................................................................................................465

    25.2 Features and Modes......................................................................................................................................................465

    25.3 Block Diagram..............................................................................................................................................................466

    25.4 OSC Signal Descriptions..............................................................................................................................................466

    25.5 External Crystal / Resonator Connections....................................................................................................................467

    25.6 External Clock Connections.........................................................................................................................................468

    25.7 Memory Map/Register Definitions...............................................................................................................................469

    25.7.1 OSC Memory Map/Register Definition.......................................................................................................469

    25.8 Functional Description..................................................................................................................................................470

    25.8.1 OSC Module States......................................................................................................................................470

    25.8.2 OSC Module Modes.....................................................................................................................................472

    25.8.3 Counter.........................................................................................................................................................474

    25.8.4 Reference Clock Pin Requirements.............................................................................................................474

    25.9 Reset..............................................................................................................................................................................474

    25.10 Low Power Modes Operation.......................................................................................................................................475

    25.11 Interrupts.......................................................................................................................................................................475

    K12 Sub-Family Reference Manual, Rev. 4, February 2013

    20 Freescale Semiconductor, Inc.

  • Section number Title Page

    Chapter 26RTC Oscillator (OSC32K)

    26.1 Introduction...................................................................................................................................................................477

    26.1.1 Features and Modes.....................................................................................................................................477

    26.1.2 Block Diagram.............................................................................................................................................477

    26.2 RTC Signal Descriptions..............................................................................................................................................478

    26.2.1 EXTAL32 Oscillator Input.....................................................................................................................478

    26.2.2 XTAL32 Oscillator Output.....................................................................................................................478

    26.3 External Crystal Connections.......................................................................................................................................479

    26.4 Memory Map/Register Descriptions.............................................................................................................................479

    26.5 Functional Description..................................................................................................................................................479

    26.6 Reset Overview.............................................................................................................................................................480

    26.7 Interrupts.......................................................................................................................................................................480

    Chapter 27Flash Memory Controller (FMC)

    27.1 Introduction...................................................................................................................................................................481

    27.1.1 Overview......................................................................................................................................................481

    27.1.2 Features........................................................................................................................................................482

    27.2 Modes of operation.......................................................................................................................................................482

    27.3 External signal description............................................................................................................................................482

    27.4 Memory map and register descriptions.........................................................................................................................483

    27.4.1 Flash Access Protection Register (FMC_PFAPR).......................................................................................485

    27.4.2 Flash Bank 0 Control Register (FMC_PFB0CR)........................................................................................488

    27.4.3 Flash Bank 1 Control Register (FMC_PFB1CR)........................................................................................491

    27.4.4 Cache Tag Storage (FMC_TAGVDW0Sn).................................................................................................493

    27.4.5 Cache Tag Storage (FMC_TAGVDW1Sn).................................................................................................494

    27.4.6 Cache Tag Storage (FMC_TAGVDW2Sn).................................................................................................495

    27.4.7 Cache Tag Storage (FMC_TAGVDW3Sn).................................................................................................496

    27.4.8 Cache Data Storage (upper word) (FMC_DATAW0SnU)..........................................................................496

    K12 Sub-Family Reference Manual, Rev. 4, February 2013

    Freescale Semiconductor, Inc. 21

  • Section number Title Page

    27.4.9 Cache Data Storage (lower word) (FMC_DATAW0SnL)..........................................................................497

    27.4.10 Cache Data Storage (upper word) (FMC_DATAW1SnU)..........................................................................497

    27.4.11 Cache Data Storage (lower word) (FMC_DATAW1SnL)..........................................................................498

    27.4.12 Cache Data Storage (upper word) (FMC_DATAW2SnU)..........................................................................498

    27.4.13 Cache Data Storage (lower word) (FMC_DATAW2SnL)..........................................................................499

    27.4.14 Cache Data Storage (upper word) (FMC_DATAW3SnU)..........................................................................499

    27.4.15 Cache Data Storage (lower word) (FMC_DATAW3SnL)..........................................................................500

    27.5 Functional description...................................................................................................................................................500

    27.5.1 Default configuration...................................................................................................................................500

    27.5.2 Configuration options..................................................................................................................................501

    27.5.3 Wait states....................................................................................................................................................501

    27.5.4 Speculative reads..........................................................................................................................................502

    27.6 Initialization and application information.....................................................................................................................503

    Chapter 28Flash Memory Module (FTFL)

    28.1 Introduction...................................................................................................................................................................505

    28.1.1 Features........................................................................................................................................................506

    28.1.2 Block Diagram.............................................................................................................................................508

    28.1.3 Glossary.......................................................................................................................................................509

    28.2 External Signal Description..........................................................................................................................................511

    28.3 Memory Map and Registers..........................................................................................................................................511

    28.3.1 Flash Configuration Field Description.........................................................................................................512

    28.3.2 Program Flash IFR Map...............................................................................................................................512

    28.3.3 Data Flash IFR Map.....................................................................................................................................513

    28.3.4 Register Descriptions...................................................................................................................................515

    28.4 Functional Description..................................................................................................................................................528

    28.4.1 Program Flash Memory Swap......................................................................................................................528

    28.4.2 Flash Protection............................................................................................................................................528

    K12 Sub-Family Reference Manual, Rev. 4, February 2013

    22 Freescale Semiconductor, Inc.

  • Section number Title Page

    28.4.3 FlexNVM Description..................................................................................................................................530

    28.4.4 Interrupts......................................................................................................................................................534

    28.4.5 Flash Operation in Low-Power Modes........................................................................................................535

    28.4.6 Functional Modes of Operation...................................................................................................................535

    28.4.7 Flash Reads and Ignored Writes..................................................................................................................535

    28.4.8 Read While Write (RWW)...........................................................................................................................536

    28.4.9 Flash Program and Erase..............................................................................................................................536

    28.4.10 Flash Command Operations.........................................................................................................................537

    28.4.11 Margin Read Commands.............................................................................................................................545

    28.4.12 Flash Command Description........................................................................................................................546

    28.4.13 Security........................................................................................................................................................574

    28.4.14 Reset Sequence............................................................................................................................................576

    Chapter 29EzPort

    29.1 Overview.......................................................................................................................................................................577

    29.1.1 Introduction..................................................................................................................................................577

    29.1.2 Features........................................................................................................................................................578

    29.1.3 Modes of operation......................................................................................................................................578

    29.2 External signal description............................................................................................................................................579

    29.2.1 EzPort Clock (EZP_CK)..............................................................................................................................579

    29.2.2 EzPort Chip Select (EZP_CS)......................................................................................................................579

    29.2.3 EzPort Serial Data In (EZP_D)....................................................................................................................580

    29.2.4 EzPort Serial Data Out (EZP_Q).................................................................................................................580

    29.3 Command definition.....................................................................................................................................................580

    29.3.1 Command descriptions.................................................................................................................................581

    29.4 Flash memory map for EzPort access...........................................................................................................................587

    K12 Sub-Family Reference Manual, Rev. 4, February 2013

    Freescale Semiconductor, Inc. 23

  • Section number Title Page

    Chapter 30Cyclic Redundancy Check (CRC)

    30.1 Introduction...................................................................................................................................................................589

    30.1.1 Features........................................................................................................................................................589

    30.1.2 Block diagram..............................................................................................................................................589

    30.1.3 Modes of operation......................................................................................................................................590

    30.2 Memory map and register descriptions.........................................................................................................................590

    30.2.1 CRC Data register (CRC_DATA)...............................................................................................................591

    30.2.2 CRC Polynomial register (CRC_GPOLY)..................................................................................................592

    30.2.3 CRC Control register (CRC_CTRL).................................................................................................