Table of Contents

Advertisement

Quick Links

K51 Sub-Family Reference Manual
Supports: MK51DX256ZCMC10, MK51DN512ZCMC10
Document Number: K51P121M100SF2RM
Rev. 6, Nov 2011

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the freescale K51 Series and is the answer not in the manual?

Questions and answers

Summary of Contents for NXP Semiconductors freescale K51 Series

  • Page 1 K51 Sub-Family Reference Manual Supports: MK51DX256ZCMC10, MK51DN512ZCMC10 Document Number: K51P121M100SF2RM Rev. 6, Nov 2011...
  • Page 2 K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 3: Table Of Contents

    Contents Section Number Title Page Chapter 1 About This Document Overview..................................53 1.1.1 Purpose.................................53 1.1.2 Audience..............................53 Conventions..................................53 1.2.1 Numbering systems............................53 1.2.2 Typographic notation...........................54 1.2.3 Special terms..............................54 Chapter 2 Introduction Overview..................................55 K50 Family Introduction...............................55 Module Functional Categories............................55 2.3.1 ARM Cortex-M4 Core Modules........................57 2.3.2 System Modules............................57 2.3.3...
  • Page 4 Section Number Title Page Core modules................................65 3.2.1 ARM Cortex-M4 Core Configuration......................65 3.2.2 Nested Vectored Interrupt Controller (NVIC) Configuration..............68 3.2.3 Asynchronous Wake-up Interrupt Controller (AWIC) Configuration............74 3.2.4 JTAG Controller Configuration........................75 System modules................................76 3.3.1 SIM Configuration............................76 3.3.2 Mode Controller Configuration........................77 3.3.3 PMC Configuration............................77 3.3.4 Low-Leakage Wake-up Unit (LLWU) Configuration.................78 3.3.5...
  • Page 5 Section Number Title Page 3.5.5 System Register File Configuration......................104 3.5.6 VBAT Register File Configuration......................105 3.5.7 EzPort Configuration...........................106 Security..................................107 3.6.1 CRC Configuration............................107 K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 6 Section Number Title Page Analog...................................107 3.7.1 16-bit SAR ADC with PGA Configuration....................107 3.7.2 CMP Configuration............................115 3.7.3 12-bit DAC Configuration...........................117 3.7.4 Op-amp Configuration..........................118 3.7.5 TRIAMP Configuration..........................120 3.7.6 VREF Configuration............................121 Timers...................................122 3.8.1 PDB Configuration............................122 3.8.2 FlexTimer Configuration..........................126 3.8.3 PIT Configuration............................129 3.8.4 Low-power timer configuration........................130 3.8.5 CMT Configuration............................132 3.8.6...
  • Page 7 Section Number Title Page System memory map..............................155 4.2.1 Aliased bit-band regions..........................156 Flash Memory Map...............................157 4.3.1 Alternate Non-Volatile IRC User Trim Description..................158 SRAM memory map..............................158 Peripheral bridge (AIPS-Lite0 and AIPS-Lite1) memory maps...................159 4.5.1 Peripheral Bridge 0 (AIPS-Lite 0) Memory Map..................159 4.5.2 Peripheral Bridge 1 (AIPS-Lite 1) Memory Map..................163 Private Peripheral Bus (PPB) memory map........................167 Chapter 5...
  • Page 8 Section Number Title Page 5.7.9 I2S clocking..............................180 5.7.10 TSI clocking..............................180 Chapter 6 Reset and Boot Introduction...................................183 Reset....................................183 6.2.1 Power-on reset (POR)..........................184 6.2.2 System resets..............................184 6.2.3 Debug resets..............................187 Boot....................................189 6.3.1 Boot sources..............................189 6.3.2 Boot options..............................189 6.3.3 FOPT boot options............................189 6.3.4 Boot sequence..............................190 Chapter 7 Power Management Introduction...................................193...
  • Page 9 Section Number Title Page Chapter 9 Debug Introduction...................................203 9.1.1 References..............................205 The Debug Port................................205 9.2.1 JTAG-to-SWD change sequence.........................206 9.2.2 JTAG-to-cJTAG change sequence.......................206 Debug Port Pin Descriptions............................207 System TAP connection..............................207 9.4.1 IR Codes...............................207 JTAG status and control registers..........................208 9.5.1 MDM-AP Control Register..........................209 9.5.2 MDM-AP Status Register..........................211 Debug Resets................................212...
  • Page 10 Section Number Title Page 10.2 Signal Multiplexing Integration............................219 10.2.1 Port control and interrupt module features....................220 10.2.2 Clock gating..............................220 10.2.3 Signal multiplexing constraints........................220 10.3 Pinout....................................221 10.3.1 K51 Signal Multiplexing and Pin Assignments...................221 10.3.2 K51 Pinouts..............................226 10.4 Module Signal Description Tables..........................227 10.4.1 Core Modules...............................227 10.4.2 System Modules............................228...
  • Page 11 Section Number Title Page 11.4.6 Digital Filter Clock Register (PORTx_DFCR)....................251 11.4.7 Digital Filter Width Register (PORTx_DFWR)..................251 11.5 Functional description..............................252 11.5.1 Pin control..............................252 11.5.2 Global pin control............................252 11.5.3 External interrupts............................253 11.5.4 Digital filter..............................254 Chapter 12 System integration module (SIM) 12.1 Introduction...................................255 12.1.1 Features................................255 12.1.2...
  • Page 12 Section Number Title Page 12.2.16 System Clock Divider Register 2 (SIM_CLKDIV2)...................283 12.2.17 Flash Configuration Register 1 (SIM_FCFG1)...................284 12.2.18 Flash Configuration Register 2 (SIM_FCFG2)...................286 12.2.19 Unique Identification Register High (SIM_UIDH)..................287 12.2.20 Unique Identification Register Mid-High (SIM_UIDMH)................288 12.2.21 Unique Identification Register Mid Low (SIM_UIDML)................288 12.2.22 Unique Identification Register Low (SIM_UIDL)..................289 12.3...
  • Page 13 Section Number Title Page 14.4.2 Low Voltage Detect Status and Control 2 Register (PMC_LVDSC2)............316 14.4.3 Regulator Status and Control Register (PMC_REGSC)................318 Chapter 15 Low-leakage wake-up unit (LLWU) 15.1 Introduction...................................321 15.1.1 Features................................322 15.1.2 Modes of operation............................322 15.1.3 Block diagram..............................323 15.2 LLWU Signal Descriptions............................324 15.3 Memory map/register definition...........................325 15.3.1...
  • Page 14 Section Number Title Page 16.2 Memory Map/Register Descriptions..........................341 16.2.1 Crossbar switch (AXBS) slave configuration (MCM_PLASC)..............342 16.2.2 Crossbar switch (AXBS) master configuration (MCM_PLAMC)..............342 16.2.3 SRAM arbitration and protection (MCM_SRAMAP).................343 16.2.4 Interrupt status register (MCM_ISR)......................344 16.2.5 ETB counter control register (MCM_ETBCC)...................345 16.2.6 ETB reload register (MCM_ETBRL)......................346 16.2.7 ETB counter value register (MCM_ETBCNT)...................347...
  • Page 15 Section Number Title Page 18.3 Memory Map/Register Definition..........................365 18.3.1 Control/Error Status Register (MPU_CESR)....................368 18.3.2 Error Address Register, Slave Port n (MPU_EARn)...................370 18.3.3 Error Detail Register, Slave Port n (MPU_EDRn)..................371 18.3.4 Region Descriptor n, Word 0 (MPU_RGDn_WORD0)................372 18.3.5 Region Descriptor n, Word 1 (MPU_RGDn_WORD1)................373 18.3.6 Region Descriptor n, Word 2 (MPU_RGDn_WORD2)................373 18.3.7...
  • Page 16 Section Number Title Page Chapter 20 Direct memory access multiplexer (DMAMUX) 20.1 Introduction...................................403 20.1.1 Overview..............................403 20.1.2 Features................................404 20.1.3 Modes of operation............................404 20.2 External signal description............................405 20.3 Memory map/register definition...........................405 20.3.1 Channel Configuration Register (DMAMUX_CHCFGn)................406 20.4 Functional description..............................407 20.4.1 DMA channels with periodic triggering capability..................407 20.4.2 DMA channels with no triggering capability....................410 20.4.3...
  • Page 17 Section Number Title Page 21.3.6 Set Enable Error Interrupt Register (DMA_SEEI)..................443 21.3.7 Clear Enable Request Register (DMA_CERQ)...................444 21.3.8 Set Enable Request Register (DMA_SERQ)....................445 21.3.9 Clear DONE Status Bit Register (DMA_CDNE)..................446 21.3.10 Set START Bit Register (DMA_SSRT)......................447 21.3.11 Clear Error Register (DMA_CERR)......................448 21.3.12 Clear Interrupt Request Register (DMA_CINT)..................449 21.3.13...
  • Page 18 Section Number Title Page 21.3.31 TCD Beginning Minor Loop Link, Major Loop Count (Channel Linking Disabled) (DMA_TCDn_BITER_ELINKNO)......................469 21.4 Functional description..............................470 21.4.1 eDMA basic data flow..........................470 21.4.2 Error reporting and handling........................473 21.4.3 Channel preemption.............................475 21.4.4 Performance..............................475 21.5 Initialization/application information...........................480 21.5.1 eDMA initialization.............................480 21.5.2 Programming errors.............................482 21.5.3...
  • Page 19 Section Number Title Page 22.4.2 The EWM_in Signal............................500 22.4.3 EWM Counter..............................500 22.4.4 EWM Compare Registers..........................500 22.4.5 EWM Refresh Mechanism...........................501 Chapter 23 Watchdog Timer (WDOG) 23.1 Introduction...................................503 23.2 Features..................................503 23.3 Functional Overview..............................505 23.3.1 Unlocking and Updating the Watchdog.......................506 23.3.2 The Watchdog Configuration Time (WCT)....................507 23.3.3 Refreshing the Watchdog..........................508 23.3.4...
  • Page 20 Section Number Title Page 23.7.8 Watchdog Unlock Register (WDOG_UNLOCK)..................518 23.7.9 Watchdog Timer Output Register High (WDOG_TMROUTH)..............519 23.7.10 Watchdog Timer Output Register Low (WDOG_TMROUTL)..............519 23.7.11 Watchdog Reset Count Register (WDOG_RSTCNT).................520 23.7.12 Watchdog Prescaler Register (WDOG_PRESC)..................520 23.8 Watchdog Operation with 8-bit access.........................520 23.8.1 General Guideline............................520 23.8.2...
  • Page 21 Section Number Title Page 24.4.3 MCG Internal Reference Clocks........................545 24.4.4 External Reference Clock..........................546 24.4.5 MCG Fixed Frequency Clock ........................546 24.4.6 MCG PLL Clock ............................547 24.4.7 MCG Auto TRIM (ATM)..........................547 24.5 Initialization / Application Information........................548 24.5.1 MCG Module Initialization Sequence......................548 24.5.2 Using a 32.768 kHz Reference........................550 24.5.3 MCG Mode Switching..........................551...
  • Page 22 Section Number Title Page Chapter 26 RTC Oscillator 26.1 Introduction...................................573 26.1.1 Features and Modes.............................573 26.1.2 Block Diagram.............................573 26.2 RTC Signal Descriptions..............................574 26.2.1 EXTAL32 — Oscillator Input........................574 26.2.2 XTAL32 — Oscillator Output........................574 26.3 External Crystal Connections............................575 26.4 Memory Map/Register Descriptions..........................575 26.5 Functional Description..............................575 26.6 Reset Overview................................576...
  • Page 23 Section Number Title Page 27.4.9 Cache Data Storage (lower word) (FMC_DATAW0SnL)................598 27.4.10 Cache Data Storage (upper word) (FMC_DATAW1SnU)................599 27.4.11 Cache Data Storage (lower word) (FMC_DATAW1SnL)................600 27.4.12 Cache Data Storage (upper word) (FMC_DATAW2SnU)................601 27.4.13 Cache Data Storage (lower word) (FMC_DATAW2SnL)................602 27.4.14 Cache Data Storage (upper word) (FMC_DATAW3SnU)................603 27.4.15 Cache Data Storage (lower word) (FMC_DATAW3SnL)................604...
  • Page 24 Section Number Title Page 28.4.9 Flash Program and Erase..........................639 28.4.10 FTFL Command Operations........................639 28.4.11 Margin Read Commands..........................648 28.4.12 FTFL Command Description........................649 28.4.13 Security................................677 28.4.14 Reset Sequence............................679 Chapter 29 EzPort 29.1 Overview..................................681 29.1.1 Introduction..............................681 29.1.2 Features................................682 29.1.3 Modes of Operation.............................682 29.2 External Signal Description............................683 29.2.1 EzPort Clock (EZP_CK)..........................683...
  • Page 25 Section Number Title Page 30.2.3 CRC Control Register (CRC_CTRL)......................697 30.3 Functional description..............................698 30.3.1 CRC initialization/re-initialization.......................698 30.3.2 CRC calculations............................698 30.3.3 Transpose feature............................699 30.3.4 CRC result complement..........................701 Chapter 31 Analog-to-Digital Converter (ADC) 31.1 Introduction...................................703 31.1.1 Features................................703 31.1.2 Block diagram..............................704 31.2 ADC Signal Descriptions..............................705 31.2.1 Analog power (VDDA)..........................706 31.2.2...
  • Page 26 Section Number Title Page 31.3.12 ADC plus-side general calibration value register (ADCx_CLPS)...............724 31.3.13 ADC plus-side general calibration value register (ADCx_CLP4)...............724 31.3.14 ADC plus-side general calibration value register (ADCx_CLP3)...............725 31.3.15 ADC plus-side general calibration value register (ADCx_CLP2)...............725 31.3.16 ADC plus-side general calibration value register (ADCx_CLP1)...............726 31.3.17 ADC plus-side general calibration value register (ADCx_CLP0)...............726 31.3.18...
  • Page 27 Section Number Title Page 31.5 Initialization information..............................748 31.5.1 ADC module initialization example......................749 31.6 Application information..............................751 31.6.1 External pins and routing..........................751 31.6.2 Sources of error............................753 Chapter 32 Comparator (CMP) 32.1 Introduction...................................759 32.2 CMP Features................................759 32.3 6-bit DAC Key Features...............................760 32.4 ANMUX Key Features..............................761 32.5 CMP, DAC, and ANMUX Diagram..........................761 32.6...
  • Page 28 Section Number Title Page 32.12 DAC Functional Description............................786 32.12.1 Voltage Reference Source Select.........................786 32.13 DAC Resets...................................786 32.14 DAC Clocks..................................786 32.15 DAC Interrupts................................787 Chapter 33 12-bit Digital-to-Analog Converter (DAC) 33.1 Introduction...................................789 33.2 Features..................................789 33.3 Block Diagram................................789 33.4 Memory Map/Register Definition..........................790 33.4.1 DAC Data Low Register (DACx_DATnL)....................794 33.4.2 DAC Data High Register (DACx_DATnH)....................795...
  • Page 29 Section Number Title Page 34.2 Signal Description.................................807 34.2.1 INPx+................................807 34.2.2 INPx-................................807 34.2.3 VOUTx.................................807 34.3 Memory Map and Registers............................808 34.3.1 Control Register 0 (OPAMPx_C0)......................808 34.3.2 Control Register 1 (OPAMPx_C1)......................809 34.3.3 Control Register 2 (OPAMPx_C2)......................810 34.4 Functional Description..............................811 34.4.1 Operational Amplifier Configuration......................811 34.4.2 Buffer Configuration............................811 34.4.3...
  • Page 30 Section Number Title Page Chapter 36 Voltage Reference (VREFV1) 36.1 Introduction...................................821 36.1.1 Overview..............................822 36.1.2 Features................................822 36.1.3 Modes of Operation.............................823 36.1.4 VREF Signal Descriptions...........................823 36.2 Memory Map and Register Definition..........................823 36.2.1 VREF Trim Register (VREF_TRM)......................824 36.2.2 VREF Status and Control Register (VREF_SC)..................825 36.3 Functional Description..............................826 36.3.1...
  • Page 31 Section Number Title Page 37.3.5 Channel n Control Register 1 (PDBx_CHnC1)...................839 37.3.6 Channel n Status Register (PDBx_CHnS)....................840 37.3.7 Channel n Delay 0 Register (PDBx_CHnDLY0)..................841 37.3.8 Channel n Delay 1 Register (PDBx_CHnDLY1)..................841 37.3.9 DAC Interval Trigger n Control Register (PDBx_DACINTCn)..............842 37.3.10 DAC Interval n Register (PDBx_DACINTn)....................842 37.3.11 Pulse-Out n Enable Register (PDBx_POEN)....................843...
  • Page 32 Section Number Title Page 38.2.4 PHA — FTM Quadrature Decoder Phase A Input..................857 38.2.5 PHB — FTM Quadrature Decoder Phase B Input..................857 38.3 Memory Map and Register Definition..........................857 38.3.1 Module Memory Map..........................857 38.3.2 Register Descriptions...........................857 38.3.3 Status and Control (FTMx_SC)........................864 38.3.4 Counter (FTMx_CNT)..........................865 38.3.5...
  • Page 33 Section Number Title Page 38.3.27 FTM PWM Load (FTMx_PWMLOAD).....................907 38.4 Functional Description..............................909 38.4.1 Clock Source..............................909 38.4.2 Prescaler...............................910 38.4.3 Counter.................................910 38.4.4 Input Capture Mode.............................915 38.4.5 Output Compare Mode..........................918 38.4.6 Edge-Aligned PWM (EPWM) Mode......................919 38.4.7 Center-Aligned PWM (CPWM) Mode......................921 38.4.8 Combine Mode.............................922 38.4.9 Complementary Mode..........................930 38.4.10...
  • Page 34 Section Number Title Page 38.4.28 Global Time Base (GTB)..........................981 38.5 Reset Overview................................982 38.6 FTM Interrupts................................984 38.6.1 Timer Overflow Interrupt..........................984 38.6.2 Channel (n) Interrupt............................984 38.6.3 Fault Interrupt..............................984 Chapter 39 Periodic Interrupt Timer (PIT) 39.1 Introduction...................................987 39.1.1 Block Diagram.............................987 39.1.2 Features................................988 39.2 Signal Description.................................988 39.3 Memory Map/Register Description..........................989...
  • Page 35 Section Number Title Page 40.3 Memory map and register definition..........................999 40.3.1 Low Power Timer Control Status Register (LPTMRx_CSR)..............1000 40.3.2 Low Power Timer Prescale Register (LPTMRx_PSR)................1001 40.3.3 Low Power Timer Compare Register (LPTMRx_CMR)................1003 40.3.4 Low Power Timer Counter Register (LPTMRx_CNR)................1003 40.4 Functional description..............................1004 40.4.1 LPTMR power and reset..........................1004...
  • Page 36 Section Number Title Page 41.6.6 CMT Modulator Status and Control Register (CMT_MSC)...............1018 41.6.7 CMT Modulator Data Register Mark High (CMT_CMD1)................1019 41.6.8 CMT Modulator Data Register Mark Low (CMT_CMD2).................1020 41.6.9 CMT Modulator Data Register Space High (CMT_CMD3)...............1020 41.6.10 CMT Modulator Data Register Space Low (CMT_CMD4)................1021 41.6.11 CMT Primary Prescaler Register (CMT_PPS)....................1021 41.6.12...
  • Page 37 Section Number Title Page 42.2.10 RTC Read Access Register (RTC_RAR)....................1044 42.3 Functional description..............................1045 42.3.1 Power, clocking and reset..........................1045 42.3.2 Time counter..............................1046 42.3.3 Compensation...............................1047 42.3.4 Time alarm..............................1048 42.3.5 Update mode..............................1048 42.3.6 Register lock..............................1048 42.3.7 Access control..............................1049 42.3.8 Interrupt................................1049 Chapter 43 Universal Serial Bus OTG Controller (USBOTG) 43.1 Introduction...................................1051 43.1.1...
  • Page 38 Section Number Title Page 43.4.5 OTG Interrupt Status Register (USBx_OTGISTAT)...................1065 43.4.6 OTG Interrupt Control Register (USBx_OTGICR)..................1066 43.4.7 OTG Status Register (USBx_OTGSTAT)....................1067 43.4.8 OTG Control Register (USBx_OTGCTL)....................1068 43.4.9 Interrupt Status Register (USBx_ISTAT)....................1069 43.4.10 Interrupt Enable Register (USBx_INTEN)....................1070 43.4.11 Error Interrupt Status Register (USBx_ERRSTAT)..................1071 43.4.12 Error Interrupt Enable Register (USBx_ERREN)..................1072 43.4.13...
  • Page 39 Section Number Title Page Chapter 44 USB Device Charger Detection Module (USBDCD) 44.1 Preface...................................1093 44.1.1 References..............................1093 44.1.2 Acronyms and Abbreviations........................1093 44.1.3 Glossary...............................1094 44.2 Introduction...................................1094 44.2.1 Block Diagram.............................1094 44.2.2 Features................................1095 44.2.3 Modes of Operation.............................1095 44.3 Module Signal Description............................1096 44.3.1 USB Signal Descriptions..........................1096 44.4 Memory Map/Register Definition..........................1097 44.4.1...
  • Page 40 Section Number Title Page Chapter 45 USB Voltage Regulator 45.1 Introduction...................................1119 45.1.1 Overview..............................1119 45.1.2 Features................................1120 45.1.3 Modes of Operation.............................1121 45.2 USB Voltage Regulator Module Signal Descriptions....................1121 Chapter 46 SPI (DSPI) 46.1 Introduction...................................1123 46.1.1 Block Diagram.............................1123 46.1.2 Features................................1124 46.1.3 DSPI Configurations............................1125 46.1.4 Modes of Operation.............................1126 46.2...
  • Page 41 Section Number Title Page 46.3.7 DSPI PUSH TX FIFO Register In Master Mode (SPIx_PUSHR)...............1147 46.3.8 DSPI PUSH TX FIFO Register In Slave Mode (SPIx_PUSHR_SLAVE)..........1149 46.3.9 DSPI POP RX FIFO Register (SPIx_POPR)....................1149 46.3.10 DSPI Transmit FIFO Registers (SPIx_TXFRn)...................1150 46.3.11 DSPI Receive FIFO Registers (SPIx_RXFRn)....................1150 46.4 Functional Description..............................1151 46.4.1...
  • Page 42 Section Number Title Page 47.3.2 I2C Frequency Divider register (I2Cx_F)....................1181 47.3.3 I2C Control Register 1 (I2Cx_C1).......................1182 47.3.4 I2C Status Register (I2Cx_S)........................1184 47.3.5 I2C Data I/O register (I2Cx_D)........................1186 47.3.6 I2C Control Register 2 (I2Cx_C2).......................1187 47.3.7 I2C Programmable Input Glitch Filter register (I2Cx_FLT)...............1188 47.3.8 I2C Range Address register (I2Cx_RA)......................1188 47.3.9...
  • Page 43 Section Number Title Page 48.3 Memory map and registers............................1213 48.3.1 UART Baud Rate Registers:High (UARTx_BDH)..................1223 48.3.2 UART Baud Rate Registers: Low (UARTx_BDL)..................1224 48.3.3 UART Control Register 1 (UARTx_C1).....................1225 48.3.4 UART Control Register 2 (UARTx_C2).....................1227 48.3.5 UART Status Register 1 (UARTx_S1)......................1229 48.3.6 UART Status Register 2 (UARTx_S2)......................1232 48.3.7...
  • Page 44 Section Number Title Page 48.3.29 UART 7816 Wait FD Register (UARTx_WF7816)..................1257 48.3.30 UART 7816 Error Threshold Register (UARTx_ET7816)................1258 48.3.31 UART 7816 Transmit Length Register (UARTx_TL7816)................1259 48.4 Functional description..............................1259 48.4.1 Transmitter..............................1259 48.4.2 Receiver...............................1265 48.4.3 Baud rate generation............................1279 48.4.4 Data format (non ISO-7816)........................1281 48.4.5 Single-wire operation...........................1284 48.4.6...
  • Page 45 Section Number Title Page Chapter 49 Secured digital host controller (SDHC) 49.1 Introduction...................................1303 49.2 Overview..................................1303 49.2.1 Supported types of cards..........................1303 49.2.2 SDHC block diagram...........................1304 49.2.3 Features................................1305 49.2.4 Modes and operations..........................1306 49.3 SDHC signal descriptions.............................1307 49.4 Memory map and register definition..........................1308 49.4.1 DMA System Address Register (SDHC_DSADDR)..................1309 49.4.2...
  • Page 46 Section Number Title Page 49.4.20 ADMA Error Status Register (SDHC_ADMAES)..................1350 49.4.21 ADMA System Address Register (SDHC_ADSADDR)................1352 49.4.22 Vendor Specific Register (SDHC_VENDOR)....................1352 49.4.23 MMC Boot Register (SDHC_MMCBOOT)....................1354 49.4.24 Host Controller Version (SDHC_HOSTVER)....................1355 49.5 Functional description..............................1356 49.5.1 Data buffer..............................1356 49.5.2 DMA crossbar switch interface........................1362 49.5.3 SD protocol unit............................1368 49.5.4...
  • Page 47 Section Number Title Page 49.7.6 Data port access............................1409 49.7.7 Change clock frequency..........................1409 49.7.8 Multi-block read............................1409 Chapter 50 Integrated interchip sound (I2S) 50.1 Introduction...................................1411 50.1.1 Block diagram..............................1411 50.1.2 Features................................1412 50.1.3 Modes of operation............................1413 50.2 I2S signal descriptions..............................1415 50.3 Memory map/register definition...........................1419 50.3.1 S Transmit Data Registers 0 (I2Sx_TX0)....................1421 50.3.2...
  • Page 48 Section Number Title Page 50.3.19 S AC97 Channel Status Register (I2Sx_ACCST)..................1452 50.3.20 S AC97 Channel Enable Register (I2Sx_ACCEN)...................1452 50.3.21 S AC97 Channel Disable Register (I2Sx_ACCDIS).................1453 50.4 Functional description..............................1453 50.4.1 Detailed operating mode descriptions......................1453 50.4.2 I2S clocking..............................1469 50.4.3 External frame and clock operation......................1474 50.4.4 Receive interrupt enable bit description.......................1476 50.4.5...
  • Page 49 Section Number Title Page Chapter 52 Touch sense input (TSI) 52.1 Introduction...................................1493 52.2 Features..................................1493 52.3 Overview..................................1494 52.3.1 Electrode capacitance measurement unit.....................1494 52.3.2 Electrode scan unit............................1495 52.3.3 Touch detection unit.............................1496 52.4 Modes of operation...............................1496 52.4.1 TSI disabled mode............................1496 52.4.2 TSI active mode............................1496 52.4.3 TSI low power mode............................1497 52.4.4...
  • Page 50 Section Number Title Page Chapter 53 LCD Controller (SLCD) 53.1 Introduction ..................................1523 53.1.1 Features................................1523 53.1.2 Modes of operation............................1524 53.1.3 Block diagram..............................1525 53.2 LCD Signal Descriptions..............................1526 53.2.1 LCD_P[63:0]..............................1527 53.2.2 VLL1, VLL2, VLL3............................1527 53.2.3 Vcap1, Vcap2...............................1527 53.3 Memory map and register definition..........................1527 53.3.1 LCD general control register (LCD_GCR)....................1529 53.3.2...
  • Page 51 Section Number Title Page 53.3.19 LCD waveform register (LCD_WF51TO48)....................1547 53.3.20 LCD waveform register (LCD_WF55TO52)....................1547 53.3.21 LCD waveform register (LCD_WF59TO56)....................1548 53.3.22 LCD waveform register (LCD_WF63TO60)....................1549 53.4 Functional description..............................1549 53.4.1 LCD controller driver description........................1550 53.4.2 WFyTOx registers............................1559 53.4.3 LCD display modes............................1560 53.4.4 LCD charge pump and power supply operation..................1562 53.4.5 Resets................................1567...
  • Page 52 Section Number Title Page 54.3 Register description..............................1593 54.3.1 Instruction register............................1593 54.3.2 Bypass register.............................1593 54.3.3 Device identification register........................1593 54.3.4 Boundary scan register..........................1594 54.4 Functional description..............................1595 54.4.1 JTAGC reset configuration..........................1595 54.4.2 IEEE 1149.1-2001 (JTAG) Test Access Port....................1595 54.4.3 TAP controller state machine........................1595 54.4.4 JTAGC block instructions..........................1597 54.4.5...
  • Page 53: About This Document

    Chapter 1 About This Document Overview 1.1.1 Purpose This document describes the features, architecture, and programming model of the Freescale K51 microcontroller. 1.1.2 Audience This document is primarily for system architects and software application developers who are using or considering using the K51 microcontroller in a system. Conventions 1.2.1 Numbering systems The following suffixes identify different numbering systems:...
  • Page 54: Typographic Notation

    Conventions 1.2.2 Typographic notation The following typographic notation is used throughout this document: Example Description placeholder, x Items in italics are placeholders for information that you provide. Italicized text is also used for the titles of publications and for emphasis. Plain lowercase letters are also used as placeholders for single letters and numbers.
  • Page 55: Introduction

    Chapter 2 Introduction 2.1 Overview This chapter provides an overview of the Kinetis portfolio and K50 family of products. It also presents high-level descriptions of the modules available on the devices covered by this document. 2.2 K50 Family Introduction The K50 MCU family includes a flexible, low-power segment LCD controller with support for up to 320 segments, analog front end capability, and full-speed USB 2.0 On- The-Go with device charger detect capability.
  • Page 56 Module Functional Categories Table 2-1. Module functional categories (continued) Module category Description System • System integration module • Power management and mode controllers • Multiple power modes available based on run, wait, stop, and power- down modes • Low-leakage wakeup unit •...
  • Page 57: Arm Cortex-M4 Core Modules

    Chapter 2 Introduction 2.3.1 ARM Cortex-M4 Core Modules The following core modules are available on this device. Table 2-2. Core modules Module Description ARM Cortex-M4 The ARM Cortex-M4 is the newest member of the Cortex M Series of processors targeting microcontroller cores focused on very cost sensitive, deterministic, interrupt driven environments.
  • Page 58: Memories And Memory Interfaces

    Module Functional Categories Table 2-3. System modules (continued) Module Description Power management controller (PMC) The PMC provides the user with multiple power options. Ten different modes are supported that allow the user to optimize power consumption for the level of functionality needed.
  • Page 59: Clocks

    Chapter 2 Introduction Table 2-4. Memories and memory interfaces (continued) Module Description SRAM Internal system RAM. Partial SRAM kept powered in VLLS2 low leakage mode. SRAM controller Manages simultaneous accesses to system RAM by multiple master peripherals and core. System register file 32-byte register file that is accessible during all power modes and is powered by VDD.
  • Page 60: Analog Modules

    Module Functional Categories 2.3.6 Analog modules The following analog modules are available on this device: Table 2-7. Analog modules Module Description 16-bit analog-to-digital converters (ADC) 16-bit successive-approximation ADC designed with integrated programmable and programmable-gain amplifiers gain amplifiers (PGA) (PGA) Analog comparators Compares two analog input voltages across the full range of the supply voltage.
  • Page 61: Communication Interfaces

    Chapter 2 Introduction Table 2-8. Timer modules (continued) Module Description Flexible timer modules (FTM) • Selectable FTM source clock, programmable prescaler • 16-bit counter supporting free-running or initial/final value, and counting is up or up-down • Input capture, output compare, and edge-aligned and center-aligned PWM modes •...
  • Page 62: Human-Machine Interfaces

    Orderable part numbers Table 2-9. Communication modules Module Description USB OTG (low-/full-speed) USB 2.0 compliant module with support for host, device, and On-The-Go modes. Includes an on-chip transceiver for full and low speeds. USB Device Charger Detect (USBDCD) The USBDCD monitors the USB data lines to detect a smart charger meeting the USB Battery Charging Specification Rev1.1.
  • Page 63 Chapter 2 Introduction Table 2-11. Orderable part numbers summary Freescale part number Package Total Program EEPROM SRAM GPIO count flash flash frequenc memory MK51DX256ZCMC10 100 MHz MAPBGA 512 KB 256 KB 4 KB 64 KB MK51DN512ZCMC10 100 MHz MAPBGA 512 KB 512 KB —...
  • Page 64 Orderable part numbers K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 65: Chip Configuration

    Chapter 3 Chip Configuration 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 •...
  • Page 66 Core modules Debug Interrupts SRAM Upper ARM Cortex-M4 Crossbar switch Core SRAM Lower Figure 3-1. Core configuration Table 3-1. Reference links to related information Topic Related module Reference Full description ARM Cortex-M4 core, http://www.arm.com r0p0 System memory map System memory map Clocking Clock distribution Power management...
  • Page 67 Chapter 3 Chip Configuration Bus name Description Instruction code (ICODE) bus The ICODE and DCODE buses are muxed. This muxed bus is called the CODE bus and is connected to the crossbar switch via a single master port. In addition, the CODE bus is also Data code (DCODE) bus tightly coupled to the lower half of the system RAM (SRAM_L).
  • Page 68: Nested Vectored Interrupt Controller (Nvic) Configuration

    Core modules 3.2.2 Nested Vectored Interrupt Controller (NVIC) Configuration This section summarizes how the module has been configured in the chip. Full documentation for this module is provided by ARM and can be found at http:// www.arm.com. Interrupts Module Nested Vectored Module Interrupt Controller (NVIC)
  • Page 69 Chapter 3 Chip Configuration 3.2.2.3 Interrupt channel assignments The interrupt source assignments are defined in the following table. • Vector number — the value stored on the stack when an interrupt is serviced. • IRQ number — non-core interrupt source count, which is the vector number minus The IRQ number is used within ARM's NVIC documentation.
  • Page 70 Core modules Table 3-4. Interrupt vector assignments (continued) Address Vector NVIC NVIC Source module Source description non-IPR register register number number 0x0000_0054 DMA channel 5 transfer complete 0x0000_0058 DMA channel 6 transfer complete 0x0000_005C DMA channel 7 transfer complete 0x0000_0060 DMA channel 8 transfer complete 0x0000_0064 DMA channel 9 transfer complete...
  • Page 71 Chapter 3 Chip Configuration Table 3-4. Interrupt vector assignments (continued) Address Vector NVIC NVIC Source module Source description non-IPR register register number number 0x0000_00C4 — — 0x0000_00C8 — — 0x0000_00CC — — 0x0000_00D0 — — 0x0000_00D4 — — 0x0000_00D8 — —...
  • Page 72 Core modules Table 3-4. Interrupt vector assignments (continued) Address Vector NVIC NVIC Source module Source description non-IPR register register number number 0x0000_0128 ADC1 — 0x0000_012C CMP0 — 0x0000_0130 CMP1 — 0x0000_0134 CMP2 — 0x0000_0138 FTM0 Single interrupt vector for all sources 0x0000_013C FTM1 Single interrupt vector for all sources...
  • Page 73 Chapter 3 Chip Configuration Table 3-4. Interrupt vector assignments (continued) Address Vector NVIC NVIC Source module Source description non-IPR register register number number 0x0000_01A0 Port control Pin detect (Port B) module 0x0000_01A4 Port control Pin detect (Port C) module 0x0000_01A8 Port control Pin detect (Port D) module...
  • Page 74: Asynchronous Wake-Up Interrupt Controller (Awic) Configuration

    Core modules • 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...
  • Page 75: Jtag Controller Configuration

    Chapter 3 Chip Configuration Table 3-6. Reference links to related information (continued) Topic Related module Reference Power management Power management Nested Vectored NVIC Interrupt Controller (NVIC) Wake-up requests AWIC wake-up sources 3.2.3.1 Wake-up sources The device uses the following internal and external inputs to the AWIC module. Table 3-7.
  • Page 76: System Modules

    System modules JTAG controller Figure 3-4. JTAGC Controller configuration Table 3-8. Reference links to related information Topic Related module Reference Full description JTAGC JTAGC Signal multiplexing Port control Signal multiplexing System modules 3.3.1 SIM Configuration This section summarizes how the module has been configured in the chip. For a comprehensive description of the module itself, see the module’s dedicated chapter.
  • Page 77: Mode Controller Configuration

    Chapter 3 Chip Configuration 3.3.2 Mode Controller Configuration This section summarizes how the module has been configured in the chip. For a comprehensive description of the module itself, see the module’s dedicated chapter. Peripheral bridge Register access Resets Mode controller Figure 3-6.
  • Page 78: Low-Leakage Wake-Up Unit (Llwu) Configuration

    System modules Peripheral bridge Register access Power management controller (PMC) Figure 3-7. PMC configuration Table 3-11. Reference links to related information Topic Related module Reference Full description System memory map System memory map Power management Power management Full description Mode Controller Mode Controller Low-Leakage Wakeup LLWU...
  • Page 79 Chapter 3 Chip Configuration Table 3-12. Reference links to related information (continued) Topic Related module Reference Clocking Clock distribution Power management Power management chapter Power Management Power Management Controller (PMC) Controller (PMC) Mode Controller Mode Controller Wake-up requests LLWU wake-up sources 3.3.4.1 Wake-up Sources This chip uses the following internal peripheral and external pin inputs as wakeup sources to the LLWU module:...
  • Page 80: Mcm Configuration

    System modules up the MCU from any non-VLLSx mode with the NMI function selected in its port control register asserts an NMI exception on low power mode recovery. The same occurs when recovering from VLLSx modes if EzPort is disabled; otherwise, EzPort mode is entered.
  • Page 81 Chapter 3 Chip Configuration Master Modules Slave Modules Crossbar Switch ARM core code bus Flash controller ARM core system bus SRAM backdoor EzPort Peripheral bridge 0 Peripheral bridge 1 GPIO controller FlexBus SDHC Figure 3-10. Crossbar switch integration Table 3-15. Reference links to related information Topic Related module Reference...
  • Page 82: Memory Protection Unit (Mpu) Configuration

    System modules Table 3-15. Reference links to related information (continued) Topic Related module Reference Crossbar switch slave GPIO controller GPIO controller 3.3.6.1 Crossbar Switch Master Assignments The masters connected to the crossbar switch are assigned as follows: Master module Master port number ARM core code bus ARM core system bus DMA/EzPort...
  • Page 83 Chapter 3 Chip Configuration Peripheral bridge 0 Register access Transfers Transfers Logical Slave Master Logical Memory Protection Slave Master Unit (MPU) Logical Slave Master Figure 3-11. Memory Protection Unit configuration Table 3-16. Reference links to related information Topic Related module Reference Full description Memory Protection Unit...
  • Page 84 System modules 3.3.7.2 MPU Logical Bus Master Assignments The logical bus master assignments for the MPU are: Table 3-18. MPU Logical Bus Master Assignments MPU Logical Bus Master Number Bus Master Core Debugger none SDHC none none 3.3.7.3 MPU Access Violation Indications Access violations detected by the MPU are signaled to the appropriate bus master as shown below: Table 3-19.
  • Page 85: Peripheral Bridge Configuration

    Chapter 3 Chip Configuration Table 3-20. Reset Values for RGD0 Registers Register Reset value RGD0_WORD0 0000_0000h RGD0_WORD1 FFFF_FFFFh RGD0_WORD2 0061_F7DFh RGD0_WORD3 0000_0001h RGDAAC0 0061_F7DFh 3.3.7.5 Write Access Restrictions for RGD0 Registers In addition to configuring the initial state of RGD0, the MPU implements further access control on writes to the RGD0 registers.
  • Page 86 System modules Transfers Transfers AIPS-Lite peripheral bridge Figure 3-12. Peripheral bridge configuration Table 3-22. Reference links to related information Topic Related module Reference Full description Peripheral bridge Peripheral bridge (AIPS-Lite) (AIPS-Lite) System memory map System memory map Clocking Clock Distribution Crossbar switch Crossbar switch Crossbar switch...
  • Page 87: Dma Request Multiplexer Configuration

    Chapter 3 Chip Configuration 3.3.8.5 PACR registers Each of the two peripheral bridges support up to 128 peripherals each assigned to an PACRx field within the PACRA-PACRP registers. However, fewer peripherals are supported on this device. See AIPS0 Memory MapandAIPS1 Memory Map for details of the peripheral slot assignments for this device.
  • Page 88 System modules 3.3.9.1 DMA MUX request sources This device includes a DMA request mux that allows up to 63 DMA request signals to be mapped to any of the 16 DMA channels. Because of the mux there is not a hard correlation between any of the DMA request sources and a specific DMA channel.
  • Page 89 Chapter 3 Chip Configuration Table 3-24. DMA request sources - MUX 0 (continued) Source Source module Source description number FTM0 Channel 3 FTM0 Channel 4 FTM0 Channel 5 FTM0 Channel 6 FTM0 Channel 7 FTM1 Channel 0 FTM1 Channel 1 FTM2 Channel 0 FTM2...
  • Page 90: Dma Controller Configuration

    System modules Table 3-24. DMA request sources - MUX 0 (continued) Source Source module Source description number DMA MUX Always enabled DMA MUX Always enabled DMA MUX Always enabled 1. Configuring a DMA channel to select source 0 or any of the reserved sources disables that DMA channel. 3.3.9.2 DMA transfers via PIT trigger The PIT module can trigger a DMA transfer on the first four DMA channels.
  • Page 91: External Watchdog Monitor (Ewm) Configuration

    Chapter 3 Chip Configuration 3.3.11 External Watchdog Monitor (EWM) Configuration This section summarizes how the module has been configured in the chip. For a comprehensive description of the module itself, see the module’s dedicated chapter. Peripheral bridge 0 Register access Module signals External Watchdog Monitor (EWM)
  • Page 92: Watchdog Configuration

    System modules Table 3-28. EWM low-power modes Module mode Chip mode Wait Wait, VLPW Stop Stop, VLPS, LLS Power Down VLLS3, VLLS2, VLLS1 3.3.11.3 EWM_OUT pin state in low power modes During Wait, Stop and Power Down modes the EWM_OUT pin enters a high-impedance state.
  • Page 93: Clock Modules

    Chapter 3 Chip Configuration 3.3.12.1 WDOG clocks This table shows the WDOG module clocks and the corresponding chip clocks. Table 3-30. WDOG clock connections Module clock Chip clock LPO Oscillator 1 kHz LPO Clock Alt Clock Bus Clock Fast Test Clock Bus Clock System Bus Clock Bus Clock...
  • Page 94: Osc Configuration

    Clock Modules Peripheral bridge Register access Multipurpose Clock Generator (MCG) Figure 3-17. MCG configuration Table 3-32. Reference links to related information Topic Related module Reference Full description System memory map System memory map Clocking Clock distribution Power management Power management Signal multiplexing Port control Signal multiplexing...
  • Page 95: Rtc Osc Configuration

    Chapter 3 Chip Configuration Table 3-33. Reference links to related information (continued) Topic Related module Reference Power management Power management Signal multiplexing Port control Signal multiplexing Full description 3.4.2.1 OSC modes of operation with MCG The MCG's C2 register bits configure the oscillator frequency range. See the OSC and MCG chapters for more details.
  • Page 96 Memories and Memory Interfaces Peripheral bus controller 0 Register access Transfers Flash memory Figure 3-20. Flash memory configuration Table 3-35. Reference links to related information Topic Related module Reference Full description Flash memory Flash memory System memory map System memory map Clocking Clock Distribution Transfers...
  • Page 97 Chapter 3 Chip Configuration • For devices that contain FlexNVM: 1 block of program flash consisting of 2 KB sectors • For devices that contain FlexNVM: 1 block of FlexNVM consisting of 2 KB sectors • For devices that contain FlexNVM: 1 block of FlexRAM The amounts of flash memory for the devices covered in this document are: Device Program...
  • Page 98 Memories and Memory Interfaces Flash memory base address Registers Program flash base address Flash configuration field Program flash Programming acceleration RAM base address Figure 3-21. Flash memory map for devices containing only program flash Flash memory base address Registers Program flash base address Flash configuration field Program flash FlexNVM base address...
  • Page 99: Flash Memory Controller Configuration

    Chapter 3 Chip Configuration 3.5.1.7 Erase All Flash Contents In addition to software, the entire flash memory may be erased external to the flash memory in two ways: 1. Via the EzPort by issuing a bulk erase (BE) command. See the EzPort chapter for more details.
  • Page 100: Sram Configuration

    Memories and Memory Interfaces Table 3-36. Reference links to related information (continued) Topic Related module Reference Transfers Crossbar switch Crossbar Switch Register access Peripheral bridge Peripheral bridge 3.5.2.1 Number of masters The Flash Memory Controller supports up to eight crossbar switch masters. However, this device has a different number of crossbar switch masters.
  • Page 101 Chapter 3 Chip Configuration Cortex-M4 SRAM upper core Transfers Crossbar SRAM lower switch Figure 3-24. SRAM configuration Table 3-37. Reference links to related information Topic Related module Reference Full description SRAM SRAM System memory map System memory map Clocking Clock Distribution Transfers SRAM controller SRAM controller...
  • Page 102 Memories and Memory Interfaces • SRAM_L = [0x2000_0000–(SRAM_size/2)] to 0x1FFF_FFFF • SRAM_U = 0x2000_0000 to [0x2000_0000+(SRAM_size/2)-1] This is illustrated in the following figure. 0x2000_0000 – SRAM_size/2 SRAM_L 0x1FFF_FFFF 0x2000_0000 SRAM_U 0x2000_0000 + SRAM_size/2 - 1 Figure 3-25. SRAM blocks memory map For example, for a device containing 64 KB of SRAM the ranges are: •...
  • Page 103: Sram Controller Configuration

    Chapter 3 Chip Configuration The following figure illustrates the SRAM accesses within the device. SRAM_L Cortex-M4 core Crossbar switch non-core master Frontdoor Backdoor Code bus non-core master SRAM controller System bus non-core master SRAM_U Figure 3-26. SRAM access diagram The following simultaneous accesses can be made to different logical halves of the SRAM: •...
  • Page 104: System Register File Configuration

    Memories and Memory Interfaces Cortex-M4 core SRAM controller Transfers Crossbar switch Figure 3-27. SRAM controller configuration Table 3-38. Reference links to related information Topic Related module Reference System memory map System memory map Power management Power management Power management controller (PMC) Transfers SRAM SRAM...
  • Page 105: Vbat Register File Configuration

    Chapter 3 Chip Configuration 3.5.5.1 System Register file This device includes a 32-byte register file that is powered in all power modes. Also, it retains contents during low-voltage detect (LVD) events and is only reset during a power-on reset. 3.5.6 VBAT Register File Configuration This section summarizes how the module has been configured in the chip.
  • Page 106: Ezport Configuration

    Memories and Memory Interfaces 3.5.7 EzPort Configuration This section summarizes how the module has been configured in the chip. For a comprehensive description of the module itself, see the module’s dedicated chapter. Module signals Transfers EzPort Figure 3-30. EzPort configuration Table 3-41.
  • Page 107: Security

    Chapter 3 Chip Configuration Security 3.6.1 CRC Configuration This section summarizes how the module has been configured in the chip. For a comprehensive description of the module itself, see the module’s dedicated chapter. Peripheral bridge Register access Figure 3-31. CRC configuration Table 3-42.
  • Page 108 Analog Peripheral bus controller 0 Register access Module signals Transfers 16-bit SAR ADC Other peripherals Figure 3-32. 16-bit SAR ADC with PGA configuration Table 3-43. Reference links to related information Topic Related module Reference Full description 16-bit SAR ADC with 16-bit SAR ADC with PGA System memory map System memory map...
  • Page 109 Chapter 3 Chip Configuration 3.7.1.3 ADC0 Connections/Channel Assignment NOTE As indicated by the following sections, each ADCx_DPx input and certain ADCx_DMx inputs may operate as single-ended ADC channels in single-ended mode. 3.7.1.3.1 ADC0 Channel Assignment for 121-Pin Package ADC Channel Channel Input signal Input signal...
  • Page 110 Analog ADC Channel Channel Input signal Input signal (SC1n[ADCH]) (SC1n[DIFF]= 1) (SC1n[DIFF]= 0) 11001 AD25 Reserved Reserved 11010 AD26 Temperature Sensor (Diff) Temperature Sensor (S.E) 11011 AD27 Bandgap (Diff) Bandgap (S.E) 11100 AD28 Reserved Reserved 11101 AD29 -VREFH (Diff) VREFH (S.E) 11110 AD30 Reserved...
  • Page 111 Chapter 3 Chip Configuration ADC Channel Channel Input signal Input signal (SC1n[ADCH]) (SC1n[DIFF]= 1) (SC1n[DIFF]= 0) 00111 AD7b Reserved ADC1_SE7b 01000 Reserved ADC1_SE8 01001 Reserved ADC1_SE9 01010 AD10 Reserved Reserved 01011 AD11 Reserved Reserved 01100 AD12 Reserved ADC1_SE12 01101 AD13 Reserved ADC1_SE13 01110...
  • Page 112 Analog AD4 [00100] ADCx_SE4a ADCx_SE5a AD5 [00101] ADCx_SE6a ADCx_SE7a AD6 [00110] ADCx_SE4b ADCx_SE5b AD7 [00111] ADCx_SE6b ADCx_SE7b Figure 3-33. ADCx_SEn channels a and b selection 3.7.1.6 ADC Hardware Interleaved Channels The AD8 and AD9 channels on ADCx are interleaved in hardware using the following configuration.
  • Page 113 Chapter 3 Chip Configuration • VREFH/VREFL - connected as the primary reference option • 1.2 V VREF_OUT - connected as the V reference option ADCx_SC2[REFSEL] bit selects the voltage reference sources for ADC. Refer to REFSEL description in ADC chapter for more details. The only reference option for the PGA is the 1.2 V VREF_OUT source.
  • Page 114 Analog Table 3-44. ADC low-power modes Module mode Chip mode Wait Wait, VLPW Normal Stop Stop, VLPS Low Power Stop LLS, VLLS3, VLLS2, VLLS1 3.7.1.11 PGA Integration • No additional external pins are required for the PGA as it is part of the ADC and is selected as a separate channel •...
  • Page 115: Cmp Configuration

    Chapter 3 Chip Configuration ADC0 ADC0_DP1 DAD1 ADC0_DM1 DAD0 PGA0_DP/ADC0_DP0/ADC1_DP3 PGA0 DAD2 PGA0_DM/ADC0_DM0/ADC1_DM3 DAD3 ADC1 DAD3 PGA1_DP/ADC1_DP0/ADC0_DP3 PGA1 DAD2 PGA1_DM/ADC1_DM0/ADC0_DM3 DAD0 ADC1_DP1 DAD1 ADC1_DM1 Figure 3-35. PGA Integration 3.7.2 CMP Configuration This section summarizes how the module has been configured in the chip. For a comprehensive description of the module itself, see the module’s dedicated chapter.
  • Page 116 Analog Peripheral bridge 0 Register access Module signals Other peripherals Figure 3-36. CMP configuration Table 3-45. Reference links to related information Topic Related module Reference Full description Comparator (CMP) Comparator System memory map System memory map Clocking Clock distribution Power management Power management Signal multiplexing Port control...
  • Page 117: 12-Bit Dac Configuration

    Chapter 3 Chip Configuration 3.7.2.3 External window/sample input PDB pulse-out controls the CMP Sample/Window timing. 3.7.3 12-bit DAC Configuration This section summarizes how the module has been configured in the chip. For a comprehensive description of the module itself, see the module’s dedicated chapter. Peripheral bus controller 0 Register...
  • Page 118: Op-Amp Configuration

    Analog 3.7.3.3 12-bit DAC Reference For this device VREF_OUT and VDDA are selectable as the DAC reference. VREF_OUT is connected to the DACREF_1 input and VDDA is connected to the DACREF_2 input. Use DACx_C0[DACRFS] control bit to select between these two options.
  • Page 119 Chapter 3 Chip Configuration 3.7.4.2 Op-amp 0 input mux connections The op-amp 0 module contains multiplexers for selecting the positive and negative inputs. The inputs to these muxes are defined as follows: Op-amp 0 minus input number Signal connection OP0_DM0 input signal (default) Reserved Op-amp 1 output CMP0 6-bit DAC output...
  • Page 120: Triamp Configuration

    Analog Op-amp 1 positive input number Signal connection OP1_DP0 input signal Op-amp 0 output Op-amp 1 output CMP0 6-bit DAC output 12-bit DAC0 output 12-bit DAC1 Output Ground 3.7.4.4 Op-amp output connections The op-amp module output is optionally available as follows: Op-amp number Op-amp output signal connection CMP1 input...
  • Page 121: Vref Configuration

    Chapter 3 Chip Configuration Peripheral bridge Register access Module signals TRIAMP Figure 3-39. TRIAMP configuration Table 3-48. Reference links to related information Topic Related module Reference Full description TRIAMP TRIAMP System memory map System memory map Clocking Clock distribution Power management Power management Signal multiplexing Port control...
  • Page 122: Timers

    Timers Peripheral bus controller 0 Register access Module signals Transfers VREF Other peripherals Figure 3-40. VREF configuration Table 3-49. Reference links to related information Topic Related module Reference Full description VREF VREF System memory map System memory map Clocking Clock distribution Power management Power management Signal multiplexing...
  • Page 123 Chapter 3 Chip Configuration Peripheral bus controller 0 Register access Module signals Transfers Other peripherals Figure 3-41. PDB configuration Table 3-50. Reference links to related information Topic Related module Reference Full description System memory map System memory map Clocking Clock distribution Power management Power management Signal multiplexing...
  • Page 124 Timers Table 3-52. PDB Input Trigger Options (continued) PDB Trigger PDB Input 0101 PIT Ch 1 Output 0110 PIT Ch 2 Output 0111 PIT Ch 3 Output 1000 FTM0 Init and Ext Trigger Outputs 1001 FTM1 Init and Ext Trigger Outputs 1010 FTM2 Init and Ext Trigger Outputs 1011...
  • Page 125 Chapter 3 Chip Configuration Channel 0 pre-trigger 0 Channel 1 Channel 0 pre-trigger 1 pre-trigger 1 Channel 1 pre-trigger 0 Figure 3-42. PDB back-to-back chain The application code can set the PDBx_CHnC1[BB] bits to configure the PDB pre- triggers as a single chain or several chains. 3.8.1.4 PDB Interval Trigger Connections to DAC In this MCU, PDB interval trigger connections to DAC are implemented as follows.
  • Page 126: Flextimer Configuration

    Timers 3.8.1.7 Pulse-Out Enable Register Implementation The following table shows the comparison of pulse-out enable register at the module and chip level. Table 3-53. PDB pulse-out enable register Register Module implementation Chip implementation POnEN 7:0 - POEN 0 - POEN 31:8 - Reserved 31:1 - Reserved 3.8.2 FlexTimer Configuration...
  • Page 127 Chapter 3 Chip Configuration Table 3-55. FTM Instantiations FTM instance Number of channels Features/usage FTM0 3-phase motor + 2 general purpose or stepper motor FTM1 Quadrature decoder or general purpose FTM2 Quadrature decoder or general purpose Compared with the FTM0 configuration, the FTM1 and FTM2 configuration adds the Quadrature decoder feature and reduces the number of channels.
  • Page 128 Timers • FTM1 FAULT1 = CMP1 output • FTM1 FAULT2 = CMP2 output • FTM2 FAULT0 = FTM2_FLT0 pin or CMP0 output • FTM2 FAULT1 = CMP1 output • FTM2 FAULT2 = CMP2 output 3.8.2.6 FTM Hardware Triggers The FTM synchronization hardware triggers are connected in the chip as follows: •...
  • Page 129: Pit Configuration

    Chapter 3 Chip Configuration 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...
  • Page 130: Low-Power Timer Configuration

    Timers Table 3-56. Reference links to related information (continued) Topic Related module Reference System memory map System memory map Clocking Clock Distribution Power management Power management 3.8.3.1 PIT/DMA Periodic Trigger Assignments The PIT generates periodic trigger events to the DMA Mux as shown in the table below. Table 3-57.
  • Page 131 Chapter 3 Chip Configuration Peripheral bridge Register access Module signals Low-power timer Figure 3-46. LPT configuration Table 3-58. Reference links to related information Topic Related module Reference Full description Low-power timer Low-power timer System memory map System memory map Clocking Clock Distribution Power management Power management...
  • Page 132: Cmt Configuration

    Timers 3.8.4.2 LPTMR pulse counter input options The LPTMR_CSR[TPS] bitfield configures the input source used in pulse counter mode. The following table shows the chip-specific input assignments for this bitfield. LPTMR_CSR[TPS] Pulse counter input number Chip input CMP0 output LPTMR_ALT1 pin LPTMR_ALT2 pin Reserved 3.8.5 CMT Configuration...
  • Page 133: Rtc Configuration

    Chapter 3 Chip Configuration 3.8.5.2 IRO Drive Strength The IRO pad requires higher current drive than can be obtained from a single pad. For this device, the pin associated with the CMT_IRO signal is doubled bonded to two pads. The SOPT2[CMTUARTPAD] field in SIM module can be used to configure the pin associated with the CMT_IRO signal as a higher current output port pin.
  • Page 134: Communication Interfaces

    Communication interfaces 3.8.6.3 RTC seconds interrupt The RTC seconds interrupt is not supported on this device. Communication interfaces 3.9.1 Universal Serial Bus (USB) Subsystem The USB subsystem includes these components: • Dual-role USB OTG-capable (On-The-Go) controller that supports a full-speed (FS) device or FS/LS host.
  • Page 135 Chapter 3 Chip Configuration 3.9.1.2 USB Power Distribution This chip includes an internal 5 V to 3.3 V USB regulator that powers the USB transceiver or the MCU (depending on the application). 3.9.1.2.1 AA/AAA cells power supply The chip can be powered by two AA/AAA cells. In this case, the MCU is powered through VDD which is within the 1.8 to 3.0 V range.
  • Page 136 Communication interfaces To PMC and Pads VOUT33 stab Chip TYPE A VREGIN VBUS Si2301 Charger Regulator USB0_DP Controller XCVR USB0_DM Li-Ion VBUS Sense Charger Detect Figure 3-51. USB regulator Li-ion usecase 3.9.1.2.3 USB bus power supply The chip can also be powered by the USB bus directly. In this case, VOUT33 is connected to VDD.
  • Page 137 Chapter 3 Chip Configuration 3.9.1.3 USB power management The regulator should be put into STANDBY mode whenever the chip is in Stop mode. This can be done by setting the SIM_SOPT1[USBSTBY] bit. 3.9.1.4 USB controller configuration This section summarizes how the module has been configured in the chip. For a comprehensive description of the module itself, see the module’s dedicated chapter.
  • Page 138 Communication interfaces Peripheral bridge 0 Register access USB Device Charger Detect Figure 3-54. USB DCD configuration Table 3-62. Reference links to related information Topic Related module Reference Full description USB DCD USB DCD System memory map System memory map Clocking Clock Distribution USB controller USB controller...
  • Page 139: Spi Configuration

    Chapter 3 Chip Configuration NOTE When USB is not used in the application, it is recommended that the USB regulator VREGIN and VOUT33 pins remain floating. 3.9.2 SPI configuration This section summarizes how the module has been configured in the chip. For a comprehensive description of the module itself, see the module’s dedicated chapter.
  • Page 140 Communication interfaces 3.9.2.3 Number of CTARs SPI CTAR registers define different transfer attribute configurations. The SPI module supports up to eight CTAR registers. This device supports two CTARs on all instances of the SPI. In master mode, the CTAR registers define combinations of transfer attributes, such as frame size, clock phase, clock polarity, data bit ordering, baud rate, and various delays.
  • Page 141 Chapter 3 Chip Configuration Table 3-67. SPI PCS signals (continued) SPI Module PCS Signals SPI2 SPI_PCS[1:0] 3.9.2.7 SPI Operation in Low Power Modes In VLPR and VLPW modes the SPI is functional; however, the reduced system frequency also reduces the max frequency of operation for the SPI. In VLPR and VLPW modes the max SPI_CLK frequency is 1MHz.
  • Page 142: I2C Configuration

    Communication interfaces 3.9.2.9 SPI Interrupts The SPI has multiple sources of interrupt requests. However, these sources are OR'd together to generate a single interrupt request per SPI module to the interrupt controller. When an SPI interrupt occurs, read the SPI_SR to determine the exact interrupt source. 3.9.2.10 SPI clocks This table shows the SPI module clocks and the corresponding chip clocks.
  • Page 143: Uart Configuration

    Chapter 3 Chip Configuration 3.9.3.1 Number of I2C modules This device has two I C modules. 3.9.4 UART Configuration This section summarizes how the module has been configured in the chip. For a comprehensive description of the module itself, see the module’s dedicated chapter. Peripheral bridge Register...
  • Page 144 Communication interfaces 3. IrDA is available on all UARTs 4. UART0 contains the standard features plus ISO7816 5. AMR support on all UARTs. The pin control and interrupts (PORT) module supports open-drain for all I/O. 6. UART0 and UART1 contains 8-entry transmit and 8-entry receive FIFOs 7.
  • Page 145: Sdhc Configuration

    Chapter 3 Chip Configuration Source UART 0 UART 1 UART 2 UART 3 UART 4 UART 5 Parity error Transmitter buffer overflow Receiver buffer underflow Transmit — — — — — threshold (ISO7816) Receiver — — — — — threshold (ISO7816) Wait timer —...
  • Page 146: I2S Configuration

    Communication interfaces Table 3-71. Reference links to related information (continued) Topic Related module Reference Transfers Crossbar switch Crossbar switch Signal Multiplexing Port control Signal Multiplexing 3.9.5.1 SDHC clocking In addition to the system clock, the SDHC needs a clock for the base for the external card clock.
  • Page 147 Chapter 3 Chip Configuration Peripheral bridge Register access Module signals Figure 3-60. I S configuration Table 3-72. Reference links to related information Topic Related module Reference Full description System memory map System memory map Clocking Clock Distribution Power management Power management Signal multiplexing Port control Signal Multiplexing...
  • Page 148: Human-Machine Interfaces (Hmi)

    Human-machine interfaces (HMI) 3.9.6.3 I S clock generation To generate the desired frequencies for the I S module there are multiple clocking options as shown below: • The core/system clock is routed to an 8-bit fractional divider to generate the I clock.
  • Page 149: Tsi Configuration

    Chapter 3 Chip Configuration Peripheral bridge Register access Transfers Module signals GPIO controller Figure 3-61. GPIO configuration Table 3-73. Reference links to related information Topic Related module Reference Full description GPIO GPIO System memory map System memory map Clocking Clock Distribution Power management Power management Transfers...
  • Page 150 Human-machine interfaces (HMI) Peripheral bridge Register access Module signals Touch sense input module Figure 3-62. TSI configuration Table 3-74. Reference links to related information Topic Related module Reference Full description System memory map System memory map Clocking Clock Distribution Power management Power management Signal Multiplexing Port control...
  • Page 151 Chapter 3 Chip Configuration Table 3-75. TSI module functionality in MCU operation modes (continued) MCU operation mode TSI clock sources TSI operation mode Functional electrode Required when GENCS[TSIEN] pins GENCS[STPE] state is 1 VLPS OSCERCLK Active mode LPOCLK, Low power mode Determined by VLPOSCCLK PEN[LPSP]...
  • Page 152: Segment Lcd Configuration

    Human-machine interfaces (HMI) 3.10.3 Segment LCD Configuration This section summarizes how the module has been configured in the chip. For a comprehensive description of the module itself, see the module’s dedicated chapter. Peripheral bus controller 0 Register access Module signals Segment LCD Figure 3-63.
  • Page 153 Chapter 3 Chip Configuration See the Signal Multiplexing and Signal Descriptions chapter for the number of LCD pins used in this MCU. 3.10.3.3 LCD pin enable, backplane enable, and waveform registers The following table shows the comparison of LCD pin enable, backplane enable, and waveform registers at the module and chip level.
  • Page 154 Human-machine interfaces (HMI) K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 155: Memory Map

    Chapter 4 Memory Map 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. 4.2 System memory map The following table shows the high-level device memory map. Table 4-1.
  • Page 156: Aliased Bit-Band Regions

    System memory map Table 4-1. System memory map (continued) System 32-bit Address Range Destination Slave Access 0x400F_F000–0x400F_FFFF Bitband region for general purpose input/output (GPIO) Cortex-M4 core & DMA/EzPort 0x4010_0000–0x41FF_FFFF Reserved – 0x4200_0000–0x43FF_FFFF Aliased to peripheral bridge (AIPS-Lite) and general purpose Cortex-M4 core input/output (GPIO) bitband only...
  • Page 157: Flash Memory Map

    Chapter 4 Memory Map Bit-band region Alias bit-band region 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. 4.3 Flash Memory Map The various flash memories and the flash registers are located at different base addresses as shown in the following figure.
  • Page 158: Alternate Non-Volatile Irc User Trim Description

    SRAM memory map Flash memory base address Registers Program flash base address Flash configuration field Program flash FlexNVM base address FlexNVM FlexRAM base address FlexRAM Figure 4-3. Flash memory map for devices containing FlexNVM 4.3.1 Alternate Non-Volatile IRC User Trim Description The following non-volatile locations (4 bytes) are reserved for custom IRC user trim supported by some development tools.
  • Page 159: Peripheral Bridge (Aips-Lite0 And Aips-Lite1) Memory Maps

    Chapter 4 Memory Map 4.5 Peripheral bridge (AIPS-Lite0 and AIPS-Lite1) memory maps The peripheral memory map is accessible via two slave ports on the crossbar switch in the 0x4000_0000–0x400F_FFFF region. The device implements two peripheral bridges (AIPS-Lite 0 and 1): •...
  • Page 160 Peripheral bridge (AIPS-Lite0 and AIPS-Lite1) memory maps Table 4-2. Peripheral bridge 0 slot assignments (continued) System 32-bit base address Slot Module number 0x4000_6000 — 0x4000_7000 — 0x4000_8000 DMA controller 0x4000_9000 DMA controller transfer control descriptors 0x4000_A000 — 0x4000_B000 — 0x4000_C000 —...
  • Page 161 Chapter 4 Memory Map Table 4-2. Peripheral bridge 0 slot assignments (continued) System 32-bit base address Slot Module number 0x4002_8000 — 0x4002_9000 — 0x4002_A000 — 0x4002_B000 — 0x4002_C000 SPI 0 0x4002_D000 SPI 1 0x4002_E000 — 0x4002_F000 I2S 0 0x4003_0000 — 0x4003_1000 —...
  • Page 162 Peripheral bridge (AIPS-Lite0 and AIPS-Lite1) memory maps Table 4-2. Peripheral bridge 0 slot assignments (continued) System 32-bit base address Slot Module number 0x4004_A000 Port B multiplexing control 0x4004_B000 Port C multiplexing control 0x4004_C000 Port D multiplexing control 0x4004_D000 Port E multiplexing control 0x4004_E000 —...
  • Page 163: Peripheral Bridge 1 (Aips-Lite 1) Memory Map

    Chapter 4 Memory Map Table 4-2. Peripheral bridge 0 slot assignments (continued) System 32-bit base address Slot Module number 0x4006_C000 UART 2 0x4006_D000 UART 3 0x4006_E000 — 0x4006_F000 — 0x4007_0000 — 0x4007_1000 — 0x4007_2000 USB OTG FS/LS 0x4007_3000 Analog comparator (CMP) / 6-bit digital-to-analog converter (DAC) 0x4007_4000 Voltage reference (VREF) 0x4007_5000...
  • Page 164 Peripheral bridge (AIPS-Lite0 and AIPS-Lite1) memory maps Table 4-3. Peripheral bridge 1 slot assignments (continued) System 32-bit base address Slot Module number 0x4008_8000 — 0x4008_9000 — 0x4008_A000 — 0x4008_B000 — 0x4008_C000 — 0x4008_D000 — 0x4008_E000 — 0x4008_F000 — 0x4009_0000 — 0x4009_1000 —...
  • Page 165 Chapter 4 Memory Map Table 4-3. Peripheral bridge 1 slot assignments (continued) System 32-bit base address Slot Module number 0x400A_A000 — 0x400A_B000 — 0x400A_C000 SPI 2 0x400A_D000 — 0x400A_E000 — 0x400A_F000 — 0x400B_0000 — 0x400B_1000 SDHC 0x400B_2000 — 0x400B_3000 — 0x400B_4000 —...
  • Page 166 Peripheral bridge (AIPS-Lite0 and AIPS-Lite1) memory maps Table 4-3. Peripheral bridge 1 slot assignments (continued) System 32-bit base address Slot Module number 0x400C_C000 12-bit digital-to-analog converter (DAC) 0 0x400C_D000 12-bit digital-to-analog converter (DAC) 1 0x400C_E000 — 0x400C_F000 — 0x400D_0000 — 0x400D_1000 —...
  • Page 167: Private Peripheral Bus (Ppb) Memory Map

    Chapter 4 Memory Map Table 4-3. Peripheral bridge 1 slot assignments (continued) System 32-bit base address Slot Module number 0x400E_E000 — 0x400E_F000 — 0x400F_0000 — 0x400F_1000 — 0x400F_2000 — 0x400F_3000 — 0x400F_4000 — 0x400F_5000 Subslot A: Op-amp 0 0x400F_5800 Subslot B: Op-amp 1 0x400F_6000 —...
  • Page 168 Private Peripheral Bus (PPB) memory map Table 4-4. PPB memory map (continued) System 32-bit Address Range Resource 0xE000_E000–0xE000_EFFF System Control Space (SCS) (for NVIC) 0xE000_F000–0xE003_FFFF Reserved 0xE004_0000–0xE004_0FFF Trace Port Interface Unit (TPIU) 0xE004_1000–0xE004_1FFF Embedded Trace Macrocell (ETM) 0xE004_2000–0xE004_2FFF Embedded Trace Buffer (ETB) 0xE004_3000–0xE004_3FFF Embedded Trace Funnel 0xE004_4000–0xE007_FFFF...
  • Page 169: Clock Distribution

    Chapter 5 Clock Distribution 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.
  • Page 170: Clock Definitions

    Clock definitions Multiplexers MCG_Cx MCG_Cx SIM_SOPT1, SIM_SOPT2 Dividers — MCG_Cx SIM_CLKDIVx Clock gates OSC_CR MCG_C1 SIM_SCGCx 4 MHz IRC ÷2 Clock options for MCGIRCLK some peripherals MCGFFCLK 32 kHz IRC ÷2 (see note) Core / system clocks OUTDIV1 Bus clock OUTDIV2 MCGOUTCLK Flash clock...
  • Page 171: Device Clock Summary

    Chapter 5 Clock Distribution Clock name Description Bus clock MCGOUTCLK divided by OUTDIV2 clocks the bus slaves and peripheral (excluding memories) Flash clock MCGOUTCLK divided by OUTDIV4 clocks the flash memory MCGIRCLK MCG output of the slow or fast internal reference clock MCGFFCLK MCG output of the slow internal reference clock or a divided MCG external reference clock.
  • Page 172 Clock definitions Table 5-1. Clock Summary (continued) Clock name Run mode VLPR mode Clock source Clock is disabled when… clock frequency clock frequency Internal reference 30-40 kHz or 2 MHz 2 MHz only MCG_C1[IRCLKEN] cleared, (MCGIRCLK) Stop mode and MCG_C1[IREFSTEN] cleared, or VLPS/LLS/VLLS mode External reference...
  • Page 173: Internal Clocking Requirements

    Chapter 5 Clock Distribution 5.5 Internal clocking requirements The clock dividers are programmed via the SIM module’s CLKDIV registers. Each divider is programmable from a divide-by-1 through divide-by-16 setting. The following requirements must be met when configuring the clocks for this device: 1.
  • Page 174: Clock Divider Values After Reset

    Clock Gating 5.5.1 Clock divider values after reset Each clock divider is programmed via the SIM module’s CLKDIVn registers. The flash memory's FTFL_FOPT[LPBOOT] bit controls the reset value of the core clock, system clock, bus clock, and flash clock dividers as shown below: FTFL_FOPT Core/system clock Bus clock...
  • Page 175 Chapter 5 Clock Distribution Table 5-2. Module clocks Module Bus interface clock Internal clocks I/O interface clocks Core modules ARM Cortex-M4 core System clock Core clock — NVIC System clock — — System clock — — System clock — — System clock TRACE clock TRACE_CLKOUT...
  • Page 176: Pmc 1-Khz Lpo Clock

    Module clocks Table 5-2. Module clocks (continued) Module Bus interface clock Internal clocks I/O interface clocks Op-Amp Bus clock — — TRIAMP Bus clock — — Timers Bus clock — — FlexTimers Bus clock MCGFFCLK FTM_CLKINx Bus clock — — LPTMR Bus clock LPO, OSCERCLK,...
  • Page 177: Debug Trace Clock

    Chapter 5 Clock Distribution WDOG clock Bus clock WDOG_STCTRLH[CLKSRC] Figure 5-2. WDOG clock generation 5.7.3 Debug trace clock The debug trace clock source can be clocked as shown in the following figure. MCGOUTCLK TPIU TRACECLKIN TRACE_CLKOUT ÷2 Core / system clock SIM_SOPT2[TRACECLKSEL] Figure 5-3.
  • Page 178: Lptmr Clocking

    Module clocks Bus clock PORTx digital input filter clock PORTx_DFCR[CS] Figure 5-4. PORTx digital input filter clock generation 5.7.5 LPTMR clocking The prescaler and glitch filters in each of the LPTMRx modules can be clocked as shown in the following figure. NOTE The chosen clock must remain enabled if the LPTMRx is to continue operating in all required low-power modes.
  • Page 179: Uart Clocking

    Chapter 5 Clock Distribution The USB OTG controller also requires a 48 MHz clock. The clock source options are shown below. USB_CLKIN USB 48MHz SIM_CLKDIV2 MCGPLLCLK or [USBFRAC, USBDIV] MCGFLLCLK SIM_SOPT2[USBSRC] Figure 5-6. USB 48 MHz clock source NOTE The MCGFLLCLK does not meet the USB jitter specifications for certification.
  • Page 180: I2S Clocking

    Module clocks 5.7.9 I S clocking In addition to the bus clock, the I S has a clock source for master clock generation. The maximum frequency of this clock is 50 MHz. The master clock source can be derived from several sources, as shown in the following figure. Core/system clock SIM_CLKDIV2 MCGPLLCLK or...
  • Page 181 Chapter 5 Clock Distribution TSI clock in low-power mode ERCLK32K TSI_GENCS[LPCLKS] Figure 5-10. TSI low-power clock generation K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 182 Module clocks K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 183: Reset And Boot

    Chapter 6 Reset and Boot 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) •...
  • Page 184: Power-On Reset (Por)

    Reset 6.2.1 Power-on reset (POR) When power is initially applied to the MCU or when the supply voltage drops below the power-on reset re-arm voltage level (V ), the POR circuit causes a POR reset condition. As the supply voltage rises, the LVD circuit holds the MCU in reset until the supply has risen above the LVD low threshold (V ).
  • Page 185 Chapter 6 Reset and Boot 6.2.2.1 External pin reset (PIN) On this device, RESET is a dedicated pin. This pin is open drain and has an internal pullup device. Asserting RESET wakes the device from any mode. During a pin reset, the SRSL[PIN] bit is set.
  • Page 186 Reset The LVD can be configured to generate a reset upon detection of a low voltage condition by setting LVDSC1[LVDRE]. After an LVD reset has occurred, the LVD system holds the MCU in reset until the supply voltage rises above the low voltage detection threshold. The SRSL[LVD] bit is set following an LVD reset or POR.
  • Page 187 Chapter 6 Reset and Boot The MC_SRSL[LOC] bit is set to indicate the error. 6.2.2.6 Software reset (SW) The SYSRESETREQ bit in the NVIC application interrupt and reset control register can be set to force a software reset on the device. (See ARM's NVIC documentation for the full description of the register fields, especially the VECTKEY field requirements.) Setting SYSRESETREQ generates a software reset request.
  • Page 188: Debug Resets

    Reset 6.2.3 Debug resets The following sections detail the debug resets available on the device. 6.2.3.1 JTAG reset The JTAG module generate a system reset when certain IR codes are selected. This functional reset is asserted when EzPort, EXTEST, HIGHZ and CLAMP instructions are active.
  • Page 189: Boot

    Chapter 6 Reset and Boot • DWT • ITM • NVIC • Crossbar bus switch • AHB-AP • Private peripheral bus 6.3 Boot This section describes the boot sequence, including sources and options. 6.3.1 Boot sources This device only supports booting from internal flash. Any secondary boot must go through an initialization sequence in flash.
  • Page 190: Boot Sequence

    Boot reprogram the option byte in flash to change the FOPT values that are used for subsequent resets. For more details on programming the option byte, refer to the flash memory chapter. The MCU uses the FTFL_FOPT register bits to configure the device at reset as shown in the following table.
  • Page 191 Chapter 6 Reset and Boot 4. The RESET pin is released, but the system reset of internal logic continues to be held until the Flash Controller finishes initialization. EzPort mode is selected instead of the normal CPU execution if EZP_CS is low when the internal reset is deasserted. EzPort mode can be disabled by programming FTFL_FOPT[EZPORT_DIS].
  • Page 192 Boot K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 193: Power Management

    Chapter 7 Power Management 7.1 Introduction This chapter describes the various chip power modes and functionality of the individual modules in these modes. 7.2 Power modes The power management controller (PMC) provides multiple power options to allow the user to optimize power consumption for the level of functionality needed. Depending on the stop requirements of the user application, a variety of stop modes are available that provide state retention, partial power down or full power down of certain logic and/or memory.
  • Page 194 Power modes Table 7-1. Chip power modes (continued) Chip mode Description Core mode Normal recovery method Normal Wait - Allows peripherals to function while the core is in sleep mode, Sleep Interrupt via WFI reducing power. NVIC remains sensitive to interrupts; peripherals continue to be clocked.
  • Page 195: Entering And Exiting Power Modes

    Chapter 7 Power Management Table 7-1. Chip power modes (continued) Chip mode Description Core mode Normal recovery method BAT (backup The chip is powered down except for the VBAT supply. The RTC and Power-up battery only) the 32-byte VBAT register file for customer-critical data remain Sequence powered.
  • Page 196: Power Mode Transitions

    Power mode transitions 7.4 Power mode transitions The following figure shows the power mode transitions. Any reset always brings the chip back to the normal run state. In run, wait, and stop modes active power regulation is enabled. The VLPx modes are limited in frequency, but offer a lower power operating mode than normal modes.
  • Page 197: Power Modes Shutdown Sequencing

    Chapter 7 Power Management 7.5 Power modes shutdown sequencing When entering stop or other low-power modes, the clocks are shut off in an orderly sequence to safely place the chip in the targeted low-power state. All low-power entry sequences are initiated by the core executing an WFI instruction. The ARM core's outputs, SLEEPDEEP and SLEEPING, trigger entry to the various low-power modes: •...
  • Page 198 Module Operation in Low Power Modes • powered = Memory is powered to retain contents. • low power = Flash has a low power state that retains configuration registers to support faster wakeup. • OFF = Modules are powered off; module is in reset state upon wakeup. •...
  • Page 199 Chapter 7 Power Management Table 7-2. Module operation in low power modes (continued) Modules Stop VLPR VLPW VLPS VLLSx FlexMemory low power low power low power low power low power low power in VLLS3, OFF in VLLS2 and VLLS1 Register files powered powered powered...
  • Page 200: Clock Gating

    Clock Gating Table 7-2. Module operation in low power modes (continued) Modules Stop VLPR VLPW VLPS VLLSx Human-machine interfaces GPIO wakeup wakeup static, pins OFF, pins latched latched Segment LCD wakeup wakeup wakeup wakeup 1. Using the LLWU module, the external pins available for this chip do not require the associated peripheral function to be enabled.
  • Page 201: Security

    Chapter 8 Security 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. 8.2 Flash Security The flash module provides security information to the MCU based on the state held by the FSEC[SEC] bits.
  • Page 202: Security Interactions With Other Modules

    Security Interactions with other Modules 8.3 Security Interactions with other Modules The flash security settings are used by the SoC to determine what resources are available. The following sections describe the interactions between modules and the flash security settings or the impact that the flash security has on non-flash modules. 8.3.1 Security Interactions with EzPort When flash security is active the MCU can still boot in EzPort mode.
  • Page 203: Introduction

    Chapter 9 Debug 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: •...
  • Page 204 Introduction Cortex-M4 INTNMI Interrupts Sleep INTISR[239:0] NVIC Core SLEEPING Debug Trigger SLEEPDEEP Instr. Data Trace port (serial wire or multi-pin) TPIU AWIC Private Peripheral Bus (internal) Table I-code bus Code bus D-code bus Matrix System bus SWJ-DP AHB-AP JTAG MDM-AP Figure 9-1.
  • Page 205: References

    Chapter 9 Debug Table 9-1. Debug Components Description (continued) Module Description DWT (Data and Address Watchpoints) 4 data and address watchpoints (configurable for less, but 4 seems to be accepted) FPB (Flash Patch and Breakpoints) The FPB implements hardware breakpoints and patches code and data from code space to system space.
  • Page 206: Jtag-To-Swd Change Sequence

    The Debug Port IR==BYPASS or IDC ODE 4’b1111 or 4’b0000 jtag_updateinstr[3:0] To Test J TAGC Resources nTRST TC K TRACESWO (1’b1 = 4-pin J TAG) CJ TAG (1’b0 = 2-pin cJ TAG) TDI TDO PEN nSYS_TDO nSYS_TDI 1’b1 nTRST nSYS_TRST SWCLKTCK TC K nSYS_TC K...
  • Page 207: Debug Port Pin Descriptions

    Chapter 9 Debug 2. Set the control level to 2 via zero-bit scans 3. Execute the Store Format (STFMT) command (00011) to set the scan format register to 1149.7 scan format 9.3 Debug Port Pin Descriptions The debug port pins default after POR to their JTAG functionality with the exception of JTAG_TRST_b and can be later reassigned to their alternate functionalities.
  • Page 208: Ir Codes

    JTAG status and control registers 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...
  • Page 209: Mdm-Ap Control Register

    Chapter 9 Debug It is important to note that these DAP control and status registers are not memory mapped within the system memory map and are only accessible via the Debug Access Port (DAP) using JTAG, cJTAG, or SWD. The MDM-AP is accessible as Debug Access Port 1 with the available registers shown in the table below.
  • Page 210 JTAG status and control registers 9.5.1 MDM-AP Control Register Table 9-5. MDM-AP Control register assignments Name Secure Description Flash Mass Erase in Progress Set to cause mass erase. Cleared by hardware after mass erase operation completes. When mass erase is disabled (via MEEN and SEC settings), the erase request does not occur and the Flash Mass Erase in Progress bit continues to assert until the next system reset.
  • Page 211: Mdm-Ap Status Register

    Chapter 9 Debug Table 9-5. MDM-AP Control register assignments (continued) Name Secure Description LLS, VLLSx Status Acknowledge Set this bit to acknowledge the DAP LLS and VLLS Status bits have been read. This acknowledge automatically clears the status bits. This bit is used by the debugger to clear the sticky LLS and VLLSx mode entry status bits.
  • Page 212: Debug Resets

    Debug Resets Table 9-6. MDM-AP Status register assignments (continued) Name Description LP Enabled Decode of LPLLSM control bits to indicate that VLPS, LLS, or VLLSx are the selected power mode the next time the ARM Core enters Deep Sleep. 0 Low Power Stop Mode is not enabled 1 Low Power Stop Mode is enabled Usage intended for debug operation in which Run to VLPS is attempted.
  • Page 213: Ahb-Ap

    Chapter 9 Debug • 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: •...
  • Page 214: Itm

    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.
  • Page 215: Coresight Embedded Trace Buffer (Etb)

    Chapter 9 Debug 9.11 Coresight Embedded Trace Buffer (ETB) The ETB provides on-chip storage of trace data using 32-bit RAM. The ETB accepts trace data from any CoreSight-compliant component trace source with an ATB master port, such as a trace source or a trace funnel. It is included in this device to remove dependencies from the trace pin pad speed, and enable low cost trace solutions.
  • Page 216: Etb Counter Control

    TPIU multiple sequential runs by executing code until the ETB is almost full, and halting or executing an interrupt handler to allow the buffer to be emptied, and then continuing executing code. The target halts or executes an interrupt handler when the buffer is almost full to empty the data and then the debugger runs the target again.
  • Page 217: Debug In Low Power Modes

    Chapter 9 Debug • Sleep cycles • CPI (all instruction cycles except for the first cycle) • Interrupt overhead NOTE An event is emitted each time a counter overflows. • The DWT can be configured to emit PC samples at defined intervals, and to emit interrupt event information.
  • Page 218: Debug Module State In Low Power Modes

    Debug & Security 9.14.1 Debug Module State in Low Power Modes The following table shows the state of the debug modules in low power modes. These terms are used: • FF = Full functionality. In VLPR and VLPW the system frequency is limited, but if a module does not have a limitation in its functionality, it is still listed as FF.
  • Page 219: Signal Multiplexing And Signal Descriptions

    Chapter 10 Signal Multiplexing and Signal Descriptions 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. 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.
  • Page 220: Port Control And Interrupt Module Features

    Signal Multiplexing Integration Table 10-1. Reference links to related information (continued) Topic Related module Reference Clocking Clock Distribution Register access Peripheral bus Peripheral bridge controller 10.2.1 Port control and interrupt module features • Five 32-pin ports NOTE Not all pins are available on the device. See the following section for details.
  • Page 221: Pinout

    Chapter 10 Signal Multiplexing and Signal Descriptions 10.3 Pinout 10.3.1 K51 Signal Multiplexing and Pin Assignments The following table shows the signals available on each pin and the locations of these pins on the devices supported by this document. The Port Control Module is responsible for selecting which ALT functionality is available on each pin.
  • Page 222 Pinout Pin Name Default ALT0 ALT1 ALT2 ALT3 ALT4 ALT5 ALT6 ALT7 EzPort ADC1_DM1/ ADC1_DM1/ ADC1_DM1/ OP1_DM0 OP1_DM0 OP1_DM0 PGA0_DP/ PGA0_DP/ PGA0_DP/ ADC0_DP0/ ADC0_DP0/ ADC0_DP0/ ADC1_DP3 ADC1_DP3 ADC1_DP3 PGA0_DM/ PGA0_DM/ PGA0_DM/ ADC0_DM0/ ADC0_DM0/ ADC0_DM0/ ADC1_DM3 ADC1_DM3 ADC1_DM3 PGA1_DP/ PGA1_DP/ PGA1_DP/ ADC1_DP0/ ADC1_DP0/ ADC1_DP0/...
  • Page 223 Chapter 10 Signal Multiplexing and Signal Descriptions Pin Name Default ALT0 ALT1 ALT2 ALT3 ALT4 ALT5 ALT6 ALT7 EzPort DAC1_OUT/ DAC1_OUT/ DAC1_OUT/ CMP2_IN3/ CMP2_IN3/ CMP2_IN3/ ADC1_SE23/ ADC1_SE23/ ADC1_SE23/ OP0_DP5/ OP0_DP5/ OP0_DP5/ OP1_DP5 OP1_DP5 OP1_DP5 XTAL32 XTAL32 XTAL32 EXTAL32 EXTAL32 EXTAL32 VBAT VBAT VBAT...
  • Page 224 Pinout Pin Name Default ALT0 ALT1 ALT2 ALT3 ALT4 ALT5 ALT6 ALT7 EzPort J11 RESET_b RESET_b RESET_b H11 PTA29 DISABLED PTA29 FB_AD19 G11 PTB0/ LCD_P0/ LCD_P0/ PTB0/ I2C0_SCL FTM1_CH0 FTM1_QD_P LCD_P0 LLWU_P5 ADC0_SE8/ ADC0_SE8/ LLWU_P5 ADC1_SE8/ ADC1_SE8/ TSI0_CH0 TSI0_CH0 G10 PTB1 LCD_P1/ LCD_P1/ PTB1...
  • Page 225 Chapter 10 Signal Multiplexing and Signal Descriptions Pin Name Default ALT0 ALT1 ALT2 ALT3 ALT4 ALT5 ALT6 ALT7 EzPort CMP1_IN0/ CMP1_IN0/ TSI0_CH15 TSI0_CH15 PTC3/ LCD_P23/ LCD_P23/ PTC3/ SPI0_PCS1 UART1_RX FTM0_CH2 LCD_P23 LLWU_P7 CMP1_IN1 CMP1_IN1 LLWU_P7 A11 VLL3 VLL3 VLL3 A10 VLL2 VLL2 VLL2 VLL1...
  • Page 226: K51 Pinouts

    Pinout Pin Name Default ALT0 ALT1 ALT2 ALT3 ALT4 ALT5 ALT6 ALT7 EzPort PTD3 LCD_P43 LCD_P43 PTD3 SPI0_SIN UART2_TX LCD_P43 PTD4/ LCD_P44 LCD_P44 PTD4/ SPI0_PCS1 UART0_RTS FTM0_CH4 EWM_IN LCD_P44 LLWU_P14 LLWU_P14 PTD5 LCD_P45/ LCD_P45/ PTD5 SPI0_PCS2 UART0_CTS FTM0_CH5 EWM_OUT_ LCD_P45 ADC0_SE6b ADC0_SE6b PTD6/...
  • Page 227: Module Signal Description Tables

    Chapter 10 Signal Multiplexing and Signal Descriptions PTD7 PTD5 PTD4 PTC19 PTC14 PTC13 PTC8 PTC4 VLL1 VLL2 VLL3 PTD10 PTD6 PTD3 PTC18 PTC15 PTC12 PTC7 PTC3 PTC0 PTB16 VCAP2 PTD12 PTD11 PTD2 PTC17 PTC11 PTC10 PTC6 PTC2 PTB19 PTB11 VCAP1 PTD14 PTD13 PTD1...
  • Page 228: Core Modules

    Module Signal Description Tables 10.4.1 Core Modules Table 10-2. JTAG Signal Descriptions Chip signal name Module signal Description name JTAG_TMS JTAG_TMS/ JTAG Test Mode Selection SWD_DIO JTAG_TCLK JTAG_TCLK/ JTAG Test Clock SWD_CLK JTAG_TDI JTAG_TDI JTAG Test Data Input JTAG_TDO JTAG_TDO/ JTAG Test Data Output TRACE_SWO JTAG_TRST...
  • Page 229: Clock Modules

    Chapter 10 Signal Multiplexing and Signal Descriptions Table 10-5. System Signal Descriptions (continued) Chip signal name Module signal Description name RESET — Reset bi-directional signal — MCU power — MCU ground Table 10-6. EWM Signal Descriptions Chip signal name Module signal Description name EWM_IN...
  • Page 230: Analog

    Module Signal Description Tables 10.4.5 Analog Table 10-10. ADC 0 Signal Descriptions Chip signal name Module signal Description name ADC0_DP3, DADP[3:0] Differential analog channel inputs PGA0_DP, ADC0_DP[1:0] ADC0_DM3, DADM[3:0] Differential analog channel inputs PGA0_DM, ADC0_DM[1:0] ADC0_SE[18,17,15: AD[23:4] Single-ended analog channel inputs 12,9:418,17,15:12,9: VREFH Voltage reference select high...
  • Page 231 Chapter 10 Signal Multiplexing and Signal Descriptions Table 10-13. CMP 1 Signal Descriptions Chip signal name Module signal Description name CMP1_IN[5:0] IN[5:0] Analog voltage inputs CMP1_OUT CMPO Comparator output Table 10-14. CMP 2 Signal Descriptions Chip signal name Module signal Description name CMP2_IN[5:0]...
  • Page 232: Communication Interfaces

    Module Signal Description Tables Table 10-19. TRIAMP 1 Signal Descriptions Chip signal name Module signal Description name TRI1_DP inp_3v Amplifier positive input terminal TRI1_DM inn_3v Amplifier negative input terminal TRI1_OUT out_3v Amplifier output terminal Table 10-20. VREF Signal Descriptions Chip signal name Module signal Description name...
  • Page 233 Chapter 10 Signal Multiplexing and Signal Descriptions Table 10-23. SPI 0 Signal Descriptions (continued) Chip signal name Module signal Description name SPI0_PCS5 PCS5/ PCSS Master mode: Peripheral Chip Select 5 / Peripheral Chip Select Strobe Slave mode: Unused SPI0_SIN Serial Data In SPI0_SOUT SOUT Serial Data Out...
  • Page 234 Module Signal Description Tables Table 10-28. UART 2 Signal Descriptions Chip signal name Module signal Description name UART2_CTS Clear to send UART2_RTS Request to send UART2_TX Transmit data UART2_RX Receive data Table 10-29. UART 3 Signal Descriptions Chip signal name Module signal Description name...
  • Page 235 Chapter 10 Signal Multiplexing and Signal Descriptions Table 10-32. SDHC Signal Descriptions (continued) Chip signal name Module signal Description name SDHC0_D1 SDHC_D1 8-bit mode: DAT1 line 4-bit mode: DAT1 line or interrupt detect 1-bit mode: Interrupt detect SDHC0_D2 SDHC_D2 4-/8-bit mode: DAT2 line or read wait 1-bit mode: Read wait SDHC0_D3 SDHC_D3...
  • Page 236: Human-Machine Interfaces (Hmi)

    Module Signal Description Tables Table 10-33. I S 0 Signal Descriptions (continued) Chip signal name Module signal Description name I2S0_TXD STXD Serial transmit data. The STXD port is an output and transmits data from the serial transmit shift register. The STXD port is an output port when data is being transmitted and is disabled between data word transmissions and on the trailing edge of the bit clock after the last bit of a word is transmitted.
  • Page 237: Port Control And Interrupts (Port)

    Chapter 11 Port control and interrupts (PORT) 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 external interrupt, digital filtering and port control 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.
  • Page 238: Modes Of Operation

    Introduction • Selectable clock source for digital input filter with 5-bit resolution on filter size • Digital filter is functional in all digital pin muxing modes • Port control • Individual pull control registers with pullup, pulldown and pull-disable support •...
  • Page 239: External Signal Description

    Chapter 11 Port control and interrupts (PORT) 11.2 External signal description Table 11-1. Signal properties Name Function Reset Pull PORTx[31:0] External interrupt NOTE Not all pins within each port are implemented on each device. 11.3 Detailed signal descriptions Table 11-2. PORTx interface-detailed signal descriptions Signal Description PORTx[31:0]...
  • Page 240 Memory map and register definition PORT memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 4004_900C Pin Control Register n (PORTA_PCR3) 0000_0000h 11.4.1/246 4004_9010 Pin Control Register n (PORTA_PCR4) 0000_0000h 11.4.1/246 4004_9014 Pin Control Register n (PORTA_PCR5) 0000_0000h 11.4.1/246 4004_9018...
  • Page 241 Chapter 11 Port control and interrupts (PORT) PORT memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) reads zero) 4004_90A0 Interrupt Status Flag Register (PORTA_ISFR) 0000_0000h 11.4.4/249 4004_90C0 Digital Filter Enable Register (PORTA_DFER) 0000_0000h 11.4.5/250 4004_90C4...
  • Page 242 Memory map and register definition PORT memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 4004_A070 Pin Control Register n (PORTB_PCR28) 0000_0000h 11.4.1/246 4004_A074 Pin Control Register n (PORTB_PCR29) 0000_0000h 11.4.1/246 4004_A078 Pin Control Register n (PORTB_PCR30) 0000_0000h 11.4.1/246 4004_A07C...
  • Page 243 Chapter 11 Port control and interrupts (PORT) PORT memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 4004_B050 Pin Control Register n (PORTC_PCR20) 0000_0000h 11.4.1/246 4004_B054 Pin Control Register n (PORTC_PCR21) 0000_0000h 11.4.1/246 4004_B058 Pin Control Register n (PORTC_PCR22) 0000_0000h...
  • Page 244 Memory map and register definition PORT memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 4004_C030 Pin Control Register n (PORTD_PCR12) 0000_0000h 11.4.1/246 4004_C034 Pin Control Register n (PORTD_PCR13) 0000_0000h 11.4.1/246 4004_C038 Pin Control Register n (PORTD_PCR14) 0000_0000h 11.4.1/246 4004_C03C...
  • Page 245 Chapter 11 Port control and interrupts (PORT) PORT memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 4004_D010 Pin Control Register n (PORTE_PCR4) 0000_0000h 11.4.1/246 4004_D014 Pin Control Register n (PORTE_PCR5) 0000_0000h 11.4.1/246 4004_D018 Pin Control Register n (PORTE_PCR6) 0000_0000h...
  • Page 246: Pin Control Register N (Portx_Pcrn)

    Memory map and register definition PORT memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 4004_D0A0 Interrupt Status Flag Register (PORTE_ISFR) 0000_0000h 11.4.4/249 4004_D0C0 Digital Filter Enable Register (PORTE_DFER) 0000_0000h 11.4.5/250 4004_D0C4 Digital Filter Clock Register (PORTE_DFCR) 0000_0000h 11.4.6/251 4004_D0C8...
  • Page 247 Chapter 11 Port control and interrupts (PORT) PORTx_PCRn field descriptions (continued) Field Description 1001 Interrupt on rising edge. 1010 Interrupt on falling edge. 1011 Interrupt on either edge. 1100 Interrupt when logic one. Others Reserved. Lock Register Pin Control Register bits [15:0] are not locked. Pin Control Register bits [15:0] are locked and cannot be updated until the next System Reset.
  • Page 248: Global Pin Control Low Register (Portx_Gpclr)

    Memory map and register definition PORTx_PCRn field descriptions (continued) Field Description Slew Rate Enable Slew Rate configuration is valid in all digital pin muxing modes. Fast slew rate is configured on the corresponding pin, if pin is configured as a digital output. Slow slew rate is configured on the corresponding pin, if pin is configured as a digital output.
  • Page 249: Global Pin Control High Register (Portx_Gpchr)

    Chapter 11 Port control and interrupts (PORT) 11.4.3 Global Pin Control High Register (PORTx_GPCHR) Addresses: PORTA_GPCHR is 4004_9000h base + 84h offset = 4004_9084h PORTB_GPCHR is 4004_A000h base + 84h offset = 4004_A084h PORTC_GPCHR is 4004_B000h base + 84h offset = 4004_B084h PORTD_GPCHR is 4004_C000h base + 84h offset = 4004_C084h PORTE_GPCHR is 4004_D000h base + 84h offset = 4004_D084h GPWE...
  • Page 250: Digital Filter Enable Register (Portx_Dfer)

    Memory map and register definition PORTx_ISFR field descriptions Field Description 31–0 Interrupt Status Flag Each bit in the field indicates the detection of the configured interrupt of the same number as the bit. Configured interrupt has not been detected. Configured interrupt has been detected. If pin is configured to generate a DMA request then the corresponding flag will be cleared automatically at the completion of the requested DMA transfer, otherwise the flag remains set until a logic one is written to the flag.
  • Page 251: Digital Filter Clock Register (Portx_Dfcr)

    Chapter 11 Port control and interrupts (PORT) 11.4.6 Digital Filter Clock Register (PORTx_DFCR) Addresses: PORTA_DFCR is 4004_9000h base + C4h offset = 4004_90C4h PORTB_DFCR is 4004_A000h base + C4h offset = 4004_A0C4h PORTC_DFCR is 4004_B000h base + C4h offset = 4004_B0C4h PORTD_DFCR is 4004_C000h base + C4h offset = 4004_C0C4h PORTE_DFCR is 4004_D000h base + C4h offset = 4004_D0C4h Reset...
  • Page 252: Functional Description

    Functional description PORTx_DFWR field descriptions Field Description 31–5 This read-only field is reserved and always has the value zero. Reserved 4–0 Filter Length FILT The digital filter configuration is valid in all digital pin muxing modes. Configures the maximum size of the glitches (in clock cycles) the digital filter absorbs for enabled digital filters.
  • Page 253: External Interrupts

    Chapter 11 Port control and interrupts (PORT) 11.5.2 Global pin control The two global pin control registers allow a single register write to update the lower half of the pin control register on up to sixteen pins, all with the same value. Registers that are locked cannot be written using the global pin control registers.
  • Page 254: Digital Filter

    Functional description During stop mode, the interrupt status flag for any enabled interrupt (but not DMA request) will asynchronously set if the required level or edge is detected. This also generates an asynchronous wakeup signal to exit the low power mode. 11.5.4 Digital filter The digital filter capabilities of the PORT module are available in all digital pin muxing modes provided the PORT module is enabled.
  • Page 255: System Integration Module (Sim)

    Chapter 12 System integration module (SIM) 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 • Configuration for system clocking •...
  • Page 256: Sim Signal Descriptions

    Memory map and register definition 12.1.3 SIM Signal Descriptions Table 12-1. SIM Signal Descriptions Signa Description EZP_ EzPort mode select 12.1.3.1 Detailed signal description Table 12-2. SIM interface-detailed signal descriptions Signal Description EZP_CS EZPORT mode select State meaning Assertion-0 - Configure part for EZPORT mode Negation- 1 - Configure part for normal flash operation...
  • Page 257 Chapter 12 System integration module (SIM) SIM memory map Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 4004_7000 System Options Register 1 (SIM_SOPT1) Undefined 12.2.1/258 4004_8004 System Options Register 2 (SIM_SOPT2) 0000_1000h 12.2.2/260 4004_800C System Options Register 4 (SIM_SOPT4) 0000_0000h 12.2.3/262 4004_8010...
  • Page 258: System Options Register 1 (Sim_Sopt1)

    Memory map and register definition 12.2.1 System Options Register 1 (SIM_SOPT1) The reset value of the SOPT1 register is as follows: Exit from POR and LVD: USBREGEN is set, USBSTBY is cleared, and OSC32KSEL is cleared. Exit from VLLS or other system reset: USBREGEN, USBSTBY and OSC32KSEL are unaffected Address: SIM_SOPT1 is 4004_7000h base + 0h offset = 4004_7000h Reserved Reset...
  • Page 259 Chapter 12 System integration module (SIM) SIM_SOPT1 field descriptions (continued) Field Description 22–20 This read-only field is reserved and always has the value zero. Reserved 32K oscillator clock select OSC32KSEL Selects the 32 kHz clock source (ERCLK32K) for Segment LCD, TSI, and LPTMR. This bit is reset only for POR/LVD.
  • Page 260: System Options Register 2 (Sim_Sopt2)

    Memory map and register definition 12.2.2 System Options Register 2 (SIM_SOPT2) 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: SIM_SOPT2 is 4004_7000h base + 1004h offset = 4004_8004h SDHCSRC I2SSRC...
  • Page 261 Chapter 12 System integration module (SIM) SIM_SOPT2 field descriptions (continued) Field Description OSCERCLK clock External bypass clock (I2S0_CLKIN) 23–22 This read-only field is reserved and always has the value zero. Reserved 21–20 This read-only field is reserved and always has the value zero. Reserved This read-only field is reserved and always has the value zero.
  • Page 262: System Options Register 4 (Sim_Sopt4)

    Memory map and register definition SIM_SOPT2 field descriptions (continued) Field Description System oscillator (OSCCLK) 32 kHz RTC oscillator 12.2.3 System Options Register 4 (SIM_SOPT4) Address: SIM_SOPT4 is 4004_7000h base + 100Ch offset = 4004_800Ch Reset Reset SIM_SOPT4 field descriptions Field Description 31–27 This read-only field is reserved and always has the value zero.
  • Page 263 Chapter 12 System integration module (SIM) SIM_SOPT4 field descriptions (continued) Field Description 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.
  • Page 264: System Options Register 5 (Sim_Sopt5)

    Memory map and register definition SIM_SOPT4 field descriptions (continued) Field Description FTM1_FLT0 pin CMP0 out This read-only field is reserved and always has the value zero. Reserved 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.
  • Page 265 Chapter 12 System integration module (SIM) SIM_SOPT5 field descriptions Field Description 31–8 This read-only field is reserved and always has the value zero. Reserved 7–6 UART 1 receive data source select UART1RXSRC Selects the source for the UART 1 receive data. UART1_RX pin CMP0 CMP1...
  • Page 266: System Options Register 6 (Sim_Sopt6)

    Memory map and register definition 12.2.5 System Options Register 6 (SIM_SOPT6) The reset values of the RSTFLTEN and RSTFLTSEL bits are for power-on reset only. They are unaffected by other reset types. Address: SIM_SOPT6 is 4004_7000h base + 1014h offset = 4004_8014h RSTFLTEN RSTFLTSEL Reset...
  • Page 267: System Options Register 7 (Sim_Sopt7)

    Chapter 12 System integration module (SIM) 12.2.6 System Options Register 7 (SIM_SOPT7) Address: SIM_SOPT7 is 4004_7000h base + 1018h offset = 4004_8018h Reset ADC1TRGSEL ADC0TRGSEL Reset SIM_SOPT7 field descriptions Field Description 31–16 This read-only field is reserved and always has the value zero. Reserved ADC1 alternate trigger enable ADC1ALTTRGEN...
  • Page 268 Memory map and register definition SIM_SOPT7 field descriptions (continued) Field Description 0001 High speed comparator 0 output 0010 High speed comparator 1 output 0011 High speed comparator 2 output 0100 PIT trigger 0 0101 PIT trigger 1 0110 PIT trigger 2 0111 PIT trigger 3 1000 FTM0 trigger 1001 FTM1 trigger...
  • Page 269: System Device Identification Register (Sim_Sdid)

    Chapter 12 System integration module (SIM) SIM_SOPT7 field descriptions (continued) Field Description 1101 RTC seconds 1110 Low-power timer trigger 1011 Unused 12.2.7 System Device Identification Register (SIM_SDID) Address: SIM_SDID is 4004_7000h base + 1024h offset = 4004_8024h REVID FAMID PINID 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* Reset * Notes:...
  • Page 270: System Clock Gating Control Register 1 (Sim_Scgc1)

    Memory map and register definition SIM_SDID field descriptions (continued) Field Description 3–0 Pincount identification PINID Specifies the pincount of the device. 0000 Reserved 0001 Reserved 0010 32-pin 0011 Reserved 0100 48-pin 0101 64-pin 0110 80-pin 0111 81-pin 1000 100-pin 1001 121-pin 1010 144-pin...
  • Page 271: System Clock Gating Control Register 2 (Sim_Scgc2)

    Chapter 12 System integration module (SIM) SIM_SCGC1 field descriptions (continued) Field Description OPAMP Clock Gate Control OPAMP This bit controls the clock gate to the OPAMP module. Clock disabled Clock enabled 20–12 This read-only field is reserved and always has the value zero. Reserved UART5 Clock Gate Control UART5...
  • Page 272: System Clock Gating Control Register 3 (Sim_Scgc3)

    Memory map and register definition SIM_SCGC2 field descriptions (continued) Field Description This bit controls the clock gate to the DAC0 module. Clock disabled Clock enabled 11–1 This read-only field is reserved and always has the value zero. Reserved This read-only field is reserved and always has the value zero. Reserved 12.2.10 System Clock Gating Control Register 3 (SIM_SCGC3) Address: SIM_SCGC3 is 4004_7000h base + 1030h offset = 4004_8030h...
  • Page 273: System Clock Gating Control Register 4 (Sim_Scgc4)

    Chapter 12 System integration module (SIM) SIM_SCGC3 field descriptions (continued) Field Description 23–18 This read-only field is reserved and always has the value zero. Reserved SDHC Clock Gate Control SDHC This bit controls the clock gate to the SDHC module. Clock disabled Clock enabled 16–13...
  • Page 274 Memory map and register definition SIM_SCGC4 field descriptions Field Description This read-only field is reserved and always has the value zero. Reserved 30–29 This read-only field is reserved and always has the value one. Reserved LLWU Clock Gate Control LLWU This bit controls the clock gate to the LLWU module.
  • Page 275 Chapter 12 System integration module (SIM) SIM_SCGC4 field descriptions (continued) Field Description Clock disabled Clock enabled UART0 Clock Gate Control UART0 This bit controls the clock gate to the UART0 module. Clock disabled Clock enabled 9–8 This read-only field is reserved and always has the value zero. Reserved I2C1 Clock Gate Control I2C1...
  • Page 276: System Clock Gating Control Register 5 (Sim_Scgc5)

    Memory map and register definition 12.2.12 System Clock Gating Control Register 5 (SIM_SCGC5) Address: SIM_SCGC5 is 4004_7000h base + 1038h offset = 4004_8038h Reset Reset SIM_SCGC5 field descriptions Field Description 31–19 This read-only field is reserved and always has the value zero. Reserved This read-only field is reserved and always has the value one.
  • Page 277 Chapter 12 System integration module (SIM) SIM_SCGC5 field descriptions (continued) Field Description Clock disabled Clock enabled Port A Clock Gate Control PORTA This bit controls the clock gate to the Port A module. Clock disabled Clock enabled 8–7 This read-only field is reserved and always has the value one. Reserved This read-only field is reserved and always has the value zero.
  • Page 278: System Clock Gating Control Register 6 (Sim_Scgc6)

    Memory map and register definition 12.2.13 System Clock Gating Control Register 6 (SIM_SCGC6) Address: SIM_SCGC6 is 4004_7000h base + 103Ch offset = 4004_803Ch Reset Reset SIM_SCGC6 field descriptions Field Description This read-only field is reserved and always has the value zero. Reserved This read-only field is reserved and always has the value one.
  • Page 279 Chapter 12 System integration module (SIM) SIM_SCGC6 field descriptions (continued) Field Description FTM0 Clock Gate Control FTM0 This bit controls the clock gate to the FTM0 module. Clock disabled Clock enabled PIT Clock Gate Control This bit controls the clock gate to the PIT module. Clock disabled Clock enabled PDB Clock Gate Control...
  • Page 280: System Clock Gating Control Register 7 (Sim_Scgc7)

    Memory map and register definition SIM_SCGC6 field descriptions (continued) Field Description SPI0 Clock Gate Control SPI0 This bit controls the clock gate to the SPI0 module. Clock disabled Clock enabled 11–5 This read-only field is reserved and always has the value zero. Reserved This read-only field is reserved and always has the value zero.
  • Page 281: System Clock Divider Register 1 (Sim_Clkdiv1)

    Chapter 12 System integration module (SIM) SIM_SCGC7 field descriptions (continued) Field Description DMA Clock Gate Control This bit controls the clock gate to the DMA module. Clock disabled Clock enabled This read-only field is reserved and always has the value zero. Reserved 12.2.15 System Clock Divider Register 1 (SIM_CLKDIV1) The CLKDIV1 register cannot be written to when the device is in VLPR mode.
  • Page 282 Memory map and register definition SIM_CLKDIV1 field descriptions (continued) Field Description 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].
  • Page 283: System Clock Divider Register 2 (Sim_Clkdiv2)

    Chapter 12 System integration module (SIM) SIM_CLKDIV1 field descriptions (continued) Field Description 15–0 This read-only field is reserved and always has the value zero. Reserved 12.2.16 System Clock Divider Register 2 (SIM_CLKDIV2) Address: SIM_CLKDIV2 is 4004_7000h base + 1048h offset = 4004_8048h I2SDIV Reset I2SFRAC...
  • Page 284: Flash Configuration Register 1 (Sim_Fcfg1)

    Memory map and register definition SIM_CLKDIV2 field descriptions (continued) Field Description Divider output clock = Divider input clock × [ (USBFRAC+1) / (USBDIV+1) ] USB clock divider fraction USBFRAC This field sets the fraction multiply value for the fractional clock divider when the MCGFLLCLK/ MCGPLLCLK clock is the USB clock source (SOPT2[USBSRC] = 1).
  • Page 285 Chapter 12 System integration module (SIM) SIM_FCFG1 field descriptions (continued) Field Description 1011 512 KB of program flash memory, 16 KB protection region 1111 For devices with FlexNVM (SIM_FCFG2[PFLSH]=0): 256 KB of program flash, 8 KB protection region. For devices without FlexNVM (SIM_FCFG2[PFLSH]=1): 512 KB of program flash memory, 16 KB protection region 23–20 This read-only field is reserved and always has the value zero.
  • Page 286: Flash Configuration Register 2 (Sim_Fcfg2)

    Memory map and register definition 12.2.18 Flash Configuration Register 2 (SIM_FCFG2) Address: SIM_FCFG2 is 4004_7000h base + 1050h offset = 4004_8050h MAXADDR0 MAXADDR1 Reset Reset * Notes: • x = Undefined at reset. SIM_FCFG2 field descriptions Field Description Swap program flash SWAPPFLSH For devices without FlexNVM: Indicates that swap is active.
  • Page 287: Unique Identification Register High (Sim_Uidh)

    Chapter 12 System integration module (SIM) SIM_FCFG2 field descriptions (continued) Field Description For devices without FlexNVM: This bit is always set. For devices with FlexNVM: Physical flash block 1 is used as FlexNVM For devices without FlexNVM: Reserved Physical flash block 1 is used as program flash This read-only field is reserved and always has the value zero.
  • Page 288: Unique Identification Register Mid-High (Sim_Uidmh)

    Memory map and register definition 12.2.20 Unique Identification Register Mid-High (SIM_UIDMH) Address: SIM_UIDMH is 4004_7000h base + 1058h offset = 4004_8058h 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* Reset * Notes: •...
  • Page 289: Unique Identification Register Low (Sim_Uidl)

    Chapter 12 System integration module (SIM) 12.2.22 Unique Identification Register Low (SIM_UIDL) Address: SIM_UIDL is 4004_7000h base + 1060h offset = 4004_8060h 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* Reset * Notes: •...
  • Page 290 Functional description K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 291: Mode Controller

    Chapter 13 Mode Controller 13.1 Introduction NOTE For the chip-specific implementation details of this module's instances see the chip configuration chapter. This section discusses the mode controller (MC) which controls power management and reset mechanisms including the various sources of resets on the device. The MC provides: •...
  • Page 292 Introduction 13.1.2 Modes of Operation The ARM CPU has three primary modes of operation: run, sleep, and deep sleep. The WFI instruction is used to invoke sleep and deep sleep modes. For Freescale microcontrollers, run, wait and stop are the common terminology used for the primary operating modes.
  • Page 293 Chapter 13 Mode Controller Table 13-1. Power modes (continued) Mode Description VLPR The Core Clock, System Clock and Bus Clocks maximum frequency is restricted to 2MHz max, Flash Clock is restricted to 1MHz. The slow IRC within the MCG must not be enabled when VLPR is entered.
  • Page 294 Introduction Any reset VLPW Wait VLPR Stop VLPS VLLS 3, 2, 1 Figure 13-1. Power Mode State Diagram The following table defines triggers for the various state transitions shown in the previous figure. Table 13-2. Power mode transition triggers Transition # From Trigger Conditions Wait...
  • Page 295 Chapter 13 Mode Controller Table 13-2. Power mode transition triggers (continued) Transition # From Trigger Conditions VLPR Reduce system, bus and core frequency to 2 MHz or less, Flash access limited to 1MHz. AVLP=1, Set RUNM = 10. NOTE: Poll VLPRS bit before transitioning out of VLPR mode.
  • Page 296 Introduction Table 13-2. Power mode transition triggers (continued) Transition # From Trigger Conditions VLPR VLLS(3,2,1) LPLLSM = (see PMCTRL register description for VLLS configuration), Sleep-now or sleep-on-exit modes entered with SLEEPDEEP set, controlled in System Control Register in ARM core 13.1.2.2 Run Modes The device contains two different run modes: •...
  • Page 297 Chapter 13 Mode Controller • RUNM set to 10b to enter VLPR. • Flash programming/erasing is not allowed. • The slow IRC must not be enabled. • All clock monitors must be disabled before entering VLPR. While in VLPR, the regulator is slow responding and cannot handle fast load transitions. Therefore, do not change the clock frequency.
  • Page 298 Introduction 13.1.2.3.1 Wait Mode Wait mode is entered when the ARM core enters the sleep-now or sleep-on-exit modes. The ARM CPU enters a low-power state in which it is not clocked, but peripherals continue to be clocked provided they are enabled and clock gating to the peripheral is enabled via the SIM.
  • Page 299 Chapter 13 Mode Controller certain asynchronous mode peripherals are operating with the remainer of the MCU powered off. The tradeoffs depend upon the user's application, where power usage and state retention versus functional needs are weighed. The various stop modes are selected by setting the appropriate bits in the power mode protection (PMPROT) and power mode control (PMCTRL) registers.
  • Page 300 Introduction Register in the ARM core forces the MCU into VLPS and hardware sets the LPWUI bit set. In VLPS, the on-chip voltage regulator remains in its stop regulation state as in VLPR. On transitions from VLPR to VLPS with LPLLSM set to 000b, hardware forces LPLLSM to value of 010b.
  • Page 301 Chapter 13 Mode Controller 13.1.2.4.4 Very Low-Leakage Stop (VLLS3,2,1) Modes This device contains three very low leakage modes: VLLS3, VLLS2, and VLLS1. When a reference applies to all three low leakage modes, VLLS is used. All three of the VLLS modes can be entered from normal run or VLPR. The MCU enters the configured VLLS mode if: •...
  • Page 302: Mcu Reset

    Introduction No debug is available while the MCU is in LLS or VLLS modes. LLS is a state-retention mode and all debug operation can continue after waking from LLS, even in cases where system wakeup is due to a system reset event. Entering into a VLLS mode causes all the debug controls and settings to be powered off.
  • Page 303 Chapter 13 Mode Controller • Computer operating properly (COP) timer • Clock generator (MCG) loss of clock reset (LOC) • Low-voltage detect (LVD) • Wakeup from very low leakage stop modes, VLLSx • Software reset (SW) - by setting SYSRESETREQ bit of the NVIC's Application Interrupt and Reset Control Register •...
  • Page 304 Introduction 13.1.3.4 Multi-Clock Generator (MCG) Loss-of-Clock (LOC) Reset The MCG module supports an external reference clock. If the clock monitor is enabled (MCG_C6[CME] is set) and the external reference falls below a certain frequency (specified in the MCG_C2[RANGE] field), the MCU resets. If a loss of clock causes a reset, the SRSL[LOC] bit is set.
  • Page 305: Mode Control Memory Map/Register Definition

    Chapter 13 Mode Controller 13.1.3.7 Software (SW) Reset Setting the SYSRESETREQ bit in the NVIC's Application Interrupt and Reset Control Register forces a software reset on the device. A software reset resets of all major components except for debug. When the device is reset by a software reset, the SRSH[SW] bit is set. 13.1.3.8 Lock-Up Reset When the processor’s built-in system state protection hardware detects the core is locked up because of an unrecoverable exception, a lock-up reset occurs.
  • Page 306: System Reset Status Register High (Mc_Srsh)

    Mode Control Memory Map/Register Definition MC memory map Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 4007_E000 System Reset Status Register High (MC_SRSH) 13.2.1/306 4007_E001 System Reset Status Register Low (MC_SRSL) 13.2.2/307 4007_E002 Power Mode Protection Register (MC_PMPROT) 13.2.3/308 4007_E003 Power Mode Control Register (MC_PMCTRL)
  • Page 307: System Reset Status Register Low (Mc_Srsl)

    Chapter 13 Mode Controller MC_SRSH field descriptions (continued) Field Description Indicates reset was caused by the ARM core indication of a LOCKUP event. Reset not caused by core LOCKUP event Reset caused by core LOCKUP event JTAG generated reset JTAG Indicates reset was caused by JTAG selection of certain IR codes (EZPORT, EXTEST, HIGHZ, and CLAMP).
  • Page 308: Power Mode Protection Register (Mc_Pmprot)

    Mode Control Memory Map/Register Definition MC_SRSL field descriptions (continued) Field Description Reset not caused by POR Reset caused by POR External reset pin Indicates reset was caused by an active-low level on the external RESETpin. Reset not caused by external reset pin Reset caused by external reset pin Computer Operating Properly (COP) Watchdog Reset was caused by the COP watchdog timer timing out.
  • Page 309 Chapter 13 Mode Controller If the MCU is configured for a disallowed power mode, the MCU remains in its current power mode. For example, if in normal run (RUNM = 00, AVLP = 0) an attempt to enter VLPR using PMCTRL[RUNM] is blocked and the RUNM bits remain 00b indicating MCU is still in normal run mode.
  • Page 310: Power Mode Control Register (Mc_Pmctrl)

    Mode Control Memory Map/Register Definition MC_PMPROT field descriptions (continued) Field Description VLLS3 is not allowed VLLS3 is allowed Allow very low leakage stop 2 mode AVLLS2 This write once bit allows the MCU to enter very low leakage stop 2 mode (VLLS2) provided the appropriate control bits are set up in PMCTRL.
  • Page 311 Chapter 13 Mode Controller Address: MC_PMCTRL is 4007_E000h base + 3h offset = 4007_E003h Read LPWUI RUNM LPLLSM Write Reset MC_PMCTRL field descriptions Field Description Low Power Wake Up on Interrupt LPWUI Controls if the voltage regulator exits stop regulation when any active MCU interrupt occurs, returning the MCU to normal run mode.
  • Page 312 Mode Control Memory Map/Register Definition K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 313: Power Management Controller

    Chapter 14 Power Management Controller 14.1 Introduction NOTE For the chip-specific implementation details of this module's instances see the chip configuration chapter. The PMC contains the internal voltage regulator, power on reset (POR), and low voltage detect system. Mode Controller controls the PMC and its chapter contains description of all device resets, including POR.
  • Page 314: Lvd Reset Operation

    Low-Voltage Detect (LVD) System selectable trip voltage: high (V ) or low (V ). The trip voltage is selected by the LVDH LVDL LVDSC1[LVDV] bits. The LVD is disabled upon entering VLPx, LLS, and VLLSx modes. Two flags are available to indicate the status of the low-voltage detect system: •...
  • Page 315: Pmc Memory Map/Register Definition

    Chapter 14 Power Management Controller The LVDSC2[LVWV] bits select one of four trip voltages: • Highest (V LVW4 • Two mid-levels (V and V LVW3 LVW2 • Lowest (V LVW1 14.4 PMC Memory Map/Register Definition The following table shows the registers related to the PMC. Mode Control Memory Map/Register Definition for the mode controller registers.
  • Page 316: Low Voltage Detect Status And Control 2 Register (Pmc_Lvdsc2)

    PMC Memory Map/Register Definition Address: PMC_LVDSC1 is 4007_D000h base + 0h offset = 4007_D000h Read LVDF LVDIE LVDRE LVDV Write LVDACK Reset PMC_LVDSC1 field descriptions Field Description Low-Voltage Detect Flag LVDF This read-only status bit indicates a low-voltage detect event. Low-voltage event not detected Low-voltage event detected Low-Voltage Detect Acknowledge...
  • Page 317 Chapter 14 Power Management Controller See the device's data sheet for the exact LVD trip voltages. NOTE The LVW trip voltages depend on LVWV and LVDV bits. NOTE The reset value of this register depends on the reset type: • POR -- 0x00 •...
  • Page 318: Regulator Status And Control Register (Pmc_Regsc)

    PMC Memory Map/Register Definition 14.4.3 Regulator Status and Control Register (PMC_REGSC) The power management controller contains an internal voltage regulator. The voltage regulator design uses a bandgap reference, that is also available through a buffer as input to certain internal peripherals. The internal regulator provides a status bit (REGONS) indicating the regulator is in run regulation.
  • Page 319 Chapter 14 Power Management Controller PMC_REGSC field descriptions (continued) Field Description Bandgap Buffer Enable BGBE Enables the bandgap buffer. Bandgap buffer not enabled Bandgap buffer enabled K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 320 PMC Memory Map/Register Definition K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 321: Low-Leakage Wake-Up Unit (Llwu)

    Chapter 15 Low-leakage wake-up unit (LLWU) 15.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 7 internal modules as a wakeup source from low-leakage power modes (LLS and VLLS).
  • Page 322: Features

    Introduction 15.1.1 Features The LLWU module features include: • Supports up to 16 external input pins and up to 7 internal modules with individual enable bits • Input sources may be external pins or from internal peripherals capable of running in LLS or VLLS.
  • Page 323: Block Diagram

    Chapter 15 Low-leakage wake-up unit (LLWU) 15.1.2.2 VLLS modes The LLWU module provides up to 16 external wakeup inputs and up to seven internal module wakeup inputs. In addition, a VLLS reset event can be initiated via assertion of the RESET pin. All wakeup and reset events result in VLLS exit via a reset flow. 15.1.2.3 Non-low leakage modes The LLWU is not active in all non- LLS and VLLS modes where detection and control logic are in a static state.
  • Page 324: Llwu Signal Descriptions

    LLWU Signal Descriptions LLS/VLLS entered WUME7 LLWU_MWUF7 occurred Interrupt module Module7 interrupt flag flag detect (LLWU_M7IF) (System Error) WUME6 Internal LLWU_MWUF6 occurred Interrupt module Module6 interrupt flag module flag detect (LLWU_M6IF) sources LLWU_MWUF0 occurred Interrupt module Module0 interrupt flag flag detect (LLWU_M0IF) WUPE15 LLWU...
  • Page 325: Memory Map/Register Definition

    Chapter 15 Low-leakage wake-up unit (LLWU) 15.3 Memory map/register definition The LLWU includes the following registers: • Five 8-bit wakeup source enable registers • Enable external pin input sources • Enable internal peripheral sources • Three 8-bit wakeup flag registers •...
  • Page 326: Llwu Pin Enable 2 Register (Llwu_Pe2)

    Memory map/register definition Address: LLWU_PE1 is 4007_C000h base + 0h offset = 4007_C000h Read WUPE3 WUPE2 WUPE1 WUPE0 Write Reset LLWU_PE1 field descriptions Field Description 7–6 Wakeup Pin Enable for LLWU_P3 WUPE3 Enables and configures the edge detection for the wakeup pin. External input pin disabled as wakeup input External input pin enabled with rising edge detection External input pin enabled with falling edge detection...
  • Page 327 Chapter 15 Low-leakage wake-up unit (LLWU) NOTE This register is unaffected by wakeup from low leakage modes (exit from LLS via RESET or any exit from VLLS). Address: LLWU_PE2 is 4007_C000h base + 1h offset = 4007_C001h Read WUPE7 WUPE6 WUPE5 WUPE4 Write...
  • Page 328: Llwu Pin Enable 3 Register (Llwu_Pe3)

    Memory map/register definition 15.3.3 LLWU Pin Enable 3 Register (LLWU_PE3) LLWU_PE3 contains the bit field to enable and select the edge detect type for the external wakeup input pins LLWU_P11-LLWU_P8. NOTE This register is unaffected by wakeup from low leakage modes (exit from LLS via RESET or any exit from VLLS).
  • Page 329: Llwu Pin Enable 4 Register (Llwu_Pe4)

    Chapter 15 Low-leakage wake-up unit (LLWU) LLWU_PE3 field descriptions (continued) Field Description External input pin enabled with falling edge detection External input pin enabled with any change detection 15.3.4 LLWU Pin Enable 4 Register (LLWU_PE4) LLWU_PE4 contains the bit field to enable and select the edge detect type for the external wakeup input pins LLWU_P15-LLWU_P12.
  • Page 330: Llwu Module Enable Register (Llwu_Me)

    Memory map/register definition LLWU_PE4 field descriptions (continued) Field Description External input pin enabled with falling edge detection External input pin enabled with any change detection 1–0 Wakeup Pin Enable for LLWU_P12 WUPE12 Enables and configures the edge detection for the wakeup pin. External input pin disabled as wakeup input External input pin enabled with rising edge detection External input pin enabled with falling edge detection...
  • Page 331: Llwu Flag 1 Register (Llwu_F1)

    Chapter 15 Low-leakage wake-up unit (LLWU) LLWU_ME field descriptions (continued) Field Description Internal module flag not used as wakeup source Internal module flag used as wakeup source Wakeup Module Enable for Module 4 WUME4 Enables an internal module as a wakeup source input. Internal module flag not used as wakeup source Internal module flag used as wakeup source Wakeup Module Enable for Module 3...
  • Page 332 Memory map/register definition Address: LLWU_F1 is 4007_C000h base + 5h offset = 4007_C005h Read WUF7 WUF6 WUF5 WUF4 WUF3 WUF2 WUF1 WUF0 Write Reset LLWU_F1 field descriptions Field Description Wakeup Flag for LLWU_P7 WUF7 Indicates that an enabled external wakeup pin was a source of exiting LLS or VLLS. To clear the flag write a one to WUF7.
  • Page 333: Llwu Flag 2 Register (Llwu_F2)

    Chapter 15 Low-leakage wake-up unit (LLWU) LLWU_F1 field descriptions (continued) Field Description Wakeup Flag for LLWU_P1 WUF1 Indicates that an enabled external wakeup pin was a source of exiting LLS or VLLS. To clear the flag write a one to WUF1. LLWU_P1 input was not a source of wakeup from LLS or VLLS mode LLWU_P1 input was a source of wakeup from LLS or VLLS mode Wakeup Flag for LLWU_P0...
  • Page 334 Memory map/register definition LLWU_F2 field descriptions (continued) Field Description LLWU_P15 input was not a source of wakeup from LLS or VLLS mode LLWU_P15 input was a source of wakeup from LLS or VLLS mode Wakeup Flag for LLWU_P14 WUF14 Indicates that an enabled external wakeup pin was a source of exiting LLS or VLLS. To clear the flag write a one to WUF14.
  • Page 335: Llwu Flag 3 Register (Llwu_F3)

    Chapter 15 Low-leakage wake-up unit (LLWU) 15.3.8 LLWU Flag 3 Register (LLWU_F3) LLWU_F3 contains the wakeup flags indicating which internal wakeup source caused the MCU to exit LLS or VLLS mode. For LLS, this will be the source causing the CPU interrupt flow.
  • Page 336: Llwu Control And Status Register (Llwu_Cs)

    Memory map/register definition LLWU_F3 field descriptions (continued) Field Description Wakeup flag for module 4 MWUF4 Indicates that an enabled internal peripheral was a source of exiting LLS or VLLS. To clear the flag follow the internal peripheral flag clearing mechanism. Module 4 input was not a source of wakeup from LLS or VLLS mode Module 4 input was a source of wakeup from LLS or VLLS mode Wakeup flag for module 3...
  • Page 337: Functional Description

    Chapter 15 Low-leakage wake-up unit (LLWU) Address: LLWU_CS is 4007_C000h base + 8h offset = 4007_C008h Read ACKISO FLTEP FLTR Write Reset LLWU_CS field descriptions Field Description Acknowledge Isolation ACKISO Reading this bit indicates whether certain peripherals and the I/O pads are in a latched state as a result of having been in a VLLS mode.
  • Page 338: Lls Mode

    Functional description The LLWU implements an optional 3-cycle glitch filter, based on the LPO clock, such that a detected external pin is required to stay asserted until the enabled glitch filter times out. There is also 2 additional cycles of latency due to synchronization that results in a total of 5 cycles of delay before the detect circuit alerts the system to the wakeup or reset event when the filter function is enabled.
  • Page 339: Initialization

    Chapter 15 Low-leakage wake-up unit (LLWU) In the case of a wakeup due to external pin or internal module wakeup, the I/O states are held until software clears the ACKISO bit (by writing a 1 to it). Recovery is always via a system reset flow and the MC_SRS[WAKEUP] is set indicating the low leakage mode was active prior to the last system reset flow.
  • Page 340 Functional description K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 341: Miscellaneous Control Module (Mcm)

    Chapter 16 Miscellaneous Control Module (MCM) 16.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. 16.1.1 Features The MCM includes these distinctive features: •...
  • Page 342: Crossbar Switch (Axbs) Slave Configuration (Mcm_Plasc)

    Memory Map/Register Descriptions MCM memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) Crossbar switch (AXBS) master configuration E008_000A 003Fh 16.2.2/342 (MCM_PLAMC) E008_000C SRAM arbitration and protection (MCM_SRAMAP) 0000_0000h 16.2.3/343 E008_0010 Interrupt status register (MCM_ISR) 0000_0000h 16.2.4/344 E008_0014...
  • Page 343: Sram Arbitration And Protection (Mcm_Sramap)

    Chapter 16 Miscellaneous Control Module (MCM) MCM_PLAMC field descriptions Field Description 15–8 This read-only field is reserved and always has the value zero. Reserved 7–0 Each bit in the AMC field indicates if there is a corresponding connection to the AXBS master input port. A bus master connection to AXBS input port n is absent A bus master connection to AXBS input port n is present 16.2.3 SRAM arbitration and protection (MCM_SRAMAP)
  • Page 344: Interrupt Status Register (Mcm_Isr)

    Memory Map/Register Descriptions MCM_SRAMAP field descriptions (continued) Field Description Special round robin (favors SRAM backoor accesses over the processor) Fixed priority. Processor has highest, backdoor has lowest Fixed priority. Backdoor has highest, processor has lowest This read-only field is reserved and always has the value zero. Reserved SRAM_U write protect SRAMUWP...
  • Page 345: Etb Counter Control Register (Mcm_Etbcc)

    Chapter 16 Miscellaneous Control Module (MCM) MCM_ISR field descriptions (continued) Field Description Non-maskable interrupt pending If ETBCC[RSPT] is set to 10b, this bit is set when the ETB counter expires. No pending NMI Due to the ETB counter expiring, an NMI is pending Normal interrupt pending If ETBCC[RSPT] is set to 01b, this bit is set when the ETB counter expires.
  • Page 346: Etb Reload Register (Mcm_Etbrl)

    Memory Map/Register Descriptions MCM_ETBCC field descriptions (continued) Field Description If debug halt was enabled and a debug halt request was asserted on counter expiration, setting this bit clears the debug halt request. No effect Clears pending debug halt, NMI, or IRQ interrupt requests 2–1 Response type RSPT...
  • Page 347: Etb Counter Value Register (Mcm_Etbcnt)

    Chapter 16 Miscellaneous Control Module (MCM) 16.2.7 ETB counter value register (MCM_ETBCNT) Address: MCM_ETBCNT is E008_0000h base + 1Ch offset = E008_001Ch COUNTER Reset MCM_ETBCNT field descriptions Field Description 31–11 This read-only field is reserved and always has the value zero. Reserved 10–0 Byte count counter value...
  • Page 348 Functional Description 16.3.1.2 Normal interrupt The MCM's normal interrupt is generated if any of the following are true: • MCM_ISCR[ETBI] is set, which is caused by • The ETB counter is enabled (MCM_ETBCC[CNTEN] = 1), • The ETB count expires, and •...
  • Page 349: Crossbar Switch (Axbs)

    Chapter 17 Crossbar Switch (AXBS) 17.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.
  • Page 350: Memory Map / Register Definition

    Memory Map / Register Definition 17.2 Memory Map / Register Definition Each slave port of the crossbar switch contains configuration registers. Read- and write- transfers require two bus clock cycles. The registers can be read from and written to only in supervisor mode.
  • Page 351: Priority Registers Slave (Axbs_Prsn)

    Chapter 17 Crossbar Switch (AXBS) AXBS memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 4000_4600 Priority Registers Slave (AXBS_PRS6) 7654_3210h 17.2.1/351 4000_4610 Control Register (AXBS_CRS6) 0000_0000h 17.2.2/354 4000_4700 Priority Registers Slave (AXBS_PRS7) 7654_3210h 17.2.1/351 4000_4710...
  • Page 352 Memory Map / Register Definition • If the device contains less than five masters, values 000– 011 are valid and writing other values results in an error. • If the device contains n masters where n ≥ 5, values 0 to n-1 are valid and writing other values results in an error.
  • Page 353 Chapter 17 Crossbar Switch (AXBS) AXBS_PRSn field descriptions (continued) Field Description 22–20 Master 5 priority. Sets the arbitration priority for this port on the associated slave port. This master has level 1, or highest, priority when accessing the slave port. This master has level 2 priority when accessing the slave port.
  • Page 354: Control Register (Axbs_Crsn)

    Memory Map / Register Definition AXBS_PRSn field descriptions (continued) Field Description This read-only field is reserved and always has the value zero. Reserved 6–4 Master 1 priority. Sets the arbitration priority for this port on the associated slave port. This master has level 1, or highest, priority when accessing the slave port. This master has level 2 priority when accessing the slave port.
  • Page 355 Chapter 17 Crossbar Switch (AXBS) AXBS_CRSn field descriptions Field Description Read only Forces the slave port’s CSRn and PRSn registers to be read-only. After set, only a hardware reset clears The slave port’s registers are writeable The slave port’s registers are read-only and cannot be written. Attempted writes have no effect on the registers and result in a bus error response.
  • Page 356: Master General Purpose Control Register (Axbs_Mgpcrn)

    Memory Map / Register Definition AXBS_CRSn field descriptions (continued) Field Description Park on master port M1 Park on master port M2 Park on master port M3 Park on master port M4 Park on master port M5 Reserved Reserved 17.2.3 Master General Purpose Control Register (AXBS_MGPCRn) 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.
  • Page 357: Functional Description

    Chapter 17 Crossbar Switch (AXBS) AXBS_MGPCRn field descriptions (continued) Field Description Reserved Reserved Reserved 17.3 Functional Description 17.3.1 General operation When a master accesses the crossbar switch the access is immediately taken. If the targeted slave port of the access is available, then the access is immediately presented on the slave port.
  • Page 358: Register Coherency

    Functional Description The crossbar terminates all master IDLE transfers, as opposed to allowing the termination to come from one of the slave busses. 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.
  • Page 359 Chapter 17 Crossbar Switch (AXBS) MGPCR[AULB] Lost control Lost control No arbitration Arbitration allowed No arbitration No arbitration Master-to-slave transfer 1 beat 1 beat 12 beat burst Figure 17-28. Undefined length burst example 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.
  • Page 360 Functional Description When a master makes a request to a slave port, the slave port checks if the new requesting master's priority level is higher than that of the master that currently has control over the slave port, unless the slave port is in a parked state. The slave port performs an arbitration check at every clock edge to ensure that the proper master, if any, has control of the slave port.
  • Page 361: Initialization/Application Information

    Chapter 17 Crossbar Switch (AXBS) Parking may continue to be used in a round-robin mode, but does not affect the round- robin pointer unless the parked master actually performs a transfer. Handoff occurs to the next master in line after one cycle of arbitration. If the slave port is put into low-power park mode, the round-robin pointer is reset to point at master port 0, giving it the highest priority.
  • Page 362 Initialization/application information K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 363: Memory Protection Unit (Mpu)

    Chapter 18 Memory Protection Unit (MPU) 18.1 Introduction NOTE For the chip-specific implementation details of this module's instances see the chip configuration chapter. The Memory Protection Unit (MPU) provides hardware access control for all memory references generated in the device. 18.2 Overview The MPU concurrently monitors all system bus transactions and evaluates their appropriateness using pre-programmed region descriptors that define memory spaces and...
  • Page 364: Features

    Overview Slave Port n Internal Address Phase Signals Peripheral Bus Access Region Evaluation Descriptor 0 Macro Access Region Evaluation Descriptor 1 Macro Access Region Evaluation Descriptor x Macro MPU_EARn MPU_EDRn Figure 18-1. MPU Block Diagram 18.2.2 Features The MPU implements a two-dimensional hardware array of memory region descriptors and the crossbar slave ports to continuously monitor the legality of every memory reference generated by each bus master in the system.
  • Page 365: Memory Map/Register Definition

    Chapter 18 Memory Protection Unit (MPU) • Alternate programming model view of the access control permissions word • Priority given to granting permission over denying access for overlapping region descriptors • Detects access protection errors if a memory reference does not hit in any memory region, or if the reference is illegal in all hit memory regions.
  • Page 366 Memory Map/Register Definition MPU memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 4000_D020 Error Address Register, Slave Port n (MPU_EAR2) Undefined 18.3.2/370 4000_D024 Error Detail Register, Slave Port n (MPU_EDR2) Undefined 18.3.3/371 4000_D028 Error Address Register, Slave Port n (MPU_EAR3) Undefined...
  • Page 367 Chapter 18 Memory Protection Unit (MPU) MPU memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 4000_D46C Region Descriptor n, Word 3 (MPU_RGD6_WORD3) 0000_0000h 18.3.7/376 4000_D470 Region Descriptor n, Word 0 (MPU_RGD7_WORD0) 0000_0000h 18.3.4/372 4000_D474 Region Descriptor n, Word 1 (MPU_RGD7_WORD1)
  • Page 368: Control/Error Status Register (Mpu_Cesr)

    Memory Map/Register Definition MPU memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) Region Descriptor Alternate Access Control n 4000_D81C 0000_0000h 18.3.8/377 (MPU_RGDAAC7) Region Descriptor Alternate Access Control n 4000_D820 0000_0000h 18.3.8/377 (MPU_RGDAAC8) Region Descriptor Alternate Access Control n 4000_D824 0000_0000h...
  • Page 369 Chapter 18 Memory Protection Unit (MPU) MPU_CESR field descriptions (continued) Field Description 22–20 This read-only field is reserved and always has the value zero. Reserved 19–16 Hardware revision level Specifies the MPU’s hardware and definition revision level. It can be read by software to determine the functional definition of the module.
  • Page 370: Error Address Register, Slave Port N (Mpu_Earn)

    Memory Map/Register Definition 18.3.2 Error Address Register, Slave Port n (MPU_EARn) When the MPU detects an access error on slave port n, the 32-bit reference address is captured in this read-only register and the corresponding bit in CESR[SPERR] set. Additional information about the faulting access is captured in the corresponding EDRn at the same time.
  • Page 371: Error Detail Register, Slave Port N (Mpu_Edrn)

    Chapter 18 Memory Protection Unit (MPU) 18.3.3 Error Detail Register, Slave Port n (MPU_EDRn) When the MPU detects an access error on slave port n, 32 bits of error detail are captured in this read-only register and the corresponding bit in CESR[SPERR] is set. Information on the faulting address is captured in the corresponding EARn register at the same time.
  • Page 372: Region Descriptor N, Word 0 (Mpu_Rgdn_Word0)

    Memory Map/Register Definition MPU_EDRn field descriptions (continued) Field Description NOTE: All other encodings are reserved. User mode, instruction access User mode, data access Supervisor mode, instruction access Supervisor mode, data access Error read/write Indicates the access type of the faulting reference. Read Write 18.3.4 Region Descriptor n, Word 0 (MPU_RGD_WORD0)
  • Page 373: Region Descriptor N, Word 1 (Mpu_Rgdn_Word1)

    Chapter 18 Memory Protection Unit (MPU) 18.3.5 Region Descriptor n, Word 1 (MPU_RGD_WORD1) The second word of the region descriptor defines the 31-modulo-32 byte end address of the memory region. Writes to this register clear the region descriptor’s valid bit (RGDn_WORD3[VLD]).
  • Page 374 Memory Map/Register Definition Writes to RGDn_WORD2 clear the region descriptor’s valid bit (RGDn_WORD3[VLD]). If only updating the access controls, write to RGDAACn instead because stores to these locations do not affect the descriptor’s valid bit. Addresses: 4000_D000h base + 408h offset + (16d × n), where n = 0d to 11d M2SM M3SM M3UM...
  • Page 375 Chapter 18 Memory Protection Unit (MPU) MPU_RGDn_WORD2 field descriptions (continued) Field Description Bus master 4 reads terminate with an access error and the read is not performed Bus master 4 reads allowed Bus master 4 write enable M4WE Bus master 4 writes terminate with an access error and the write is not performed Bus master 4 writes allowed This field is reserved.
  • Page 376: Region Descriptor N, Word 3 (Mpu_Rgdn_Word3)

    Memory Map/Register Definition MPU_RGDn_WORD2 field descriptions (continued) Field Description See M3UM description 18.3.7 Region Descriptor n, Word 3 (MPU_RGD_WORD3) The fourth word of the region descriptor contains the region descriptor’s valid bit. Addresses: 4000_D000h base + 40Ch offset + (16d × n), where n = 0d to 11d Reset MPU_RGDn_WORD3 field descriptions Field...
  • Page 377: Region Descriptor Alternate Access Control N (Mpu_Rgdaacn)

    Chapter 18 Memory Protection Unit (MPU) 18.3.8 Region Descriptor Alternate Access Control n (MPU_RGDAACn) Since software may adjust only the access controls within a region descriptor (RGDn_WORD2) as different tasks execute, an alternate programming view of this 32- bit entity is available. Writing to this register does not affect the descriptor’s valid bit. Addresses: 4000_D000h base + 800h offset + (4d ×...
  • Page 378 Memory Map/Register Definition MPU_RGDAACn field descriptions (continued) Field Description Bus master 5 writes terminate with an access error and the write is not performed Bus master 5 writes allowed Bus master 4 read enable. M4RE Bus master 4 reads terminate with an access error and the read is not performed Bus master 4 reads allowed Bus master 4 write enable M4WE...
  • Page 379: Functional Description

    Chapter 18 Memory Protection Unit (MPU) MPU_RGDAACn field descriptions (continued) Field Description 4–3 Bus master 0 supervisor mode access control M0SM See M3SM description. 2–0 Bus master 0 user mode access control M0UM See M3UM description. 18.4 Functional Description In this section, the functional operation of the MPU is detailed, including the operation of the access evaluation macro and the handling of error-terminated bus cycles.
  • Page 380: Putting It All Together And Error Terminations

    Functional Description 18.4.1.1 Hit Determination To determine if the current reference hits in the given region, two magnitude comparators are used with the region's start and end addresses. The boolean equation for this portion of the hit determination is: region_hit = ((addr[31:5] >= RGDn_Word0[SRTADDR]) & (addr[31:5] <= RGDn_Word1[ENDADDR])) & RGDn_Word3[VLD] where addr is the current reference address, RGDn_Word0[SRTADDR] and RGDn_Word1[ENDADDR] are the start and end addresses, and RGDn_Word3[VLD] is...
  • Page 381: Power Management

    Chapter 18 Memory Protection Unit (MPU) 1. If the access does not hit in any region descriptor, a protection error is reported. 2. If the access hits in a single region descriptor and that region signals a protection violation, a protection error is reported. 3.
  • Page 382 Application Information • Creating a new memory region—Load the appropriate region descriptor into an available RGDn, using four sequential 32-bit writes. The hardware assists in the maintenance of the valid bit, so if this approach is followed, there are no coherency issues with the multi-cycle descriptor writes.
  • Page 383 Chapter 18 Memory Protection Unit (MPU) Table 18-81. Overlapping Region Descriptor Example (continued) Region Description RGDn DMA1 DMA2 CP0 data & stack — — — CP0 → CP1 shared data — — CP1 → CP0 shared data CP1 data & stack —...
  • Page 384 Application Information K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 385: Peripheral Bridge (Aips-Lite)

    Chapter 19 Peripheral Bridge (AIPS-Lite) 19.1 Introduction NOTE For the chip-specific implementation details of this module's instances see the chip configuration chapter. The peripheral bridge (AIPS-Lite) converts the crossbar switch interface to an interface to access a majority of peripherals on the device. The peripheral bridge supports up to 128 peripherals.
  • Page 386: Memory Map/Register Definition

    Memory map/register definition module address, transfer attributes, byte enables, and write data as inputs to the peripherals. The peripheral bridge captures read data from the peripheral interface and drives it to the crossbar switch. The register maps of the peripherals are located on 4 KB boundaries. Each peripheral is allocated one 4 KB block of the memory map.
  • Page 387: Master Privilege Register A (Aipsx_Mpra)

    Chapter 19 Peripheral Bridge (AIPS-Lite) AIPS memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 4000_0040 Peripheral Access Control Register (AIPS0_PACRE) Undefined 19.2.3/396 4000_0044 Peripheral Access Control Register (AIPS0_PACRF) Undefined 19.2.3/396 4000_0048 Peripheral Access Control Register (AIPS0_PACRG) Undefined 19.2.3/396 4000_004C...
  • Page 388 Memory map/register definition NOTE At reset, the default value loaded into the MPROT[7-0] fields is device-specific. See the Chip Configuration details for the value on your particular device. Accesses to registers or register fields which correspond to master or peripheral locations which are not implemented return zeros on reads, and are ignored on writes.
  • Page 389 Chapter 19 Peripheral Bridge (AIPS-Lite) AIPSx_MPRA field descriptions (continued) Field Description Master trusted for read MTR1 Determines whether the master is trusted for read accesses. This master is not trusted for read accesses. This master is trusted for read accesses. Master trusted for writes MTW1 Determines whether the master is trusted for write accesses.
  • Page 390 Memory map/register definition AIPSx_MPRA field descriptions (continued) Field Description This master is not trusted for write accesses. This master is trusted for write accesses. Master privilege level MPL3 Specifies how the privilege level of the master is determined. Accesses from this master are forced to user-mode. Accesses from this master are not forced to user-mode.
  • Page 391: Peripheral Access Control Register (Aipsx_Pacrn)

    Chapter 19 Peripheral Bridge (AIPS-Lite) AIPSx_MPRA field descriptions (continued) Field Description 3–0 This read-only field is reserved and always has the value zero. Reserved 19.2.2 Peripheral Access Control Register (AIPSx_PACRn) Each of the peripherals has a four-bit PACR[0:127] field which defines the access levels supported by the given module.
  • Page 392 Memory map/register definition Offset Register [31:28] [27:24] [23:20] [19:16] [15:12] [11:8] [7:4] [3:0] 0x60 PACRM PACR96 PACR97 PACR98 PACR99 PACR100 PACR101 PACR102 PACR103 0x64 PACRN PACR104 PACR105 PACR106 PACR107 PACR108 PACR109 PACR110 PACR111 0x68 PACRO PACR112 PACR113 PACR114 PACR115 PACR116 PACR117 PACR118 PACR119...
  • Page 393 Chapter 19 Peripheral Bridge (AIPS-Lite) AIPSx_PACRn field descriptions (continued) Field Description This read-only field is reserved and always has the value zero. Reserved Supervisor protect Determines whether the peripheral requires supervisor privilege level for access. When this bit is set, the master privilege level must indicate the supervisor access attribute , and the MPROTn[MPL] control bit for the master must be set.
  • Page 394 Memory map/register definition AIPSx_PACRn field descriptions (continued) Field Description Accesses from an untrusted master are allowed. Accesses from an untrusted master are not allowed. This read-only field is reserved and always has the value zero. Reserved Supervisor protect Determines whether the peripheral requires supervisor privilege level for access. When this bit is set, the master privilege level must indicate the supervisor access attribute , and the MPROTn[MPL] control bit for the master must be set.
  • Page 395 Chapter 19 Peripheral Bridge (AIPS-Lite) AIPSx_PACRn field descriptions (continued) Field Description Determines whether the peripheral allows accesses from an untrusted master. When this bit is set and an access is attempted by an untrusted master, the access terminates with an error response and no peripheral access initiates.
  • Page 396: Peripheral Access Control Register (Aipsx_Pacrn)

    Memory map/register definition AIPSx_PACRn field descriptions (continued) Field Description Trusted protect Determines whether the peripheral allows accesses from an untrusted master. When this bit is set and an access is attempted by an untrusted master, the access terminates with an error response and no peripheral access initiates .
  • Page 397 Chapter 19 Peripheral Bridge (AIPS-Lite) NOTE The reset value of the PACRE-P depends on your device's configuration. Addresses: 4000_0000h base + 40h offset + (4d × n), where n = 0d to 11d 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* Reset * Notes: •...
  • Page 398 Memory map/register definition AIPSx_PACRn field descriptions (continued) Field Description This peripheral does not require supervisor privilege level for accesses. This peripheral requires supervisor privilege level for accesses. Write protect 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.
  • Page 399 Chapter 19 Peripheral Bridge (AIPS-Lite) AIPSx_PACRn field descriptions (continued) Field Description the master must be set. If not, access terminates with an error response and no peripheral access initiates. This peripheral does not require supervisor privilege level for accesses. This peripheral requires supervisor privilege level for accesses. Write protect Determines whether the peripheral allows write accesss.
  • Page 400 Memory map/register definition AIPSx_PACRn field descriptions (continued) Field Description Determines whether the peripheral requires supervisor privilege level for access. When this bit is set, the master privilege level must indicate the supervisor access attribute , and the MPROTn[MPL] control bit for the master must be set.
  • Page 401: Functional Description

    Chapter 19 Peripheral Bridge (AIPS-Lite) AIPSx_PACRn field descriptions (continued) Field Description Supervisor protect Determines whether the peripheral requires supervisor privilege level for access. When this bit is set, the master privilege level must indicate the supervisor access attribute , and the MPROTn[MPL] control bit for the master must be set.
  • Page 402 Functional Description K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 403: Direct Memory Access Multiplexer (Dmamux)

    Chapter 20 Direct memory access multiplexer (DMAMUX) 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 DMA Mux routes up to 63 DMA sources (called slots) to be mapped to any of the 16 DMA channels.
  • Page 404: Features

    Introduction DMA Channel #0 DMAMUX Source #1 DMA Channel #1 Source #2 Source #3 Source #x Always #1 Always #y Trigger #1 DMA Channel #n Trigger #z Figure 20-1. DMA MUX block diagram 20.1.2 Features The DMA channel MUX provides these features: •...
  • Page 405: External Signal Description

    Chapter 20 Direct memory access multiplexer (DMAMUX) In this mode, the DMA channel is disabled. Since 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 (e.g.
  • Page 406: Channel Configuration Register (Dmamux_Chcfgn)

    Memory map/register definition DMAMUX memory map Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 4002_1000 Channel Configuration Register (DMAMUX_CHCFG0) 20.3.1/406 4002_1001 Channel Configuration Register (DMAMUX_CHCFG1) 20.3.1/406 4002_1002 Channel Configuration Register (DMAMUX_CHCFG2) 20.3.1/406 4002_1003 Channel Configuration Register (DMAMUX_CHCFG3) 20.3.1/406 4002_1004 Channel Configuration Register (DMAMUX_CHCFG4)
  • Page 407: Functional Description

    Chapter 20 Direct memory access multiplexer (DMAMUX) DMAMUX_CHCFGn field descriptions Field Description DMA Channel Enable ENBL Enables the DMA channel 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.
  • Page 408 Functional description such, the configuration of the periodic triggering interval is done via configuration registers in the PIT. Please refer to Periodic Interrupt Timer chapter for more information on this topic. Note Because of the dynamic nature of the system (i.e. DMA channel priorities, bus arbitration, interrupt service routine lengths, etc.), the number of clock cycles between a trigger and the actual DMA transfer cannot be guaranteed.
  • Page 409 Chapter 20 Direct memory access multiplexer (DMAMUX) Peripheral Request Trigger DMA Request Figure 20-20. DMA MUX channel triggering: normal operation Once 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.
  • Page 410: Dma Channels With No Triggering Capability

    Functional description 20.4.2 DMA channels with no triggering capability The other channels of the DMA MUX provide the normal routing functionality as described in Modes of operation. 20.4.3 "Always enabled" DMA sources In addition to the peripherals that can be used as DMA sources, there are 10 additional DMA sources that are "always enabled".
  • Page 411: Initialization/Application Information

    Chapter 20 Direct memory access multiplexer (DMAMUX) • Use explicit software re-activation. In this option, the DMA is configured to transfer the data using both minor and major loops, but the processor is required to re-activate the channel (by writing to the DMA registers) after every minor loop. For this option, the DMA channel should be disabled in the DMA channel MUX.
  • Page 412 Initialization/application information 3. Configure a timer for the desired trigger interval 4. Write 0xC5 to CHCFG2 (base address + 0x02) The following code example illustrates steps #1 and #4 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);...
  • Page 413 Chapter 20 Direct memory access multiplexer (DMAMUX) 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);...
  • Page 414 Initialization/application information 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);...
  • Page 415: Direct Memory Access Controller (Edma)

    Chapter 21 Direct Memory Access Controller (eDMA) 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.
  • Page 416: Block Parts

    Introduction eDMA Write Address Write Data Transfer Control Descriptor (TCD) eDMA Engine Program Model/ Read Data Channel Arbitration Read Data Address Path Control Data Path Write Data Address eDMA Peripheral eDMA Done Request Figure 21-1. eDMA block diagram 21.1.2 Block parts The eDMA module is partitioned into two major modules: the eDMA engine and the transfer-control descriptor local memory.
  • Page 417 Chapter 21 Direct Memory Access Controller (eDMA) Table 21-1. eDMA engine submodules Submodule Function Address path This block implements registered versions of two channel transfer control descriptors, channel x and channel y, and manages all master bus-address calculations. All the channels provide the same functionality.
  • Page 418: Features

    Introduction Table 21-2. Transfer control descriptor memory Submodule Description Memory controller This logic implements the required dual-ported controller, managing accesses from the eDMA engine as well as references from the internal peripheral bus. As noted earlier, in the event of simultaneous accesses, the eDMA engine is given priority and the peripheral transaction is stalled.
  • Page 419: Modes Of Operation

    Chapter 21 Direct Memory Access Controller (eDMA) • Channel completion reported via optional interrupt requests • One interrupt per channel, optionally asserted at completion of major iteration count • Optional error terminations per channel and logically summed together to form one error interrupt to the interrupt controller •...
  • Page 420 Memory map/register definition • The first region defines a number of registers providing control functions • The second region corresponds to the local transfer control descriptor memory Each channel requires a 32-byte transfer control descriptor for defining the desired data movement operation.
  • Page 421 Chapter 21 Direct Memory Access Controller (eDMA) DMA memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) (always 21.3.11/ 4000_801E Clear Error Register (DMA_CERR) reads zero) (always 21.3.12/ 4000_801F Clear Interrupt Request Register (DMA_CINT) reads zero) 21.3.13/...
  • Page 422 Memory map/register definition DMA memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 21.3.16/ 4000_810E Channel n Priority Register (DMA_DCHPRI13) Undefined 21.3.16/ 4000_810F Channel n Priority Register (DMA_DCHPRI12) Undefined 21.3.17/ 4000_9000 TCD Source Address (DMA_TCD0_SADDR) Undefined 21.3.18/ 4000_9004...
  • Page 423 Chapter 21 Direct Memory Access Controller (eDMA) DMA memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) TCD Minor Byte Count (Minor Loop Disabled) 21.3.20/ 4000_9028 Undefined (DMA_TCD1_NBYTES_MLNO) TCD Signed Minor Loop Offset (Minor Loop Enabled and 21.3.21/ 4000_9028 Undefined...
  • Page 424 Memory map/register definition DMA memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) TCD Signed Destination Address Offset 21.3.25/ 4000_9054 Undefined (DMA_TCD2_DOFF) TCD Current Minor Loop Link, Major Loop Count (Channel 21.3.26/ 4000_9056 Undefined Linking Enabled) (DMA_TCD2_CITER_ELINKYES) 21.3.27/...
  • Page 425 Chapter 21 Direct Memory Access Controller (eDMA) DMA memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) TCD Beginning Minor Loop Link, Major Loop Count 21.3.30/ 4000_907E (Channel Linking Enabled) Undefined (DMA_TCD3_BITER_ELINKYES) TCD Beginning Minor Loop Link, Major Loop Count 21.3.31/ 4000_907E (Channel Linking Disabled)
  • Page 426 Memory map/register definition DMA memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 21.3.19/ 4000_90A6 TCD Transfer Attributes (DMA_TCD5_ATTR) Undefined TCD Minor Byte Count (Minor Loop Disabled) 21.3.20/ 4000_90A8 Undefined (DMA_TCD5_NBYTES_MLNO) TCD Signed Minor Loop Offset (Minor Loop Enabled and 21.3.21/ 4000_90A8 Undefined...
  • Page 427 Chapter 21 Direct Memory Access Controller (eDMA) DMA memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 21.3.24/ 4000_90D0 TCD Destination Address (DMA_TCD6_DADDR) Undefined TCD Signed Destination Address Offset 21.3.25/ 4000_90D4 Undefined (DMA_TCD6_DOFF) TCD Current Minor Loop Link, Major Loop Count (Channel 21.3.26/ 4000_90D6...
  • Page 428 Memory map/register definition DMA memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 21.3.29/ 4000_90FC TCD Control and Status (DMA_TCD7_CSR) Undefined TCD Beginning Minor Loop Link, Major Loop Count 21.3.30/ 4000_90FE (Channel Linking Enabled) Undefined (DMA_TCD7_BITER_ELINKYES) TCD Beginning Minor Loop Link, Major Loop Count...
  • Page 429 Chapter 21 Direct Memory Access Controller (eDMA) DMA memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 21.3.18/ 4000_9124 TCD Signed Source Address Offset (DMA_TCD9_SOFF) Undefined 21.3.19/ 4000_9126 TCD Transfer Attributes (DMA_TCD9_ATTR) Undefined TCD Minor Byte Count (Minor Loop Disabled) 21.3.20/ 4000_9128...
  • Page 430 Memory map/register definition DMA memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) TCD Last Source Address Adjustment 21.3.23/ 4000_914C Undefined (DMA_TCD10_SLAST) 21.3.24/ 4000_9150 TCD Destination Address (DMA_TCD10_DADDR) Undefined TCD Signed Destination Address Offset 21.3.25/ 4000_9154 Undefined...
  • Page 431 Chapter 21 Direct Memory Access Controller (eDMA) DMA memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) TCD Last Destination Address Adjustment/Scatter Gather 21.3.28/ 4000_9178 Undefined Address (DMA_TCD11_DLASTSGA) 21.3.29/ 4000_917C TCD Control and Status (DMA_TCD11_CSR) Undefined TCD Beginning Minor Loop Link, Major Loop Count 21.3.30/...
  • Page 432 Memory map/register definition DMA memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 21.3.17/ 4000_91A0 TCD Source Address (DMA_TCD13_SADDR) Undefined 21.3.18/ 4000_91A4 TCD Signed Source Address Offset (DMA_TCD13_SOFF) Undefined 21.3.19/ 4000_91A6 TCD Transfer Attributes (DMA_TCD13_ATTR) Undefined TCD Minor Byte Count (Minor Loop Disabled) 21.3.20/...
  • Page 433 Chapter 21 Direct Memory Access Controller (eDMA) DMA memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) TCD Signed Minor Loop Offset (Minor Loop and Offset 21.3.22/ 4000_91C8 Undefined Enabled) (DMA_TCD14_NBYTES_MLOFFYES) TCD Last Source Address Adjustment 21.3.23/ 4000_91CC Undefined...
  • Page 434: Control Register (Dma_Cr)

    Memory map/register definition DMA memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 21.3.27/ 4000_91F6 DMA_TCD15_CITER_ELINKNO Undefined TCD Last Destination Address Adjustment/Scatter Gather 21.3.28/ 4000_91F8 Undefined Address (DMA_TCD15_DLASTSGA) 21.3.29/ 4000_91FC TCD Control and Status (DMA_TCD15_CSR) Undefined TCD Beginning Minor Loop Link, Major Loop Count 21.3.30/...
  • Page 435 Chapter 21 Direct Memory Access Controller (eDMA) DMA_CR field descriptions (continued) Field Description Normal operation Cancel the remaining data transfer. Stop the executing channel and force the minor loop to finish. The cancel takes effect after the last write of the current read/write sequence. The CX bit clears itself after the cancel has been honored.
  • Page 436: Error Status Register (Dma_Es)

    Memory map/register definition DMA_CR field descriptions (continued) Field Description When in debug mode, the DMA continues to operate. When in debug mode, the DMA stalls the start of a new channel. Executing channels are allowed to complete. Channel execution resumes when the system exits debug mode or the EDBG bit is cleared. This read-only field is reserved and always has the value zero.
  • Page 437 Chapter 21 Direct Memory Access Controller (eDMA) DMA_ES field descriptions (continued) Field Description This read-only field is reserved and always has the value zero. Reserved Channel Priority Error No channel priority error The last recorded error was a configuration error in the channel priorities. Channel priorities are not unique.
  • Page 438: Enable Request Register (Dma_Erq)

    Memory map/register definition DMA_ES field descriptions (continued) Field Description Source Bus Error No source bus error The last recorded error was a bus error on a source read Destination Bus Error No destination bus error The last recorded error was a bus error on a destination write 21.3.3 Enable Request Register (DMA_ERQ) The ERQ register provides a bit map for the 16 implemented channels to enable the request signal for each channel.
  • Page 439 Chapter 21 Direct Memory Access Controller (eDMA) DMA_ERQ field descriptions (continued) Field Description Enable DMA Request 13 ERQ13 The DMA request signal for the corresponding channel is disabled The DMA request signal for the corresponding channel is enabled Enable DMA Request 12 ERQ12 The DMA request signal for the corresponding channel is disabled The DMA request signal for the corresponding channel is enabled...
  • Page 440: Enable Error Interrupt Register (Dma_Eei)

    Memory map/register definition DMA_ERQ field descriptions (continued) Field Description The DMA request signal for the corresponding channel is disabled The DMA request signal for the corresponding channel is enabled Enable DMA Request 1 ERQ1 The DMA request signal for the corresponding channel is disabled The DMA request signal for the corresponding channel is enabled Enable DMA Request 0 ERQ0...
  • Page 441 Chapter 21 Direct Memory Access Controller (eDMA) DMA_EEI field descriptions (continued) Field Description Enable Error Interrupt 13 EEI13 The error signal for corresponding channel does not generate an error interrupt The assertion of the error signal for corresponding channel generates an error interrupt request Enable Error Interrupt 12 EEI12 The error signal for corresponding channel does not generate an error interrupt...
  • Page 442: Clear Enable Error Interrupt Register (Dma_Ceei)

    Memory map/register definition DMA_EEI field descriptions (continued) Field Description The error signal for corresponding channel does not generate an error interrupt The assertion of the error signal for corresponding channel generates an error interrupt request Enable Error Interrupt 1 EEI1 The error signal for corresponding channel does not generate an error interrupt The assertion of the error signal for corresponding channel generates an error interrupt request Enable Error Interrupt 0...
  • Page 443: Set Enable Error Interrupt Register (Dma_Seei)

    Chapter 21 Direct Memory Access Controller (eDMA) 21.3.6 Set Enable Error Interrupt Register (DMA_SEEI) 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.
  • Page 444: Clear Enable Request Register (Dma_Cerq)

    Memory map/register definition 21.3.7 Clear Enable Request Register (DMA_CERQ) 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.
  • Page 445: Set Enable Request Register (Dma_Serq)

    Chapter 21 Direct Memory Access Controller (eDMA) 21.3.8 Set Enable Request Register (DMA_SERQ) 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.
  • Page 446: Clear Done Status Bit Register (Dma_Cdne)

    Memory map/register definition 21.3.9 Clear DONE Status Bit Register (DMA_CDNE) 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.
  • Page 447: Set Start Bit Register (Dma_Ssrt)

    Chapter 21 Direct Memory Access Controller (eDMA) 21.3.10 Set START Bit Register (DMA_SSRT) 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.
  • Page 448: Clear Error Register (Dma_Cerr)

    Memory map/register definition 21.3.11 Clear Error Register (DMA_CERR) 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.
  • Page 449: Clear Interrupt Request Register (Dma_Cint)

    Chapter 21 Direct Memory Access Controller (eDMA) 21.3.12 Clear Interrupt Request Register (DMA_CINT) 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.
  • Page 450 Memory map/register definition 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.
  • Page 451 Chapter 21 Direct Memory Access Controller (eDMA) DMA_INT field descriptions (continued) Field Description The interrupt request for corresponding channel is cleared The interrupt request for corresponding channel is active Interrupt Request 10 INT10 The interrupt request for corresponding channel is cleared The interrupt request for corresponding channel is active Interrupt Request 9 INT9...
  • Page 452: Error Register (Dma_Err)

    Memory map/register definition 21.3.14 Error Register (DMA_ERR) The ERR provides a bit map for the 16 channels, signaling the presence of an error for each channel. The eDMA engine signals the occurrence of an error condition by setting the appropriate bit in this register. The outputs of this register are enabled by the contents of the EEI, and then routed to the interrupt controller.
  • Page 453 Chapter 21 Direct Memory Access Controller (eDMA) DMA_ERR field descriptions (continued) Field Description Error In Channel 15 ERR15 An error in the corresponding channel has not occurred An error in the corresponding channel has occurred Error In Channel 14 ERR14 An error in the corresponding channel has not occurred An error in the corresponding channel has occurred Error In Channel 13...
  • Page 454: Hardware Request Status Register (Dma_Hrs)

    Memory map/register definition DMA_ERR field descriptions (continued) Field Description An error in the corresponding channel has not occurred An error in the corresponding channel has occurred Error In Channel 3 ERR3 An error in the corresponding channel has not occurred An error in the corresponding channel has occurred Error In Channel 2 ERR2...
  • Page 455 Chapter 21 Direct Memory Access Controller (eDMA) DMA_HRS field descriptions Field Description 31–16 This read-only field is reserved and always has the value zero. Reserved Hardware Request Status Channel 15 HRS15 A hardware service request for the corresponding channel is not present A hardware service request for the corresponding channel is present Hardware Request Status Channel 14 HRS14...
  • Page 456: Channel N Priority Register (Dma_Dchprin)

    Memory map/register definition DMA_HRS field descriptions (continued) Field Description Hardware Request Status Channel 4 HRS4 A hardware service request for the corresponding channel is not present A hardware service request for the corresponding channel is present Hardware Request Status Channel 3 HRS3 A hardware service request for the corresponding channel is not present A hardware service request for the corresponding channel is present...
  • Page 457: Tcd Source Address (Dma_Tcdn_Saddr)

    Chapter 21 Direct Memory Access Controller (eDMA) DMA_DCHPRIn field descriptions (continued) Field Description Channel n cannot be suspended by a higher priority channel’s service request Channel n can be temporarily suspended by the service request of a higher priority channel Disable Preempt Ability Channel n can suspend a lower priority channel Channel n cannot suspend any channel, regardless of channel priority...
  • Page 458: Tcd Signed Source Address Offset (Dma_Tcdn_Soff)

    Memory map/register definition 21.3.18 TCD Signed Source Address Offset (DMA_TCD_SOFF) Addresses: 4000_8000h base + 1004h offset + (32d × n), where n = 0d to 15d Read SOFF Write Reset * Notes: • x = Undefined at reset. DMA_TCDn_SOFF field descriptions Field Description 15–0...
  • Page 459: Tcd Minor Byte Count (Minor Loop Disabled) (Dma_Tcdn_Nbytes_Mlno)

    Chapter 21 Direct Memory Access Controller (eDMA) DMA_TCDn_ATTR field descriptions (continued) Field Description 10–8 Source data transfer size SSIZE The attempted use of a Reserved encoding causes a configuration error. 8-bit 16-bit 32-bit Reserved 16-byte Reserved Reserved Reserved 7–3 Destination Address Modulo DMOD See the SMOD definition 2–0...
  • Page 460: Tcd Signed Minor Loop Offset (Minor Loop Enabled And Offset Disabled) (Dma_Tcdn_Nbytes_Mloffno)

    Memory map/register definition DMA_TCDn_NBYTES_MLNO field descriptions (continued) Field Description is exhausted, the SADDR and DADDR values are written back into the TCD memory, the major iteration count is decremented and restored to the TCD memory. If the major iteration count is completed, additional processing is performed.
  • Page 461: Tcd Signed Minor Loop Offset (Minor Loop And Offset Enabled)

    Chapter 21 Direct Memory Access Controller (eDMA) DMA_TCDn_NBYTES_MLOFFNO field descriptions (continued) Field Description As a channel activates, the appropriate TCD contents load into the eDMA engine, and the appropriate reads and writes perform until the minor byte transfer count has transferred. This is an indivisible operation and cannot be halted;...
  • Page 462: Tcd Last Source Address Adjustment (Dma_Tcdn_Slast)

    Memory map/register definition DMA_TCDn_NBYTES_MLOFFYES field descriptions (continued) Field Description 9–0 Minor Byte Transfer Count NBYTES Number of bytes to be transferred in each service request of the channel. As a channel activates, the appropriate TCD contents load into the eDMA engine, and the appropriate reads and writes perform until the minor byte transfer count has transferred.
  • Page 463: Tcd Signed Destination Address Offset (Dma_Tcdn_Doff)

    Chapter 21 Direct Memory Access Controller (eDMA) DMA_TCDn_DADDR field descriptions Field Description 31–0 Destination Address DADDR Memory address pointing to the destination data. 21.3.25 TCD Signed Destination Address Offset (DMA_TCD_DOFF) Addresses: 4000_8000h base + 1014h offset + (32d × n), where n = 0d to 15d Read DOFF Write...
  • Page 464: Tcd Current Minor Loop Link, Major Loop Count (Channel Linking Disabled) (Dma_Tcdn_Citer_Elinkno)

    Memory map/register definition DMA_TCDn_CITER_ELINKYES field descriptions Field Description Enable channel-to-channel linking on minor-loop complete ELINK As the channel completes the minor loop, this flag enables linking to another channel, defined by the LINKCH field. The link target channel initiates a channel service request via an internal mechanism that sets the TCDn_CSR[START] bit of the specified channel.
  • Page 465: Tcd Last Destination Address Adjustment/Scatter Gather Address (Dma_Tcdn_Dlastsga)

    Chapter 21 Direct Memory Access Controller (eDMA) DMA_TCDn_CITER_ELINKNO field descriptions Field Description Enable channel-to-channel linking on minor-loop complete ELINK As the channel completes the minor loop, this flag enables linking to another channel, defined by the LINKCH field. The link target channel initiates a channel service request via an internal mechanism that sets the TCDn_CSR[START] bit of the specified channel.
  • Page 466: Tcd Control And Status (Dma_Tcdn_Csr)

    Memory map/register definition DMA_TCDn_DLASTSGA field descriptions (continued) Field Description else • This address points to the beginning of a 0-modulo-32-byte region containing the next transfer control descriptor to be loaded into this channel. This channel reload is performed as the major iteration count completes.
  • Page 467 Chapter 21 Direct Memory Access Controller (eDMA) DMA_TCDn_CSR field descriptions (continued) Field Description • After the major loop counter is exhausted, the eDMA engine initiates a channel service request at the channel defined by these six bits by setting that channel’s TCDn_CSR[START] bit. Channel Done DONE This flag indicates the eDMA has completed the major loop.
  • Page 468: Tcd Beginning Minor Loop Link, Major Loop Count (Channel Linking Enabled) (Dma_Tcdn_Biter_Elinkyes)

    Memory map/register definition DMA_TCDn_CSR field descriptions (continued) Field Description The half-point interrupt is disabled The half-point interrupt is enabled Enable an interrupt when major iteration count completes INTMAJOR If this flag is set, the channel generates an interrupt request by setting the appropriate bit in the INT when the current major iteration count reaches zero.
  • Page 469: Tcd Beginning Minor Loop Link, Major Loop Count (Channel Linking Disabled)

    Chapter 21 Direct Memory Access Controller (eDMA) DMA_TCDn_BITER_ELINKYES field descriptions (continued) Field Description The channel-to-channel linking is disabled The channel-to-channel linking is enabled 14–13 This read-only field is reserved and always has the value zero. Reserved 12–9 Link Channel Number LINKCH If channel-to-channel linking is enabled (ELINK = 1), then after the minor loop is exhausted, the eDMA engine initiates a channel service request at the channel defined by these four bits by setting that...
  • Page 470: Functional Description

    Functional description DMA_TCDn_BITER_ELINKNO field descriptions (continued) Field Description value extends to 15 bits in place of a link channel number. If the major loop is exhausted, this link mechanism is suppressed in favor of the MAJORELINK channel linking. NOTE: When the software loads the TCD, this field must be set equal to the corresponding CITER field. Otherwise, a configuration error is reported.
  • Page 471 Chapter 21 Direct Memory Access Controller (eDMA) eDMA Write Address Write Data Transfer Control Descriptor (TCD) eDMA Engine Program Model/ Read Data Channel Arbitration Read Data Address Path Control Data Path Write Data Address eDMA Peripheral eDMA Done Request Figure 21-289. eDMA operation, part 1 This example uses the assertion of the eDMA peripheral request signal to request service for channel n.
  • Page 472 Functional description eDMA Write Address Write Data Transfer Control Descriptor (TCD) eDMA Engine Program Model/ Read Data Channel Arbitration Read Data Address Path Control Data Path Write Data Address eDMA Peripheral eDMA Done Request Figure 21-290. eDMA operation, part 2 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.
  • Page 473: Error Reporting And Handling

    Chapter 21 Direct Memory Access Controller (eDMA) eDMA Write Address Write Data Transfer Control Descriptor (TCD) 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 Figure 21-291.
  • Page 474 Functional description • 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.
  • Page 475: Channel Preemption

    Chapter 21 Direct Memory Access Controller (eDMA) 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.
  • Page 476 Functional description address spaces remains important. However, the microarchitecture of the eDMA also factors significantly into the resulting metric. 21.4.4.1 Peak transfer rates The peak transfer rates for several different source and destination transfers are shown in the following tables. These tables assume: •...
  • Page 477 Chapter 21 Direct Memory Access Controller (eDMA) The eDMA design supports the following hardware service request sequence: Table 21-293. Hardware service request process, cycles 1–7 Cycle Description eDMA peripheral request is asserted. The eDMA peripheral request is registered locally in the eDMA module and qualified.
  • Page 478 Functional description Table 21-294. Hardware service request process, cycles 8–17 (continued) Cycle Description With internal peripheral With SRAM read and bus read and internal internal peripheral bus SRAM write write The next channel to be activated performs the read of the first part of its TCD from the local memory.
  • Page 479 Chapter 21 Direct Memory Access Controller (eDMA) 21.4.4.3 eDMA performance example Consider a system with the following characteristics: • Internal SRAM can be accessed with one wait-state when viewed from the system bus data phase • All internal peripheral bus reads require two wait-states, and internal peripheral bus writes three wait-states viewed from the system bus data phase •...
  • Page 480: Initialization/Application Information

    Initialization/application information 21.5 Initialization/application information The following sections discuss initialization of the eDMA and programming considerations. 21.5.1 eDMA initialization A typical initialization of the eDMA has the following sequence: 1. Write the CR register if a configuration other than the default is desired. 2.
  • Page 481 Chapter 21 Direct Memory Access Controller (eDMA) Table 21-297. TCD Control and Status fields TCDn_CSR field Description name START Control bit to start channel explicitly when using a software initiated DMA service (Automatically cleared by hardware) ACTIVE Status bit indicating the channel is currently in execution DONE Status bit indicating major loop completion (cleared by software when using a software initiated DMA service)
  • Page 482: Programming Errors

    Initialization/application information xADDR: (Starting address) xSIZE: (size of one Minor loop data transfer) (NBYTES in minor loop, Offset (xOFF): number of bytes added to often the same current address after each transfer value as xSIZE) (often the same value as xSIZE) Each DMA source (S) and destination (D) has its own: Address (xADDR)
  • Page 483: Performing Dma Transfers

    Chapter 21 Direct Memory Access Controller (eDMA) 21.5.3.2 Round-robin channel arbitration Channels are serviced starting with the highest channel number and rotating through to the lowest channel number without regard to the channel priority levels. 21.5.4 Performing DMA transfers 21.5.4.1 Single request To perform a simple transfer of n bytes of data with one activation, set the major loop to one (TCDn_CITER = TCDn_BITER = 1).
  • Page 484 Initialization/application information 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.
  • Page 485 Chapter 21 Direct Memory Access Controller (eDMA) 2. The channel is selected by arbitration for servicing. 3. eDMA engine writes: TCDn_CSR[DONE] = 0, TCDn_CSR[START] = 0, TCDn_CSR[ACTIVE] = 1. 4. eDMA engine reads: channel TCDn data from local memory to internal register file. 5.
  • Page 486 Initialization/application information b. Write 32-bits to location 0x2010 → first iteration of the minor loop. c. Read byte from location 0x1014, read byte from location 0x1015, read byte from 0x1016, read byte from 0x1017. d. Write 32-bits to location 0x2014 → second iteration of the minor loop. e.
  • Page 487: Monitoring Transfer Descriptor Status

    Chapter 21 Direct Memory Access Controller (eDMA) Table 21-298. Modulo example (continued) Transfer Number Address 0x12345674 0x12345678 0x1234567C 0x12345670 0x12345674 21.5.5 Monitoring transfer descriptor status 21.5.5.1 Testing for minor loop completion There are two methods to test for minor loop completion when using software initiated service requests.
  • Page 488 Initialization/application information TCDn_CSR bits Stage State START ACTIVE DONE Channel service request via hardware (peripheral request asserted) Channel is executing Channel has completed the minor loop and is idle 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.
  • Page 489: Channel Linking

    Chapter 21 Direct Memory Access Controller (eDMA) 21.5.6 Channel Linking Channel linking (or chaining) is a mechanism where one channel sets the TCDn_CSR[START] bit of another channel (or itself), therefore initiating a service request for that channel. When properly enabled, the EDMA engine automatically performs this operation at the major or minor loop completion.
  • Page 490: Dynamic Programming

    Initialization/application information Table 21-299. Channel Linking Parameters Desired Link TCD Control Field Name Description Behavior Enable channel-to-channel linking on minor loop completion (current CITER[E_LINK] Link at end of iteration) Minor Loop CITER[LINKCH] Link channel number when linking at end of minor loop (current iteration) CSR[MAJOR_E_LINK] Enable channel-to-channel linking on major loop completion Link at end of...
  • Page 491 Chapter 21 Direct Memory Access Controller (eDMA) 1. Set the TCDn_CSR[MAJOR_E_LINK] bit. 2. Read back the TCDn_CSR[MAJOR_E_LINK] bit. 3. Test the TCDn_CSR[MAJOR_E_LINK] request status. a. If the bit is set, the dynamic link attempt was successful. b. If the bit is cleared, the attempted dynamic link did not succeed, the channel was already retiring.
  • Page 492 Initialization/application information K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 493: External Watchdog Monitor (Ewm)

    Chapter 22 External Watchdog Monitor (EWM) 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.
  • Page 494: Modes Of Operation

    Introduction • Windowed refresh option • Provides robust check that program flow is faster than expected. • Programmable window. • Refresh outside window leads to assertion of EWM_out. • Robust refresh mechanism • Write values of 0xB4 and 0x2C to EWM Refresh Register within 15 (EWM_service_time) peripheral bus clock cycles.
  • Page 495: Block Diagram

    Chapter 22 External Watchdog Monitor (EWM) 22.1.2.2 Wait Mode The EWM module treats the stop and wait modes as the same. EWM functionality remains the same in both of these modes. 22.1.2.3 Debug Mode Entry to debug mode has no effect on the EWM. •...
  • Page 496: Ewm Signal Descriptions

    EWM Signal Descriptions 22.2 EWM Signal Descriptions The EWM has two external signals, as shown in the following table. Table 22-1. EWM Signal Descriptions Signal Description EWM_in EWM input for safety status of external safety circuits. The polarity of EWM_in is programmable using the CTRL[ASSIN] bit. The default polarity is active-low.
  • Page 497: Service Register (Ewm_Serv)

    Chapter 22 External Watchdog Monitor (EWM) Address: EWM_CTRL is 4006_1000h base + 0h offset = 4006_1000h Read INEN ASSIN EWMEN Write Reset EWM_CTRL field descriptions Field Description 7–3 This read-only field is reserved and always has the value zero. Reserved Input Enable.
  • Page 498: Compare Low Register (Ewm_Cmpl)

    Memory Map/Register Definition 22.3.3 Compare Low Register (EWM_CMPL) The CMPL register is reset to zero after a CPU reset. This provides no minimum time for the CPU to service the EWM counter. NOTE This register can be written only once after a CPU reset. Writing this register more than once generates a bus transfer error.
  • Page 499: Functional Description

    Chapter 22 External Watchdog Monitor (EWM) EWM_CMPH field descriptions Field Description 7–0 To prevent runaway code from changing this field, software should write to this field after a CPU reset COMPAREH even if the (default) maximum service time is required. 22.4 Functional Description The following sections describe functional details of the EWM module.
  • Page 500: The Ewm_In Signal

    Functional Description Note EWM_out pad must be in pull down state when EWM functionality is used and when EWM is under Reset. 22.4.2 The EWM_in Signal The EWM_in is a digital input signal that allows an external circuit to control the EWM_out signal.
  • Page 501: Ewm Refresh Mechanism

    Chapter 22 External Watchdog Monitor (EWM) The EWM compare registers are used to create a service window, which is used by the CPU to service/refresh the EWM module. • If the CPU services the EWM when the counter value lies between CMPL value and CMPH value, the counter is reset to zero.
  • Page 502 Functional Description K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 503: Watchdog Timer (Wdog)

    Chapter 23 Watchdog Timer (WDOG) 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. Some reasons for such failures are: run-away software code and the stoppage of the system clock that in a safety critical system can lead to serious consequences.
  • Page 504 Features • 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. •...
  • Page 505: Functional Overview

    Chapter 23 Watchdog Timer (WDOG) 23.3 Functional Overview WDOG Disable Control/Configuration Unlock Sequence bit changes N bus clk cycles after 2 Writes of data within K bus clock unlocking cycles of each other Refresh Sequence 2 writes of data within K 0xC520 bus clock cycles of each N bus clk cycles...
  • Page 506: Unlocking And Updating The Watchdog

    Functional Overview 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.
  • Page 507: The Watchdog Configuration Time (Wct)

    Chapter 23 Watchdog Timer (WDOG) 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 bother with frequently servicing the watchdog.
  • Page 508: Refreshing The Watchdog

    Functional Overview Updates in the write–once registers take effect only after the WCT window closes with the following exceptions for which changes take effect immediately: • the stop, wait, and debug mode enable bits • the standby mode enable bit •...
  • Page 509: Low Power Modes Of Operation

    Chapter 23 Watchdog Timer (WDOG) non-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. 23.3.6 Low Power Modes of Operation • In Wait mode, if the WDOG is enabled (WAIT_EN = 1), it can run on bus clock or low power oscillator clock (CLK_SRC = x) to generate interrupt (IRQ_RST_EN=1) followed by a reset on time-out.
  • Page 510: Testing The Watchdog

    Testing the Watchdog The entry into Debug mode within WCT time after reset is treated differently. The WDOG timer is kept reset to zero and there is no need to unlock and configure it within WCT time. You must not try to refresh or unlock the WDOG in this state or unknown behavior may result.
  • Page 511 Chapter 23 Watchdog Timer (WDOG) 23.4.2 Byte Test The byte test implements more thorough a test of the watchdog timer. In this test, the timer is split up into its constituent byte-wide stages that are run independently and tested for time-out against the corresponding byte of the time-out value register. The following figure explains the splitting concept: Reset Value (Hardwired) Modulus Register...
  • Page 512: Backup Reset Generator

    Backup Reset Generator Note Do not enable the watchdog interrupt during these tests. If required, you must ensure that the effective time-out value is greater than WCT time. See Generated Resets and Interrupts more details. 23.5 Backup Reset Generator The backup reset generator generates the final reset which goes out to the system. It has a backup mechanism which takes care that in case the bus clock stops and prevents the main state machine from generating a reset exception/interrupt, the watchdog timer's time-out is separately routed out as a reset to the system.
  • Page 513: Memory Map And Register Definition

    Chapter 23 Watchdog Timer (WDOG) • A gap of more than 20 bus cycles exists between the writes of two values of the unlock sequence. • A gap of more than 20 bus cycles exists between the writes of two values of the refresh sequence.
  • Page 514: Watchdog Status And Control Register High (Wdog_Stctrlh)

    Memory Map and Register Definition WDOG memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 23.7.8/ 4005_200E Watchdog Unlock Register (WDOG_UNLOCK) D928h 23.7.9/ 4005_2010 Watchdog Timer Output Register High (WDOG_TMROUTH) 0000h 23.7.10/ 4005_2012 Watchdog Timer Output Register Low (WDOG_TMROUTL) 0000h 23.7.11/...
  • Page 515 Chapter 23 Watchdog Timer (WDOG) WDOG_STCTRLH field descriptions (continued) Field Description Quick test. The timer runs in normal operation. You can load a small time-out value to do a quick test. Byte test. Puts the timer in the byte test mode where individual bytes of the timer are enabled for operation and are compared for time-out against the corresponding byte of the programmed time-out value.
  • Page 516: Watchdog Status And Control Register Low (Wdog_Stctrll)

    Memory Map and Register Definition WDOG_STCTRLH field descriptions (continued) Field Description WDOG is disabled. WDOG is enabled. 23.7.2 Watchdog Status and Control Register Low (WDOG_STCTRLL) Address: WDOG_STCTRLL is 4005_2000h base + 2h offset = 4005_2002h Read Reserved Write Reset WDOG_STCTRLL field descriptions Field Description Interrupt flag.
  • Page 517: Watchdog Time-Out Value Register Low (Wdog_Tovall)

    Chapter 23 Watchdog Timer (WDOG) 23.7.4 Watchdog Time-out Value Register Low (WDOG_TOVALL) The time-out value of the watchdog must be set to a minimum of four watchdog clock cycles. This is to take into account the delay in new settings taking effect in the watchdog clock domain.
  • Page 518: Watchdog Window Register Low (Wdog_Winl)

    Memory Map and Register Definition 23.7.6 Watchdog Window Register Low (WDOG_WINL) You must set the Window Register value lower than the Time-out Value Register. Address: WDOG_WINL is 4005_2000h base + Ah offset = 4005_200Ah Read WINLOW Write Reset WDOG_WINL field descriptions Field Description 15–0...
  • Page 519: Watchdog Timer Output Register High (Wdog_Tmrouth)

    Chapter 23 Watchdog Timer (WDOG) WDOG_UNLOCK field descriptions Field Description 15–0 You can write the unlock sequence values to this register to make the watchdog write once registers WDOGUNLOCK writable again. The required unlock sequence is 0xC520 followed by 0xD928 within 20 bus clock cycles. A valid unlock sequence opens up a window equal in length to the WCT within which you can update the registers.
  • Page 520: Watchdog Reset Count Register (Wdog_Rstcnt)

    Watchdog Operation with 8-bit access 23.7.11 Watchdog Reset Count Register (WDOG_RSTCNT) Address: WDOG_RSTCNT is 4005_2000h base + 14h offset = 4005_2014h Read RSTCNT Write Reset WDOG_RSTCNT field descriptions Field Description 15–0 Counts the number of times the watchdog resets the system. This register is reset only on a POR. Writing RSTCNT 1 to the bit to be cleared, enables you to clear the contents of this register.
  • Page 521: General Guideline

    Chapter 23 Watchdog Timer (WDOG) 23.8.1 General Guideline When performing 8-bit accesses to the watchdog's 16-bit registers where the intention is to access both the bytes of a register, you must try to place the two 8-bit accesses one after the other in your code. 23.8.2 Refresh and Unlock operations with 8-bit access One exception condition that generates a reset to the system, is the write of any value other than those required for a legal refresh/update sequence to the respective refresh and...
  • Page 522: Restrictions On Watchdog Operation

    Restrictions on Watchdog Operation 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.
  • Page 523 Chapter 23 Watchdog Timer (WDOG) • The time-out value of the watchdog should be set to a minimum of four watchdog clock cycles. This is to take into account the delay in new settings taking effect in the watchdog clock domain. •...
  • Page 524 Restrictions on Watchdog Operation K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 525: Multipurpose Clock Generator (Mcg)

    Chapter 24 Multipurpose Clock Generator (MCG) 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).
  • Page 526 Introduction • Internal or external reference clock can be used as the FLL source. • Can be used as a clock source for other on-chip peripherals. • Phase-locked loop (PLL) • Voltage-controlled oscillator (VCO) • External reference clock is used as the PLL source •...
  • Page 527 Chapter 24 Multipurpose Clock Generator (MCG) • 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 •...
  • Page 528 Introduction Crystal Oscillator External Reference Clock CLKS OSCINIT PLLCLKEN MCG Crystal Oscillator Enable Detect EREFS IREFS PLLS ATMS RANGE STOP IREFSTEN Auto Trim Machine IRCLKEN MCGIRCLK SCTRIM IRCS Internal CLKS CLKS Reference SCFTRIM Slow Clock Clock IRCSCLK Generator Fast Clock FCTRIM MCGOUTCLK MCGFLLCLK...
  • Page 529: Modes Of Operation

    Chapter 24 Multipurpose Clock Generator (MCG) 24.1.2 Modes of Operation There are nine modes of operation for the MCG: FEI, FEE, FBI, FBE, PBE, PEE, BLPI, BLPE, and Stop. For details, see MCG Modes of Operation. 24.2 External Signal Description There are no MCG signals that connect off chip.
  • Page 530: Mcg Control 1 Register (Mcg_C1)

    Memory Map/Register Definition 24.3.1 MCG Control 1 Register (MCG_C1) Address: MCG_C1 is 4006_4000h base + 0h offset = 4006_4000h Read CLKS FRDIV IREFS IRCLKEN IREFSTEN Write Reset MCG_C1 field descriptions Field Description 7–6 Clock Source Select CLKS Selects the clock source for MCGOUTCLK . Encoding 0 —...
  • Page 531: Mcg Control 2 Register (Mcg_C2)

    Chapter 24 Multipurpose Clock Generator (MCG) MCG_C1 field descriptions (continued) Field Description Internal reference clock is disabled in Stop mode. Internal reference clock is enabled in Stop mode if IRCLKEN is set or if MCG is in FEI, FBI, or BLPI modes before entering Stop mode.
  • Page 532: Mcg Control 3 Register (Mcg_C3)

    Memory Map/Register Definition MCG_C2 field descriptions (continued) Field Description FLL (or PLL) is not disabled in bypass modes. FLL (or PLL) is disabled in bypass modes (lower power) Internal Reference Clock Select IRCS Selects between the fast or slow internal reference clock source. Slow internal reference clock selected.
  • Page 533: Mcg Control 4 Register (Mcg_C4)

    Chapter 24 Multipurpose Clock Generator (MCG) 24.3.4 MCG Control 4 Register (MCG_C4) Reset values for DRST and DMX32 bits are 0. Address: MCG_C4 is 4006_4000h base + 3h offset = 4006_4003h Read DMX32 DRST_DRS FCTRIM SCFTRIM Write Reset * Notes: •...
  • Page 534: Mcg Control 5 Register (Mcg_C5)

    Memory Map/Register Definition MCG_C4 field descriptions (continued) Field Description Encoding 2 — Mid-high range. Encoding 3 — High range. 4–1 Fast Internal Reference Clock Trim Setting FCTRIM FCTRIM controls the fast internal reference clock frequency by controlling the fast internal reference clock period.
  • Page 535 Chapter 24 Multipurpose Clock Generator (MCG) MCG_C5 field descriptions (continued) Field Description MCGPLLCLK is inactive. MCGPLLCLK is active. PLL Stop Enable PLLSTEN Enables the PLL Clock during Normal Stop (In Low Power Stop mode, the PLL clock gets disabled even if PLLSTEN =1). All other power modes, PLLSTEN bit has no affect and does not enable the PLL Clock to run if it is written to 1.
  • Page 536: Mcg Control 6 Register (Mcg_C6)

    Memory Map/Register Definition 24.3.6 MCG Control 6 Register (MCG_C6) Address: MCG_C6 is 4006_4000h base + 5h offset = 4006_4005h Read PLLS VDIV LOLIE Write Reset MCG_C6 field descriptions Field Description Loss of Lock Interrrupt Enable LOLIE Determines if an interrupt request is made following a loss of lock indication. This bit only has an effect when LOLS is set.
  • Page 537: Mcg Status Register (Mcg_S)

    Chapter 24 Multipurpose Clock Generator (MCG) MCG_C6 field descriptions (continued) Field Description Table 24-9. PLL VCO Divide Factor (continued) 00001 01001 10001 11001 00010 01010 10010 11010 00011 01011 10011 11011 00100 01100 10100 11100 00101 01101 10101 11101 00110 01110 10110 11110...
  • Page 538 Memory Map/Register Definition MCG_S field descriptions (continued) Field Description While the PLL clock is locking to the desired frequency, the MCG PLL clock (MCGPLLCLK) will be gated off until the LOCK bit gets asserted. If the lock status bit is set, changing the value of the PRDIV [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.
  • Page 539: Mcg Auto Trim Control Register (Mcg_Atc)

    Chapter 24 Multipurpose Clock Generator (MCG) 24.3.8 MCG Auto Trim Control Register (MCG_ATC) Address: MCG_ATC is 4006_4000h base + 8h offset = 4006_4008h Read ATMF ATME ATMS Write Reset MCG_ATC field descriptions Field Description Automatic Trim Machine Enable ATME Enables the Auto Trim Machine to start automatically trimming the selected Internal Reference Clock. NOTE: ATME deasserts after the Auto Trim Machine has completed trimming all trim bits of the IRCS clock selected by the ATMS bit.
  • Page 540: Mcg Auto Trim Compare Value Low Register (Mcg_Atcvl)

    Functional Description MCG_ATCVH field descriptions Field Description 7–0 ATM Compare Value High ATCVH Values are used by Auto Trim Machine to compare and adjust Internal Reference trim values during ATM SAR conversion. 24.3.10 MCG Auto Trim Compare Value Low Register (MCG_ATCVL) Address: MCG_ATCVL is 4006_4000h base + Bh offset = 4006_400Bh Read ATCVL...
  • Page 541 Chapter 24 Multipurpose Clock Generator (MCG) Reset BLPE BLPI Returns to the state that was active before Entered from any state when the MCU entered Stop mode, unless a the MCU enters Stop mode Stop reset occurs while in Stop mode. Figure 24-12.
  • Page 542 Functional Description Table 24-14. MCG Modes of Operation Mode Description FLL Engaged Internal FLL engaged internal (FEI) is the default mode of operation and is entered when all the following (FEI) condtions occur: • C1[CLKS] bits are written to 00 •...
  • Page 543 Chapter 24 Multipurpose Clock Generator (MCG) Table 24-14. MCG Modes of Operation (continued) Mode Description 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 •...
  • Page 544 Functional Description Table 24-14. MCG Modes of Operation (continued) Mode Description 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 •...
  • Page 545: Low Power Bit Usage

    Chapter 24 Multipurpose Clock Generator (MCG) 24.4.1.2 MCG Mode Switching The C1[IREFS] bit can be changed at any time, but the actual switch to the newly selected reference clocks is shown by the S[IREFST] bit. When switching between engaged internal and engaged external modes, the FLL will begin locking again after the switch is completed.
  • Page 546: External Reference Clock

    Functional Description selected or by writing a new trim value to the C4[FCTRIM] bits when the fast IRC clock is selected. The internal reference clock period is proportional to the trim value written. C3[SCTRIM]:C4[SCFTRIM] (if C2[IRCS]=0) and C4[FCTRIM] (if C2[IRCS]=1) bits affect the MCGOUTCLK frequency if the MCG is in FBI or BLPI modes.
  • Page 547: Mcg Pll Clock

    Chapter 24 Multipurpose Clock Generator (MCG) 24.4.6 MCG PLL Clock The MCG PLL Clock (MCGPLLCLK) is available depending on the device's configuration of the MCG module. For more details, refer to the clock distribution chapter of this MCU. The MCGPLLCLK is prevented from coming out of the MCG until it is enabled and S[LOCK] is set.
  • Page 548: Initialization / Application Information

    Initialization / Application Information Before the ATM can be enabled, the ATM expected count needs to get derived and stored into the ATCV register. The ATCV expected count is derived based on the required target Internal Reference Clock (IRC) frequency, the frequency of the external reference clock, and using the following formula: ATCV •...
  • Page 549 Chapter 24 Multipurpose Clock Generator (MCG) 2. Write to C1 register to select the clock mode. • If entering FEE mode, set C1[FRDIV] appropriately, clear the C1[IREFS] bit to switch to the external reference, and leave the C1[CLKS] bits at 2'b00 so that the output of the FLL is selected as the system clock source.
  • Page 550: Using A 32.768 Khz Reference

    Initialization / Application Information • 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.
  • Page 551: Mcg Mode Switching

    Chapter 24 Multipurpose Clock Generator (MCG) 24.5.2 Using a 32.768 kHz Reference In FEE and FBE modes, if using a 32.768 kHz external reference, at the default FLL multiplication factor of 640, the DCO output (MCGFLLCLK) frequency is 20.97 MHz at low-range.
  • Page 552 Initialization / Application Information Table 24-15. MCGOUTCLK Frequency Calculation Options Clock Mode Note MCGOUTCLK FEI (FLL engaged internal) * F) Typical f = 20 MHz MCGOUTCLK immediately after reset. FEE (FLL engaged external) / FLL_R) *F / FLL_R must be in the range of 31.25 kHz to 39.0625 kHz FBE (FLL bypassed external) / FLL_R must be in the range of...
  • Page 553 Chapter 24 Multipurpose Clock Generator (MCG) • C1[CLKS] set to 2'b10 in order to select external reference clock as system clock source • C1[FRDIV] set to 3'b010, or divide-by-128 because 4 MHz / 128 = 31.25 kHz which is in the 31.25 kHz to 39.0625 kHz range required by the FLL •...
  • Page 554 Initialization / Application Information e. PBE: Then loop until S[LOCK] is set, indicating that the PLL has acquired lock. 4. Lastly, PBE mode transitions into PEE mode: a. C1 = 0x10 • C1[CLKS] set to 2'b00 in order to select the output of the PLL as the system clock source.
  • Page 555 Chapter 24 Multipurpose Clock Generator (MCG) START IN FEI MODE C6 = 0x40 C2 = 0x1C BLPE MODE ? (S[LP]=1) C1 = 0x90 C2 = 0x1C (S[LP]=0) CHECK S[OSCINIT] = 1? CHECK S[PLLST] = 1? CHECK S[IREFST] = 0? CHECK S[LOCK] = 1? CHECK S[CLKST] = %10?
  • Page 556 Initialization / Application Information 24.5.3.2 Example 2: Moving from PEE to BLPI Mode: MCGOUTCLK Frequency =32 kHz In this example, the MCG will move through the proper operational modes from PEE mode with a 4 MHz crystal configured for a 48 MHz MCGOUTCLK frequency (see previous example) to BLPI mode with a 32 kHz MCGOUTCLK frequency.First, the code sequence will be described.
  • Page 557 Chapter 24 Multipurpose Clock Generator (MCG) • C1[CLKS] set to 2'b01 in order to switch the system clock to the internal reference clock. • C1[IREFS] set to 1 to select the internal reference clock as the reference clock source. • C1[FRDIV] remain unchanged because the reference divider does not affect the internal reference.
  • Page 558 Initialization / Application Information START IN PEE MODE C1 = 0x90 CHECK S[PLLST] = 0? CHECK S[CLKST] = %10 ? C1 = 0x54 ENTER CHECK BLPE MODE ? S[IREFST] = 0? C2 = 0x1E (C2[LP] = 1) CHECK S[CLKST] = %01? C6 = 0x00 C2 = 0x02 BLPE MODE ?
  • Page 559 Chapter 24 Multipurpose Clock Generator (MCG) 24.5.3.3 Example 3: Moving from BLPI to FEE Mode In this example, the MCG will move through the proper operational modes from BLPI mode at a 32 kHz MCGOUTCLK frequency running off the internal reference clock (see previous example) to FEE mode using a 4 MHz crystal configured for a 20 MHz MCGOUTCLK frequency.
  • Page 560 Initialization / Application Information multiplication factor from 640 to 1280. To return the MCGOUTCLK frequency to 20 MHz, set C4[DRST_DRS] bits to 2'b00 again, and the FLL multiplication factor will switch back to 640. START IN BLPI MODE CHECK S[IREFST] = 0? C2 = 0x00 C2 = 0x1C CHECK...
  • Page 561: Oscillator (Osc)

    Chapter 25 Oscillator (OSC) 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. 25.2 Features and Modes Key features of the module are: •...
  • Page 562: Block Diagram

    Block Diagram 25.3 Block Diagram The OSC module uses a crystal or resonator to generate three filtered oscillator clock signals. Three clocks are output from OSC module: OSCCLK for MCU system, OSCERCLK for on-chip peripherals, and OSC32KCLK. The OSCCLK can only work in run mode.
  • Page 563: External Crystal / Resonator Connections

    Chapter 25 Oscillator (OSC) Table 25-1. OSC Signal Descriptions Signal Description EXTAL External clock/Oscillator input XTAL Oscillator output 25.5 External Crystal / Resonator Connections The connections for a crystal/resonator frequency reference are shown in the following figures. When using low-frequency, low-power mode, the only external component is the crystal or ceramic resonator itself.
  • Page 564: External Clock Connections

    External Clock Connections XTAL EXTAL Crystal or Resonator Figure 25-3. Crystal/Ceramic Resonator Connections - Connection 2 NOTE Connection 1 and Connection 2 should use internal capacitors as the load of the oscillator by configuring the CR[SCxP] bits. XTAL EXTAL Crystal or Resonator Figure 25-4.
  • Page 565: Memory Map/Register Definitions

    Chapter 25 Oscillator (OSC) XTAL EXTAL Clock Input Figure 25-5. External Clock Connections 25.7 Memory Map/Register Definitions Some oscillator module register bits are typically incorporated into other peripherals such as MCG or SIM. 25.7.1 OSC Memory Map/Register Definition OSC memory map Absolute Width Section/...
  • Page 566: Functional Description

    Functional Description OSC_CR field descriptions (continued) Field Description External reference clock is inactive. External reference clock is enabled. This read-only field is reserved and always has the value zero. Reserved External Reference Stop Enable EREFSTEN Controls whether or not the external reference clock (OSCERCLK) remains enabled when MCU enters Stop mode.
  • Page 567: Osc Module States

    Chapter 25 Oscillator (OSC) 25.8.1 OSC Module States The states of the OSC module are shown in the following figure. The states and their transitions between each other are described in this section. Oscillator OFF OSCCLK OSC_CLK_OUT = Static not requested OSCCLK requested OSCCLK requested &&...
  • Page 568: Osc Module Modes

    Functional Description 25.8.1.2 Oscillator Start-Up The OSC enters start-up state when it is configured to generate clocks (internally the OSC_EN transitions high) using the internal oscillator circuits by setting the external reference clock selection bit. In this state, the OSC module is enabled and oscillations are starting up, but have not yet stabilized.
  • Page 569 Chapter 25 Oscillator (OSC) Table 25-5. Oscillator Modes Mode Frequency Range Low-frequency, high-gain (1 kHz) up to f (32.768 kHz) osc_lo osc_lo Low-frequency, low-power (VLP) High-frequency mode1, high-gain (3 MHz) up to f (8 MHz) osc_hi_1 osc_hi_1 High-frequency mode1, low-power High-frequency mode2, high-gain (8 MHz) up to f (32 MHz)
  • Page 570: Counter

    Reset 25.8.2.3 High-Frequency, High-Gain Mode In high-frequency, high-gain mode, the oscillator uses a simple inverter-style amplifier. The gain is set to achieve rail-to-rail oscillation amplitudes. This mode provides low pass frequency filtering as well as hysteresis for voltage filtering and converts the output to logic levels.
  • Page 571: Low Power Modes Operation

    Chapter 25 Oscillator (OSC) 25.10 Low Power Modes Operation When the MCU enters Stop modes, the OSC is functional depending on ERCLKEN and EREFSETN bit settings. If both these bits are set, the OSC is in operation. In Low Leakage Stop (LLS) modes, the OSC holds all register settings. If ERCLKEN and EREFSTEN bits are set before entry to Low Leakage Stop modes, the OSC is still functional in these modes.
  • Page 572 Interrupts K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 573: Rtc Oscillator

    Chapter 26 RTC Oscillator 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. 26.1.1 Features and Modes The key features of the RTC oscillator are as follows: •...
  • Page 574: Rtc Signal Descriptions

    RTC Signal Descriptions control Amplitude clk out for RTC EXTAL32 detector XTAL32 Figure 26-1. RTC Oscillator Block Diagram 26.2 RTC Signal Descriptions The following table shows the user-accessible signals available for the RTC oscillator. See the chip-level specification to find out which signals are actually connected to the external pins.
  • Page 575: External Crystal Connections

    Chapter 26 RTC Oscillator 26.3 External Crystal Connections The connections with a crystal is shown in the following figure. External load capacitors and feedback resistor are not required. RTC Oscillator Module XTAL32 EXTAL32 Crystal or Resonator Figure 26-2. Crystal Connections 26.4 Memory Map/Register Descriptions RTC oscillator control bits are part of the RTC registers.
  • Page 576: Reset Overview

    Reset Overview 26.6 Reset Overview There is no reset state associated with the RTC oscillator. 26.7 Interrupts The RTC oscillator does not generate any interrupts. K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 577: Flash Memory Controller (Fmc)

    Chapter 27 Flash Memory Controller (FMC) 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.
  • Page 578: Features

    Modes of operation 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.
  • Page 579: Memory Map And Register Descriptions

    Chapter 27 Flash Memory Controller (FMC) 27.4 Memory map and register descriptions 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).
  • Page 580 Memory map and register descriptions Table 27-3. Program visible cache registers Cache Based at Contents of 32-bit read Nomenclature Nomenclature example storage offset 100h 13'h0, tag[18:6], 5'h0, valid In TAGVDWxSy, x denotes the way TAGVDW2S0 is the 13-bit and y denotes the set. tag and 1-bit valid for cache entry way 2, set 0.
  • Page 581 Chapter 27 Flash Memory Controller (FMC) FMC memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 27.4.5/ 4001_F130 Cache Tag Storage (FMC_TAGVDW1S4) 0000_0000h 27.4.5/ 4001_F134 Cache Tag Storage (FMC_TAGVDW1S5) 0000_0000h 27.4.5/ 4001_F138 Cache Tag Storage (FMC_TAGVDW1S6) 0000_0000h 27.4.5/ 4001_F13C...
  • Page 582 Memory map and register descriptions FMC memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 27.4.8/ 4001_F200 Cache Data Storage (upper word) (FMC_DATAW0S0U) 0000_0000h 27.4.9/ 4001_F204 Cache Data Storage (lower word) (FMC_DATAW0S0L) 0000_0000h 27.4.8/ 4001_F208 Cache Data Storage (upper word) (FMC_DATAW0S1U)
  • Page 583 Chapter 27 Flash Memory Controller (FMC) FMC memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 27.4.10/ 4001_F250 Cache Data Storage (upper word) (FMC_DATAW1S2U) 0000_0000h 27.4.11/ 4001_F254 Cache Data Storage (lower word) (FMC_DATAW1S2L) 0000_0000h 27.4.10/ 4001_F258...
  • Page 584 Memory map and register descriptions FMC memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 27.4.12/ 4001_F2A0 Cache Data Storage (upper word) (FMC_DATAW2S4U) 0000_0000h 27.4.13/ 4001_F2A4 Cache Data Storage (lower word) (FMC_DATAW2S4L) 0000_0000h 27.4.12/ 4001_F2A8 Cache Data Storage (upper word) (FMC_DATAW2S5U)
  • Page 585: Flash Access Protection Register (Fmc_Pfapr)

    Chapter 27 Flash Memory Controller (FMC) FMC memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 27.4.14/ 4001_F2F0 Cache Data Storage (upper word) (FMC_DATAW3S6U) 0000_0000h 27.4.15/ 4001_F2F4 Cache Data Storage (lower word) (FMC_DATAW3S6L) 0000_0000h 27.4.14/ 4001_F2F8...
  • Page 586 Memory map and register descriptions FMC_PFAPR field descriptions (continued) Field Description Prefetching for this master is enabled. Prefetching for this master is disabled. Master 5 Prefetch Disable M5PFD These bits control whether prefetching is enabled based on the logical number of the requesting crossbar switch master.
  • Page 587 Chapter 27 Flash Memory Controller (FMC) FMC_PFAPR field descriptions (continued) Field Description Only write accesses may be performed by this master. Both read and write accesses may be performed by this master. 13–12 Master 6 Access Protection M6AP[1:0] This field controls whether read and write access to the flash are allowed based on the logical master number of the requesting crossbar switch master.
  • Page 588: Flash Bank 0 Control Register (Fmc_Pfb0Cr)

    Memory map and register descriptions FMC_PFAPR field descriptions (continued) Field Description This field controls whether read and write access to the flash are allowed based on the logical master number of the requesting crossbar switch master. No access may be performed by this master Only read accesses may be performed by this master Only write accesses may be performed by this master Both read and write accesses may be performed by this master...
  • Page 589 Chapter 27 Flash Memory Controller (FMC) FMC_PFB0CR field descriptions (continued) Field Description 27–24 Cache Lock Way x CLCK_WAY[3:0] These bits determine if the given cache way is locked such that its contents will not be displaced by future misses. The bit setting definitions are for each bit in the field. Cache way is unlocked and may be displaced Cache way is locked and its contents are not displaced 23–20...
  • Page 590 Memory map and register descriptions FMC_PFB0CR field descriptions (continued) Field Description Bank 0 Data Cache Enable B0DCE This bit controls whether data references are loaded into the cache. Do not cache data references. Cache data references. Bank 0 Instruction Cache Enable B0ICE This bit controls whether instruction fetches are loaded into the cache.
  • Page 591: Flash Bank 1 Control Register (Fmc_Pfb1Cr)

    Chapter 27 Flash Memory Controller (FMC) 27.4.3 Flash Bank 1 Control Register (FMC_PFB1CR) 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: FMC_PFB1CR is 4001_F000h base + 8h offset = 4001_F008h B1RWSC[3:0] B1MW[1:0]...
  • Page 592 Memory map and register descriptions FMC_PFB1CR field descriptions (continued) Field Description Bank 1 Data Cache Enable B1DCE This bit controls whether data references are loaded into the cache. Do not cache data references. Cache data references. Bank 1 Instruction Cache Enable B1ICE This bit controls whether instruction fetches are loaded into the cache.
  • Page 593: Cache Tag Storage (Fmc_Tagvdw0Sn)

    Chapter 27 Flash Memory Controller (FMC) 27.4.4 Cache Tag Storage (FMC_TAGVDW0Sn) The 32-entry 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.
  • Page 594: Cache Tag Storage (Fmc_Tagvdw1Sn)

    Memory map and register descriptions 27.4.5 Cache Tag Storage (FMC_TAGVDW1Sn) The 32-entry 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.
  • Page 595: Cache Tag Storage (Fmc_Tagvdw2Sn)

    Chapter 27 Flash Memory Controller (FMC) 27.4.6 Cache Tag Storage (FMC_TAGVDW2Sn) The 32-entry 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.
  • Page 596: Cache Tag Storage (Fmc_Tagvdw3Sn)

    Memory map and register descriptions 27.4.7 Cache Tag Storage (FMC_TAGVDW3Sn) The 32-entry 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.
  • Page 597: Cache Data Storage (Upper Word) (Fmc_Dataw0Snu)

    Chapter 27 Flash Memory Controller (FMC) 27.4.8 Cache Data Storage (upper word) (FMC_DATAW0SU) 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.
  • Page 598: Cache Data Storage (Lower Word) (Fmc_Dataw0Snl)

    Memory map and register descriptions 27.4.9 Cache Data Storage (lower word) (FMC_DATAW0SL) 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.
  • Page 599: Cache Data Storage (Upper Word) (Fmc_Dataw1Snu)

    Chapter 27 Flash Memory Controller (FMC) 27.4.10 Cache Data Storage (upper word) (FMC_DATAW1SU) 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.
  • Page 600: Cache Data Storage (Lower Word) (Fmc_Dataw1Snl)

    Memory map and register descriptions 27.4.11 Cache Data Storage (lower word) (FMC_DATAW1SL) 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.
  • Page 601: Cache Data Storage (Upper Word) (Fmc_Dataw2Snu)

    Chapter 27 Flash Memory Controller (FMC) 27.4.12 Cache Data Storage (upper word) (FMC_DATAW2SU) 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.
  • Page 602: Cache Data Storage (Lower Word) (Fmc_Dataw2Snl)

    Memory map and register descriptions 27.4.13 Cache Data Storage (lower word) (FMC_DATAW2SL) 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.
  • Page 603: Cache Data Storage (Upper Word) (Fmc_Dataw3Snu)

    Chapter 27 Flash Memory Controller (FMC) 27.4.14 Cache Data Storage (upper word) (FMC_DATAW3SU) 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.
  • Page 604: Cache Data Storage (Lower Word) (Fmc_Dataw3Snl)

    Functional description 27.4.15 Cache Data Storage (lower word) (FMC_DATAW3SL) 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.
  • Page 605 Chapter 27 Flash Memory Controller (FMC) • These masters have write access to a portion of bank 1 when FlexNVM is used with FlexRAM as EEPROM. • For bank 0 and bank 1: • Prefetch support for data and instructions is enabled for crossbar masters 0, 1, 2. •...
  • Page 606 Functional description K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 607: Flash Memory Module (Ftfl)

    Chapter 28 Flash Memory Module (FTFL) 28.1 Introduction NOTE For the chip-specific implementation details of this module's instances see the chip configuration chapter. The FTFL module includes the following accessible memory regions: • Program flash memory for vector space and code store •...
  • Page 608: Features

    Introduction 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') states. Therefore, it is recommended that each flash block or sector be re-erased immediately prior to factory programming to ensure that the full data retention capability is achieved.
  • Page 609 Chapter 28 Flash Memory Module (FTFL) • Section programming for faster bulk programming times • Read access to data flash memory possible while programming or erasing data in the program flash memory 28.1.1.3 Program Acceleration RAM Features • For devices with only program flash memory: RAM to support section programming 28.1.1.4 FlexRAM Features For devices with FlexNVM memory: •...
  • Page 610: Block Diagram

    Introduction • Optional interrupt generation upon flash command completion • Supports MCU security mechanisms which prevent unauthorized access to the flash memory contents 28.1.2 Block Diagram The block diagram of the FTFL module is shown in the following figure. For devices with FlexNVM feature: Interrupt Program flash Status...
  • Page 611: Glossary

    Chapter 28 Flash Memory Module (FTFL) Interrupt Program flash Status Register access registers Memory controller Control registers To MCU's flash controller Program flash Programming acceleration Figure 28-2. FTFL Block Diagram 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 FTFL module.
  • Page 612 Introduction 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.
  • Page 613: External Signal Description

    Chapter 28 Flash Memory Module (FTFL) NVM Special Mode — An NVM mode enabling external, off-chip access to the memory resources in the FTFL module. A reduced FTFL command set is available when the MCU is secured. See the Chip Configuration details for information on when this mode is used.
  • Page 614: Flash Configuration Field Description

    Memory Map and Registers 28.3.1 Flash Configuration Field Description The program flash memory contains a 16-byte flash configuration field that stores default protection settings (loaded on reset) and security information that allows the MCU to restrict access to the FTFL module. Flash Configuration Field Byte Size (Bytes) Field Description...
  • Page 615: Data Flash Ifr Map

    Chapter 28 Flash Memory Module (FTFL) Address Range Size (Bytes) Field Description 0x00 – 0xBF Reserved 0xC0 – 0xFF Program Once Field 28.3.2.1 Program Once Field The Program Once Field in the program flash IFR provides 64 bytes of user data storage separate from the program flash main array.
  • Page 616 Memory Map and Registers Table 28-1. EEPROM Data Set Size (continued) EEESPLIT EEESIZE = Unimplemented or Reserved Table 28-2. EEPROM Data Set Size Field Description Field Description This read-only bitfield is reserved and must always be written as one. Reserved EEPROM Split Factor —...
  • Page 617: Register Descriptions

    Chapter 28 Flash Memory Module (FTFL) Table 28-3. FlexNVM Partition Code Data Flash IFR: 0x00FC DEPART = Unimplemented or Reserved Table 28-4. FlexNVM Partition Code Field Description Field Description This read-only bitfield is reserved and must always be written as one. Reserved FlexNVM Partition Code —...
  • Page 618 Memory Map and Registers sequence, prior to the initial rise of CCIF. During this initialization period the user may write any register. All register writes are also disabled (except for registers FCNFG and FSTAT) whenever an erase suspend request is active (FCNFG[ERSSUSP]=1).
  • Page 619 Chapter 28 Flash Memory Module (FTFL) FTFL memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 28.34.6/ 4002_0010 Program Flash Protection Registers (FTFL_FPROT3) Undefined 28.34.6/ 4002_0011 Program Flash Protection Registers (FTFL_FPROT2) Undefined 28.34.6/ 4002_0012 Program Flash Protection Registers (FTFL_FPROT1) Undefined...
  • Page 620 Memory Map and Registers FTFL_FSTAT field descriptions (continued) Field Description The CCIF bit is reset to 0 but is set to 1 by the memory controller at the end of the reset initialization sequence. Depending on how quickly the read occurs after reset release, the user may or may not see the 0 hardware reset value.
  • Page 621 Chapter 28 Flash Memory Module (FTFL) The erase control bits (ERSAREQ and ERSSUSP) have write restrictions. SWAP, PFLSH, RAMRDY, and EEERDY are read-only status bits . The unassigned bits read as noted and are not writable. The reset values for the SWAP, PFLASH, RAMRDY, and EEERDY bits are determined during the reset sequence.
  • Page 622 Memory Map and Registers FTFL_FCNFG field descriptions (continued) Field Description For program flash only configurations, the SWAP flag indicates which physical program flash block is located at relative address 0x0000. The state of the SWAP flag is set by the FTFL during the reset sequence .
  • Page 623 Chapter 28 Flash Memory Module (FTFL) During the reset sequence, the register is loaded with the contents of the flash security byte in the Flash Configuration Field located in program flash memory. The Flash basis for the values is signified by X in the reset value. Address: FTFL_FSEC is 4002_0000h base + 2h offset = 4002_0002h Read KEYEN...
  • Page 624 Memory Map and Registers FTFL_FSEC field descriptions (continued) Field Description These bits define the security state of the MCU. In the secure state, the MCU limits access to FTFL module resources. The limitations are defined per device and are detailed in the Chip Configuration details.
  • Page 625 Chapter 28 Flash Memory Module (FTFL) 28.34.5 Flash Common Command Object Registers (FTFL_FCCOBn) 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.
  • Page 626 Memory Map and Registers FTFL_FCCOBn field descriptions (continued) Field Description FCCOB Number Typical Command Parameter Contents [7:0] Data Byte 6 Data Byte 7 FCCOB Endianness and Multi-Byte Access : The FCCOB register group uses a big endian addressing convention. For all command parameter fields larger than 1 byte, the most significant data resides in the lowest FCCOB register number.
  • Page 627 Chapter 28 Flash Memory Module (FTFL) Addresses: FTFL_FPROT3 is 4002_0000h base + 10h offset = 4002_0010h FTFL_FPROT2 is 4002_0000h base + 11h offset = 4002_0011h FTFL_FPROT1 is 4002_0000h base + 12h offset = 4002_0012h FTFL_FPROT0 is 4002_0000h base + 13h offset = 4002_0013h Read PROT Write...
  • Page 628 Memory Map and Registers Address: FTFL_FEPROT is 4002_0000h base + 16h offset = 4002_0016h Read EPROT Write Reset * Notes: • x = Undefined at reset. FTFL_FEPROT field descriptions Field Description 7–0 EEPROM Region Protect EPROT For devices with program flash only: Reserved For devices with FlexNVM: Individual EEPROM regions can be protected from alteration by setting the associated EPROT bit.
  • Page 629 Chapter 28 Flash Memory Module (FTFL) 28.34.8 Data Flash Protection Register (FTFL_FDPROT) 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 FTFL command. Unprotected regions can be changed by both program and erase operations.
  • Page 630: Functional Description

    Functional Description 28.4 Functional Description The following sections describe functional details of the FTFL module. 28.4.1 Program Flash Memory Swap For devices that only contain program flash memory: The user can configure the logical memory map of the program flash space such that either of the two physical program flash blocks can exist at relative address 0x0000.
  • Page 631 Chapter 28 Flash Memory Module (FTFL) • FDPROT — • For 2 data flash sizes, protects eight regions of the data flash memory as shown in the following figure FlexNVM 0x0_0000 Data flash size / 8 DPROT0 Data flash size / 8 DPROT1 Data flash size / 8 DPROT2...
  • Page 632 Functional Description 224KB data flash 192KB data flash 0x0_0000 0x0_0000 32KB DPROT0 32KB DPROT0 32KB DPROT1 32KB DPROT1 32KB DPROT2 32KB DPROT2 32KB DPROT3 32KB DPROT3 32KB DPROT4 32KB DPROT4 32KB DPROT5 32KB DPROT5 0x2_FFFF 32KB DPROT6 64KB 0x3_7FFF EEPROM backup 32KB EEPROM backup 0x3_FFFF...
  • Page 633: Flexnvm Description

    Chapter 28 Flash Memory Module (FTFL) 28.4.3 FlexNVM Description This section describes the FlexNVM memory. This section does not apply for devices that contain only program flash memory. 28.4.3.1 FlexNVM Block Partitioning for FlexRAM The user can configure the FlexNVM block as either: •...
  • Page 634 Functional Description 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).
  • Page 635 Chapter 28 Flash Memory Module (FTFL) FlexNVM Block 0 FlexNVM Block 1 Data flash 0 Data flash 1 FlexRAM EEPROM partition A EEPROM partition B EEPROM EEPROM backup A backup B Unavailable Subsystem A Subsystem B EEESPLIT = 1/8, 1/4, or 1/2 Size of EEPROM partition A = EEESIZE x EEESPLIT Data flash 0 and 1 interleaved Figure 28-32.
  • Page 636 Functional Description 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.
  • Page 637: Interrupts

    Chapter 28 Flash Memory Module (FTFL) Figure 28-33. EEPROM backup writes to FlexRAM 28.4.4 Interrupts The FTFL module can generate interrupt requests to the MCU upon the occurrence of various FTFL events. These interrupt events and their associated status and control bits are shown in the following table.
  • Page 638: Flash Operation In Low-Power Modes

    Flash Operation in Low-Power Modes 28.4.5 Flash Operation in Low-Power Modes 28.4.5.1 Wait Mode When the MCU enters wait mode, the FTFL module is not affected. The FTFL module can recover the MCU from wait via the command complete interrupt (see Interrupts). 28.4.5.2 Stop Mode When the MCU requests stop mode, if an FTFL command is active (CCIF = 0) the command execution completes before the MCU is allowed to enter stop mode.
  • Page 639: Read While Write (Rww)

    Chapter 28 Flash Memory Module (FTFL) 28.4.8 Read While Write (RWW) The following simultaneous accesses are allowed for devices with FlexNVM: • The user may read from the program flash memory while commands (typically program and erase operations) are active in the data flash and FlexRAM memory space.
  • Page 640 Flash Operation in Low-Power Modes • The command write sequence used to set FTFL command parameters and launch execution • A description of all FTFL commands available 28.4.10.1 Command Write Sequence FTFL commands are specified using a command write sequence illustrated in Figure 28-34.
  • Page 641 Chapter 28 Flash Memory Module (FTFL) 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.
  • Page 642 Flash Operation in Low-Power Modes START Read: FSTAT register FCCOB Availability Check CCIF Previous command complete? = ‘1’? Results from previous command Access Error and ACCERR/ Protection Violation Clear the old errors FPVIOL Check Write 0x30 to FSTAT register Set? Write to the FCCOB registers to load the required command parameter.
  • Page 643 Chapter 28 Flash Memory Module (FTFL) FCMD Command Program Program Data flash FlexRAM Function flash 0 flash 1 (Devices (Devices (Devices with with with only FlexNVM) FlexNVM) program flash) 0x00 Read 1s Block × × × Verify that a program flash or data flash block is erased.
  • Page 644 Flash Operation in Low-Power Modes FCMD Command Program Program Data flash FlexRAM Function flash 0 flash 1 (Devices (Devices (Devices with with with only FlexNVM) FlexNVM) program flash) 0x0B Program × × × × Program data Section from the Section Program Buffer to a program flash or data...
  • Page 645 Chapter 28 Flash Memory Module (FTFL) FCMD Command Program Program Data flash FlexRAM Function flash 0 flash 1 (Devices (Devices (Devices with with with only FlexNVM) FlexNVM) program flash) 0x44 Erase All Blocks × × × × Erase all program flash blocks, program flash 1 IFR, data flash...
  • Page 646 Flash Operation in Low-Power Modes FCMD Command Program Program Data flash FlexRAM Function flash 0 flash 1 (Devices (Devices (Devices with with with only FlexNVM) FlexNVM) program flash) 0x81 Set FlexRAM × Switches Function FlexRAM function between RAM and EEPROM. When switching to EEPROM, FlexNVM is not...
  • Page 647 Chapter 28 Flash Memory Module (FTFL) Table 28-31. FTFL Commands by Mode (continued) NVM Normal NVM Special FCMD Command Unsecure Secure MEEN=10 Unsecure Secure MEEN=10 0x80 Program Partition × × × × — — 0x81 Set FlexRAM Function × × ×...
  • Page 648: Margin Read Commands

    Flash Operation in Low-Power Modes Table 28-33. Allowed Simultaneous Memory Operations Program Flash 0 Program Flash 1 Read Program Sector Erase Read Program Sector Erase Read — Program Program — flash 0 Sector Erase — Read — Program Program — flash 1 Sector Erase —...
  • Page 649: Ftfl Command Description

    Chapter 28 Flash Memory Module (FTFL) 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.
  • Page 650 Flash Operation in Low-Power Modes 28.4.12.1 Read 1s Block Command The Read 1s Block command checks to see if an entire program flash or data flash block has been erased to the specified margin level. The FCCOB flash address bits determine which logical block is erase-verified.
  • Page 651 Chapter 28 Flash Memory Module (FTFL) 28.4.12.2 Read 1s Section Command The Read 1s Section command checks if a section of program flash or data flash memory is erased to the specified read margin level. The Read 1s Section command defines the starting address and the number of phrases to be verified.
  • Page 652 Flash Operation in Low-Power Modes 28.4.12.3 Program Check Command The Program Check command tests a previously programmed program flash or data flash longword to see if it reads correctly at the specified margin level. Table 28-40. Program Check Command FCCOB Requirements FCCOB Number FCCOB Contents [7:0] 0x02 (PGMCHK)
  • Page 653 Chapter 28 Flash Memory Module (FTFL) Table 28-42. Program Check 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] An invalid margin choice is supplied FSTAT[ACCERR] Either of the margin reads does not match the expected data FSTAT[MGSTAT0]...
  • Page 654 Flash Operation in Low-Power Modes 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.
  • Page 655 Chapter 28 Flash Memory Module (FTFL) Upon clearing CCIF to launch the Program Longword command, the FTFL programs the data bytes into the flash using the supplied address. The swap indicator address in each program flash block is implicitly protected from programming. 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.
  • Page 656 Flash Operation in Low-Power Modes Upon clearing CCIF to launch the Erase Flash Block command, the FTFL 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.
  • Page 657 Chapter 28 Flash Memory Module (FTFL) address being erased is the non-active block. 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-35).
  • Page 658 Flash Operation in Low-Power Modes i.e. the suspend requests come repeatedly and too quickly, no forward progress is made by the Erase Flash Sector algorithm. The resume/suspend sequence runs indefinitely without completing the erase. 28.4.12.7.3 Aborting a Suspended Erase Flash Sector Operation The user may choose to abort a suspended Erase Flash Sector operation by clearing the ERSSUSP bit prior to clearing CCIF for the next command launch.
  • Page 659 Chapter 28 Flash Memory Module (FTFL) Enter with CCIF = 1 Command Initiation ERSSCR Command (Write FCCOB) Memory Controller Command Processing Launch/Resume Command (Clear CCIF) Resume ERSSCR SUSPACK=1 Next Command CCIF = 1? (Write FCCOB) Restore Erase Algo Start Clear SUSPACK = 0 Interrupt? Execute DONE?
  • Page 660 Flash Operation in Low-Power Modes 28.4.12.8 Program Section Command The Program Section operation programs the data found in the section program buffer to previously erased locations in the flash memory using an embedded algorithm. Data is preloaded into the section program buffer by writing to the FlexRAM while it is set to function as traditional RAM (see Flash Sector Programming).
  • Page 661 Chapter 28 Flash Memory Module (FTFL) 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-53.
  • Page 662 Flash Operation in Low-Power Modes 7. To restore EEPROM functionality, execute the Set FlexRAM Function command to make the FlexRAM available as EEPROM. 28.4.12.9 Read 1s All Blocks Command The Read 1s All Blocks command checks if the program flash blocks, data flash blocks, EEPROM backup records, and data flash IFR have been erased to the specified read margin level, if applicable, and releases security if the readout passes, i.e.
  • Page 663 Chapter 28 Flash Memory Module (FTFL) Table 28-56. Read 1s All Blocks Command Error Handling (continued) Error Condition Error Bit Read-1s fails FSTAT[MGSTAT0] 28.4.12.10 Read Once Command The Read Once command provides read access to a reserved 64-byte field located in the program flash 0 IFR (see Program Flash IFR Map Program Once...
  • Page 664 Flash Operation in Low-Power Modes 28.4.12.11 Program Once Command The Program Once command enables programming to a reserved 64-byte field in the program flash 0 IFR (see Program Flash IFR Map Program Once Field). Access to the Program Once field is via 16 records, each 4 bytes long. The Program Once field can be read using the Read Once command (see Read Once Command) or using the Read...
  • Page 665 Chapter 28 Flash Memory Module (FTFL) 28.4.12.12 Erase All Blocks Command The Erase All Blocks operation erases all flash memory, initializes the FlexRAM, verifies all memory contents, and releases MCU security. Table 28-61. Erase All Blocks Command FCCOB Requirements FCCOB Number FCCOB Contents [7:0] 0x44 (ERSALL) After clearing CCIF to launch the Erase All Blocks command, the FTFL erases all...
  • Page 666 Flash Operation in Low-Power Modes unsecure state and the FCNFG[RAMRDY] bit sets. The security byte in the Flash Configuration Field is also programmed to the unsecure state. The status of the erase-all request is reflected in the FCNFG[ERSAREQ] bit. The FCNFG[ERSAREQ] bit is cleared once the operation completes and the normal FSTAT error reporting is available as described in Erase All Blocks...
  • Page 667 Chapter 28 Flash Memory Module (FTFL) FTFL 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. Table 28-64.
  • Page 668 Flash Operation in Low-Power Modes Table 28-65. Swap Control Command FCCOB Requirements (continued) FCCOB Number FCCOB Contents [7:0] Next Swap Block Status (after any reset): 0x00 - Program flash block 0 at 0x0_0000 0X01 - Program flash block 1 at 0x0_0000 1.
  • Page 669 Chapter 28 Flash Memory Module (FTFL) • FCCOB6 (Current Swap Block Status) - indicates which program flash block is currently located at relative flash address 0x0_0000. • FCCOB7 (Next Swap Block Status) - indicates which program flash block will be located at relative flash address 0x0_0000 after the next reset of the FTFL module.
  • Page 670 Flash Operation in Low-Power Modes Table 28-66. Swap Control Command Error Handling (continued) Swap Error Condition Control Error Bit Code Any errors have been encountered during the swap determination and 1, 2, 4 FSTAT[MGSTAT0] program-verify operations Any brownouts were detected during the swap determination procedure FSTAT[MGSTAT0] 1.
  • Page 671 Chapter 28 Flash Memory Module (FTFL) Block0 Active States Block1 Active States Uninitialized0 0xFFFF 0xFFFF Ready0 Complete1 Reset 0xFFFF 0xFFFF 0x0000 0x0000 Update0 UpErs1 0xFF00 0xFFFF 0x0000 0xFF00 Erase Erase UpErs0 Update1 0xFF00 0x0000 0xFFFF 0xFF00 Complete0 Ready1 Reset 0x0000 0x0000 0xFFFF 0xFFFF...
  • Page 672 Flash Operation in Low-Power Modes Table 28-67. Swap State Report Mapping Case Swap Enable Swap Indicator Swap Indicator Swap State State MGST Active Field Code Block 0xFFFF Uninitialized 0x0000 0xFF00 0x0000 Update 0x0000 0xFF00- 0xFFFF Update-Erased 0x0000 0x0000 0xFFFF Complete 0x0000 0x0000 0xFFFF...
  • Page 673 Chapter 28 Flash Memory Module (FTFL) 28.4.12.14.1 Swap State Determination During the reset sequence, the state of the swap system is determined by evaluating the IFR Swap Field in the program flash 1 IFR and the swap indicators located in each of the program flash blocks at the swap indicator address stored in the IFR Swap Field.
  • Page 674 Flash Operation in Low-Power Modes Table 28-70. Valid EEPROM Data Set Size Codes EEPROM Data Size Code (FCCOB4) EEPROM Data Set Size (Bytes) FCCOB4[EEESPLIT] FCCOB4[EEESIZE] Subsystem A + B 4 + 28 8 + 24 16 + 16 16 + 16 8 + 56 16 + 48 32 + 32...
  • Page 675 Chapter 28 Flash Memory Module (FTFL) Table 28-71. Valid FlexNVM Partition Codes FlexNVM Partition Code Data flash Size (Kbytes) EEPROM backup Size (Kbytes) (FCCOB5[DEPART]) 0000 0011 0100 0101 0110 1000 1011 1100 1101 1110 1. FCCOB5[7:4] = 0000 After clearing CCIF to launch the Program Partition command, the FTFL first verifies that the EEPROM Data Size Code and FlexNVM Partition Code in the data flash IFR are erased.
  • Page 676 Flash Operation in Low-Power Modes Table 28-72. Program Partition Command Error Handling (continued) Error Condition Error Bit FlexNVM Partition Code allocates space for EEPROM backup, but EEPROM Data Size FSTAT[ACCERR] Code allocates no FlexRAM for EEPROM FCCOB4[7:6] != 00 FSTAT[ACCERR] FCCOB5[7:4] != 0000 FSTAT[ACCERR] Any errors have been encountered during the verify operation...
  • Page 677: Security

    Chapter 28 Flash Memory Module (FTFL) 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).
  • Page 678 Flash Operation in Low-Power Modes 28.4.13.1 FTFL Access by Mode and Security The following table summarizes how access to the FTFL module is affected by security and operating mode. Table 28-77. FTFL Access Summary Chip Security State Operating Mode Unsecure Secure NVM Normal Full command set...
  • Page 679: Reset Sequence

    Chapter 28 Flash Memory Module (FTFL) 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.
  • Page 680 Flash Operation in Low-Power Modes K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 681: Overview

    Chapter 29 EzPort 29.1 Overview NOTE For the chip-specific implementation details of this module's instances see the chip configuration chapter. EzPort is a serial flash programming interface that allows In-System Programming (ISP) of flash memory contents on a 32 bit general purpose micro-controller. Memory contents can be read, erased and programmed from off-chip in a compatible format to many stand- alone flash memory chips, without necessitating the removal of the micro-controller from the system.
  • Page 682: Features

    Overview EzPort Enabled EZP_CS EZP_CK Flash EzPort Controller EZP_D EZP_Q Reset Flash Memory Reset Out Reset Controller Micro-controller Core Figure 29-1. EzPort Block Diagram 29.1.2 Features The EzPort includes the following features: • Serial interface that is compatible with a subset of the SPI format. •...
  • Page 683: External Signal Description

    Chapter 29 EzPort The EzPort provides a simple interface to connect an external device to the flash memory on board a 32 bit micro-controller. The interface itself is compatible with the SPI interface (with the EzPort operating as a slave) running in either of the two following modes with data transmitted most significant bit first: •...
  • Page 684: Ezport Serial Data In (Ezp_D)

    Command Definition 29.2.2 EzPort Chip Select (EZP_CS) Chip select for signalling the start and end of serial transfers. If EZP_CS is asserted during and when the micro-controller's reset out signal is negated, then EzPort is enabled out of reset; otherwise it is disabled. After EzPort is enabled, asserting EZP_CS commences a serial data transfer, which continues until EZP_CS is negated again.
  • Page 685: Command Descriptions

    Chapter 29 EzPort Table 29-2. EzPort Commands (continued) Address Accepted when Command Description Code Data Bytes Bytes secure? RESET Reset Chip 0xB9 WRFCCOB Write FCCOB Registers 0xBA Read FCCOB registers at high FAST_RDFCCOB 0xBB 1 - 12 speed WRFLEXRAM Write FlexRAM 0xBC RDFLEXRAM Read FlexRAM...
  • Page 686 Command Definition Table 29-3. EzPort Status Register FLEXRAM BEDIS Reset: 1. Reset value reflects the status of flash security out of reset. 2. Reset value reflects FlexNVM flash partitioning. If FlexNVM flash has been paritioned for EEPROM, this bit is set immediately after reset.
  • Page 687 Chapter 29 EzPort Table 29-4. EzPort Status Register Field Descriptions (continued) Field Description Write error flag Status flag that indicates if there has been an error while executing a write command (SP, SE, BE, WRFCCOB, or WRFLEXRAM). The WEF flag will set if either the Flash Access Error Flag (ACCERR) or the Flash Protection Violation Flag (FPVIOL) or the Memory Controller Command Completion Status Flag (MGSTAT0) inside the flash memory is set at the completion of the write command.
  • Page 688 Command Definition 29.3.1.6 Section Program The Section Program (SP) command programs up to one section of flash memory which has previously been erased. A section is defined as the smaller of the flash sector size or half the size of the FlexRAM/Programming Acceleration RAM. The starting address of the memory to program is sent after the command word and must be a 64-bit aligned address (the three LSBs must be zero).
  • Page 689 Chapter 29 EzPort 29.3.1.8 Bulk Erase The Bulk Erase (BE) command erases the entire contents of flash memory, ignoring any protected sectors or flash security. Flash security is disabled upon successful completion of the BE command. Attempts to issue a BE command while the BEDIS and FS bits are set results in the WEF flag being set in the EzPort status register.
  • Page 690 Command Definition 29.3.1.11 Read FCCOB Registers at High Speed The Read FCCOB Registers at High Speed (FAST_RDFCCOB) command allows the user to read the contents of the flash common command object registers. After receiving the command, EzPort waits for one dummy byte of data before returning FCCOB register data starting at FCCOB 0 and ending with FCCOB B.
  • Page 691: Flash Memory Map For Ezport Access

    Chapter 29 EzPort The Read FlexRAM (RDFLEXRAM) command returns data from the FlexRAM. If the FlexRAM is configured for EEPROM operation, the RDFLEXRAM command can effectively be used to read data from EEPROM-flash memory. Data continues being returned for as long as the EzPort chip select (EZP_CS) is asserted, with the address automatically incrementing.
  • Page 692 Flash Memory Map for EzPort Access Table 29-5. Flash Memory Map for EzPort Access (continued) Valid Start Address Size Flash block Valid Commands See device's Chip 0x0080_0000 FlexNVM READ, FAST_READ, SP, SE, BE Configuration details See device's Chip RDFLEXRAM, FAST_RDFLEXRAM, 0x0000_0000 FlexRAM Configuration details...
  • Page 693: Cyclic Redundancy Check (Crc)

    Chapter 30 Cyclic redundancy check (CRC) 30.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.
  • Page 694: Block Diagram

    Memory map and register descriptions 30.1.2 Block diagram This is a block diagram of the CRC. FXOR TOTR CRC Data Register [31:24] CRC Data Register Seed Reverse [23:16] [31:24] Logic [15:8] Reverse [23:16] CRC Data [7:0] Logic Logic [15:8] [7:0] Checksum CRC Polynomial CRC Engine...
  • Page 695: Crc Data Register (Crc_Crc)

    Chapter 30 Cyclic redundancy check (CRC) CRC memory map Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) FFFF_ 30.2.1/ 4003_2000 CRC Data Register (CRC_CRC) FFFFh 30.2.2/ 4003_2004 CRC Polynomial Register (CRC_GPOLY) 0000_1021h 30.2.3/ 4003_2008 CRC Control Register (CRC_CTRL) 0000_0000h 30.2.1 CRC Data Register (CRC_CRC) The CRC data register contains the value of the seed, data, and checksum.
  • Page 696: Crc Polynomial Register (Crc_Gpoly)

    Memory map and register descriptions CRC_CRC field descriptions (continued) Field Description 23–16 CRC High Lower Byte In 16-bit CRC mode (the CTRL[TCRC] bit is 0), this field is not used for programming a seed value. In 32- bit CRC mode (the CTRL[TCRC] bit is 1), values written to this field are part of the seed value when the CTRL[WAS] bit is 1.
  • Page 697 Chapter 30 Cyclic redundancy check (CRC) 30.2.3 CRC Control Register (CRC_CTRL) This register controls the configuration and working of the CRC module. Appropriate bits must be set before starting a new CRC calculation. A new CRC calculation is initialized by asserting the CTRL[WAS] bit and then writing the seed into the CRC data register. Address: CRC_CTRL is 4003_2000h base + 8h offset = 4003_2008h Reset CRC_CTRL field descriptions...
  • Page 698 Functional description CRC_CTRL field descriptions (continued) Field Description Width of CRC protocol. TCRC 16-bit CRC protocol. 32-bit CRC protocol. 23–0 This read-only field is reserved and always has the value zero. Reserved 30.3 Functional description 30.3.1 CRC initialization/re-initialization To enable the CRC calculation, the user must program the WAS, POLYNOMIAL, and necessary parameters for transpose and CRC result inversion in the applicable registers.
  • Page 699 Chapter 30 Cyclic redundancy check (CRC) 5. Write a 16-bit seed to CRC[LU:LL]. CRC[HU:HL] are not used. 6. Clear the CTRL[WAS] bit to start writing data values. 7. Write data values into CRC[HU:HL:LU:LL]. A CRC is computed on every data value write, and the intermediate CRC result is stored back into CRC[LU:LL].
  • Page 700 Functional description 30.3.3.1 Types of transpose The CRC module provides several types of transpose functions to flip the bits and/or bytes (for both writing input data and reading the CRC result, separately using the CTRL[TOT] or CTRL[TOTR] fields) according to the CRC calculation being used. The following types of transpose functions are available for writing to and reading from the CRC data register.
  • Page 701 Chapter 30 Cyclic redundancy check (CRC) Figure 30-7. Transpose type 11 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.
  • Page 702 Functional description K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 703 Chapter 31 Analog-to-Digital Converter (ADC) 31.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, refer to the Power Management information for the device.
  • Page 704 Introduction • Input clock selectable from up to four sources • Operation in low power modes for lower noise operation • Asynchronous clock source for lower noise operation with option to output the clock • Selectable hardware conversion trigger with hardware channel select •...
  • Page 705 Chapter 31 Analog-to-Digital Converter (ADC) ADHWTSA SC1A Conversion SC1n ADHWTSn Trigger Control A D T R G ADHWT (SC2, CFG1, CFG2) C o m p a re tru e Control Registers A D A C K E N Async Clock Gen Interrupt ADACK A D C K...
  • Page 706 ADC Signal Descriptions Table 31-1. ADC Signal Descriptions (continued) Signal Description DADM[3:0] Differential analog channel inputs AD[23:4] Single-ended analog channel inputs Voltage reference select high REFSH Voltage reference select low REFSL Analog power supply Analog ground 31.2.1 Analog power (V The ADC analog portion uses V as its power connection.
  • Page 707 Chapter 31 Analog-to-Digital Converter (ADC) In some packages, V is connected in the package to V and V to V . If REFH REFL externally available, the positive reference(s) may be connected to the same potential as or may be driven by an external source to a level between the minimum Ref Voltage High and the V potential (V must never exceed V...
  • Page 708 Register Definition ADC memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 31.3.3/ 4003_B00C Configuration register 2 (ADC0_CFG2) 0000_0000h 31.3.4/ 4003_B010 ADC data result register (ADC0_RA) 0000_0000h 31.3.4/ 4003_B014 ADC data result register (ADC0_RB) 0000_0000h 31.3.5/ 4003_B018...
  • Page 709 Chapter 31 Analog-to-Digital Converter (ADC) ADC memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) ADC minus-side general calibration value register 31.3.21/ 4003_B05C 0000_0200h (ADC0_CLM4) ADC minus-side general calibration value register 31.3.22/ 4003_B060 0000_0100h (ADC0_CLM3) ADC minus-side general calibration value register...
  • Page 710 Register Definition ADC memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) ADC plus-side general calibration value register 31.3.13/ 400B_B03C 0000_0200h (ADC1_CLP4) ADC plus-side general calibration value register 31.3.14/ 400B_B040 0000_0100h (ADC1_CLP3) ADC plus-side general calibration value register 31.3.15/ 400B_B044 0000_0080h...
  • Page 711 Chapter 31 Analog-to-Digital Converter (ADC) Writing SC1A while SC1A is actively controlling a conversion aborts the current conversion. In software trigger mode (ADTRG=0), writes to the SC1A register subsequently initiate a new conversion (if the ADCH bits are equal to a value other than all 1s).
  • Page 712 Register Definition ADCx_SC1n field descriptions (continued) Field Description Interrupt enable AIEN AIEN enables conversion complete interrupts. When COCO becomes set while the respective AIEN is high, an interrupt is asserted. Conversion complete interrupt disabled. Conversion complete interrupt enabled. Differential mode enable DIFF DIFF configures the ADC to operate in differential mode.
  • Page 713 Chapter 31 Analog-to-Digital Converter (ADC) ADCx_SC1n field descriptions (continued) Field Description 10111 When DIFF=0, AD23 is selected as input; when DIFF=1, it is reserved. 11000 Reserved. 11001 Reserved. 11010 When DIFF=0, Temp sensor (single-ended) is selected as input; when DIFF=1, Temp sensor (differential) is selected as input.
  • Page 714 Register Definition ADCx_CFG1 field descriptions (continued) Field Description Normal power configuration. Low power configuration. The power is reduced at the expense of maximum clock speed. 6–5 Clock divide select ADIV ADIV selects the divide ratio used by the ADC to generate the internal clock ADCK. The divide ratio is 1 and the clock rate is input clock.
  • Page 715 Chapter 31 Analog-to-Digital Converter (ADC) 31.3.3 Configuration register 2 (ADCx_CFG2) CFG2 register selects the special high speed configuration for very high speed conversions and selects the long sample time duration during long sample mode. Addresses: ADC0_CFG2 is 4003_B000h base + Ch offset = 4003_B00Ch ADC1_CFG2 is 400B_B000h base + Ch offset = 400B_B00Ch Reset ADLSTS...
  • Page 716 Register Definition ADCx_CFG2 field descriptions (continued) Field Description ADHSC configures the ADC for very high speed operation. The conversion sequence is altered (2 ADCK cycles added to the conversion time) to allow higher speed conversion clocks. Normal conversion sequence selected. High speed conversion sequence selected (2 additional ADCK cycles to total conversion time).
  • Page 717 Chapter 31 Analog-to-Digital Converter (ADC) Table 31-44. Data result register description (continued) Conversion D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 Format mode 11-bit differential S Sign extended 2's complement 10-bit single- Unsigned right ended justified...
  • Page 718 Register Definition The compare value 2 register (CV2) is utilized only when the compare range function is enabled (ACREN=1). Addresses: ADC0_CV1 is 4003_B000h base + 18h offset = 4003_B018h ADC0_CV2 is 4003_B000h base + 1Ch offset = 4003_B01Ch ADC1_CV1 is 400B_B000h base + 18h offset = 400B_B018h ADC1_CV2 is 400B_B000h base + 1Ch offset = 400B_B01Ch Reset ADCx_CVn field descriptions...
  • Page 719 Chapter 31 Analog-to-Digital Converter (ADC) ADCx_SC2 field descriptions Field Description 31–8 This read-only field is reserved and always has the value zero. Reserved Conversion active ADACT ADACT indicates that a conversion or hardware averaging is in progress. ADACT is set when a conversion is initiated and cleared when a conversion is completed or aborted.
  • Page 720 Register Definition ADCx_SC2 field descriptions (continued) Field Description Default voltage reference pin pair (external pins V and V REFH REFL Alternate reference pair (V and V ). This pair may be additional external pins or internal ALTH ALTL sources depending on MCU configuration. Consult the Chip Configuration information for details specific to this MCU.
  • Page 721 Chapter 31 Analog-to-Digital Converter (ADC) ADCx_SC3 field descriptions (continued) Field Description Calibration completed normally. Calibration failed. ADC accuracy specifications are not guaranteed. 5–4 This read-only field is reserved and always has the value zero. Reserved Continuous conversion enable ADCO ADCO enables continuous conversions. One conversion or one set of conversions if the hardware average function is enabled (AVGE=1) after initiating a conversion.
  • Page 722 Register Definition ADCx_OFS field descriptions Field Description 31–16 This read-only field is reserved and always has the value zero. Reserved 15–0 Offset error correction value 31.3.9 ADC plus-side gain register (ADCx_PG) 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.
  • Page 723 Chapter 31 Analog-to-Digital Converter (ADC) Addresses: ADC0_MG is 4003_B000h base + 30h offset = 4003_B030h ADC1_MG is 400B_B000h base + 30h offset = 400B_B030h Reset ADCx_MG field descriptions Field Description 31–16 This read-only field is reserved and always has the value zero. Reserved 15–0 Minus-side gain...
  • Page 724 Register Definition 31.3.12 ADC plus-side general calibration value register (ADCx_CLPS) For more information, refer to CLPD register description. Addresses: ADC0_CLPS is 4003_B000h base + 38h offset = 4003_B038h ADC1_CLPS is 400B_B000h base + 38h offset = 400B_B038h CLPS Reset ADCx_CLPS field descriptions Field Description 31–6...
  • Page 725 Chapter 31 Analog-to-Digital Converter (ADC) 31.3.14 ADC plus-side general calibration value register (ADCx_CLP3) For more information, refer to CLPD register description. Addresses: ADC0_CLP3 is 4003_B000h base + 40h offset = 4003_B040h ADC1_CLP3 is 400B_B000h base + 40h offset = 400B_B040h CLP3 Reset ADCx_CLP3 field descriptions...
  • Page 726 Register Definition 31.3.16 ADC plus-side general calibration value register (ADCx_CLP1) For more information, refer to CLPD register description. Addresses: ADC0_CLP1 is 4003_B000h base + 48h offset = 4003_B048h ADC1_CLP1 is 400B_B000h base + 48h offset = 400B_B048h CLP1 Reset ADCx_CLP1 field descriptions Field Description 31–7...
  • Page 727 Chapter 31 Analog-to-Digital Converter (ADC) 31.3.18 ADC PGA register (ADCx_PGA) Addresses: ADC0_PGA is 4003_B000h base + 50h offset = 4003_B050h ADC1_PGA is 400B_B000h base + 50h offset = 400B_B050h PGAG Reset Reset ADCx_PGA field descriptions Field Description 31–24 This read-only field is reserved and always has the value zero. Reserved PGA enable PGAEN...
  • Page 728 Register Definition ADCx_PGA field descriptions (continued) Field Description 1000 Reserved 1001 Reserved 1010 Reserved 1011 Reserved 1100 Reserved 1101 Reserved 1110 Reserved 1111 Reserved 15–0 This read-only field is reserved and always has the value zero. Reserved 31.3.19 ADC minus-side general calibration value register (ADCx_CLMD) CLMx contain calibration information that is generated by the calibration function.
  • Page 729 Chapter 31 Analog-to-Digital Converter (ADC) 31.3.20 ADC minus-side general calibration value register (ADCx_CLMS) For more information, refer to CLMD register description. Addresses: ADC0_CLMS is 4003_B000h base + 58h offset = 4003_B058h ADC1_CLMS is 400B_B000h base + 58h offset = 400B_B058h CLMS Reset ADCx_CLMS field descriptions...
  • Page 730 Register Definition 31.3.22 ADC minus-side general calibration value register (ADCx_CLM3) For more information, refer to CLMD register description. Addresses: ADC0_CLM3 is 4003_B000h base + 60h offset = 4003_B060h ADC1_CLM3 is 400B_B000h base + 60h offset = 400B_B060h CLM3 Reset ADCx_CLM3 field descriptions Field Description 31–9...
  • Page 731 Chapter 31 Analog-to-Digital Converter (ADC) 31.3.24 ADC minus-side general calibration value register (ADCx_CLM1) For more information, refer to CLMD register description. Addresses: ADC0_CLM1 is 4003_B000h base + 68h offset = 4003_B068h ADC1_CLM1 is 400B_B000h base + 68h offset = 400B_B068h CLM1 Reset ADCx_CLM1 field descriptions...
  • Page 732 Functional description 31.4 Functional description The ADC module is disabled during reset, in low power stop mode (refer to the Power Management information for details), or when the ADCH bits in SC1n are all high. The module is idle when a conversion has completed and another conversion has not been initiated.
  • Page 733 Chapter 31 Analog-to-Digital Converter (ADC) The PGA has only one voltage reference pair. The positive reference used is chip specific and depends on the MCU configuration. Refer to the Chip Configuration chapter on the PGA Voltage Reference specific to this MCU. The ground reference is the analog ground for the PGA.
  • Page 734 Functional description 31.4.3 Voltage reference selection The ADC can be configured to accept one of the two voltage reference pairs as the reference voltage (V and V ) used for conversions. Each pair contains a REFSH REFSL positive reference that must be between the minimum Ref Voltage High and V , and a ground reference that must be at the same potential as V .
  • Page 735 Chapter 31 Analog-to-Digital Converter (ADC) When the conversion is completed, the result is placed in the data registers associated with the ADHWTSn received (ADHWTSA active selects RA register; ADHWTSn active selects Rn register). The conversion complete flag associated with the ADHWTSn received (the COCO bit in SC1n register) is then set and an interrupt is generated if the respective conversion complete interrupt has been enabled (AIEN=1).
  • Page 736 Functional description If continuous conversions are enabled, a new conversion is automatically initiated after the completion of the current conversion. In software triggered operation (ADTRG=0), continuous conversions begin after SC1A register is written and continue until aborted. In hardware triggered operation (ADTRG=1 and one ADHWTSn event has occurred), continuous conversions begin after a hardware trigger event and continue until aborted.
  • Page 737 Chapter 31 Analog-to-Digital Converter (ADC) • The MCU is reset or enters Low Power Stop modes. • The MCU enters Normal Stop mode with ADACK not enabled. 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.
  • Page 738 Functional description ADC Configuration Sample time (ADCK cycles) The total conversion time depends upon: the sample time (as determined by ADLSMP and ADLSTS bits), the MCU bus frequency, the conversion mode (as determined by MODE and SC1n[DIFF] bits), the high speed configuration (ADHSC bit), and the frequency of the conversion clock (f ADCK The ADHSC bit is used to configure a higher clock input frequency.
  • Page 739 Chapter 31 Analog-to-Digital Converter (ADC) Table 31-108. Average number factor (AverageNum) AVGE AVGS[1:0] Average number factor (AverageNum) Table 31-109. Base Conversion Time (BCT) Mode Base conversion time (BCT) 8b s.e. 17 ADCK cycles 9b diff 27 ADCK cycles 10b s.e. 20 ADCK cycles 11b diff 30 ADCK cycles...
  • Page 740 Functional description 31.4.5.6 Conversion time examples The following examples use Figure 31-95 and the information provided in Table 31-107 through Table 31-111. 31.4.5.6.1 Typical conversion time configuration A typical configuration for ADC conversion is: 10-bit mode, with the bus clock selected as the input clock source, the input clock divide-by-1 ratio selected, and a bus frequency of 8 MHz, long sample time disabled and high speed conversion disabled.
  • Page 741 Chapter 31 Analog-to-Digital Converter (ADC) Table 31-113. Typical conversion time (continued) Variable Time HSCAdder 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 (AverageNum).
  • Page 742 Functional description After the selected input is sampled and converted, the result is placed in an accumulator from which an average is calculated once the selected number of conversions has been completed. When hardware averaging is selected, the completion of a single conversion will not set the COCO bit.
  • Page 743 Chapter 31 Analog-to-Digital Converter (ADC) With the ADC range enable bit set, ACREN =1, and if compare value register 1 (CV1 value) is less than or equal to the compare value register 2 (CV2 value), then setting ACFGT will select a trigger-if-inside-compare-range inclusive-of-endpoints function. Clearing ACFGT will select a trigger-if-outside-compare-range, not-inclusive-of- endpoints function.
  • Page 744 Functional description for the different configurations. For best calibration results, it is recommended to set hardware averaging to maximum (AVGE=1, AVGS=11 for average of 32), ADC clock frequency f less than or equal to 4 MHz, V , and to calibrate at nominal ADCK REFH voltage and temperature.
  • Page 745 Chapter 31 Analog-to-Digital Converter (ADC) stored in flash memory after an initial calibration and recovered prior to the first ADC conversion. This method should reduce the calibration latency to 20 register store operations on all subsequent power, reset, or Low Power Stop mode recoveries. 31.4.8 User defined offset function The ADC offset correction register (OFS) contains the user selected or calibration generated offset error correction value.
  • Page 746 Functional description format and the effect will be an addition. An offset correction that results in an out-of- range value will be forced to the minimum or maximum value (the minimum value for single-ended conversions is 0x0000; for a differential conversion it is 0x8000). To preserve accuracy, the calibrated offset value initially stored in the OFS register must be added to the user defined offset.
  • Page 747 Chapter 31 Analog-to-Digital Converter (ADC) 31.4.10 MCU wait mode operation Wait mode is a lower power-consumption standby mode from which recovery is fast because the clock sources remain active. If a conversion is in progress when the MCU enters Wait mode, it continues until completion. Conversions can be initiated while the MCU is in Wait mode by means of the hardware trigger or if continuous conversions are enabled.
  • Page 748 Initialization information 31.4.11.2 Normal Stop mode with ADACK enabled If ADACK is selected as the conversion clock, the ADC continues operation during Normal Stop mode. Refer to the Chip Configuration chapter for configuration information for this MCU. If a conversion is in progress when the MCU enters Normal Stop mode, it continues until completion.
  • Page 749 Chapter 31 Analog-to-Digital Converter (ADC) Note Hexadecimal values are designated by a preceding 0x, binary values designated by a preceding %, and decimal values have no preceding character. 31.5.1 ADC module initialization example This section provides details about the ADC module initialization. 31.5.1.1 Initialization sequence Before the ADC module can be used to complete conversions, an initialization procedure must be performed.
  • Page 750 Initialization information CFG1 = 0x98 (%10011000) Bit 7 ADLPC Configures for low power (lowers maximum clock speed. Bit 6:5 ADIV Sets the ADCK to the input clock ÷ 1. Bit 4 ADLSMP Configures for long sample time. Bit 3:2 MODE Selects the single-ended 10-bit conversion, differential 11- bit conversion.
  • Page 751 Chapter 31 Analog-to-Digital Converter (ADC) Reset Initialize ADC CFG1 = 0x98 SC2 = 0x00 SC1n = 0x41 Check SC1n[COCO]=1? Read Rn to clear SC1n[COCO] bit Continue Figure 31-97. Initialization Flowchart for Example 31.6 Application information This section contains information for using the ADC module in applications. The ADC has been designed to be integrated into a microcontroller for use in embedded control applications requiring an ADC.
  • Page 752 Application information supply pins. In these cases, there are separate pads for the analog supplies bonded to the same pin as the corresponding digital supply so that some degree of isolation between the supplies is maintained. When available on a separate pin, both V and V must be connected to the same voltage potential as their corresponding MCU digital supply (V...
  • Page 753 Chapter 31 Analog-to-Digital Converter (ADC) frequency characteristics. This capacitor is connected between V and V REFH REFL must be placed as near as possible to the package pins. Resistance in the path is not recommended because the current causes a voltage drop that could result in conversion errors.
  • Page 754 Application information SC = Number of ADCK cycles used during sample window CADIN = Internal ADC input capacitance NUMTAU = -ln(LSBERR / 2 LSBERR = value of acceptable sampling error in LSBs N = 8 in 8-bit mode, 10 in 10-bit mode, 12 in 12-bit mode or 16 in 16-bit mode Higher source resistances or higher-accuracy sampling is possible by setting ADLSMP and changing the ADLSTS bits (to increase the sample window) or decreasing ADCK frequency to increase sample time.
  • Page 755 Chapter 31 Analog-to-Digital Converter (ADC) • For software triggered conversions, immediately follow the write to the SC1 register with a wait instruction or stop instruction. • For Normal Stop mode operation, select ADACK as the clock source. Operation in Normal Stop reduces V noise but increases effective conversion time due to stop recovery.
  • Page 756 Application information 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. 31.6.2.5 Linearity errors The ADC may also exhibit non-linearity of several forms. Every effort has been made to reduce these errors, but the system designers should be aware of them because they affect overall accuracy.
  • Page 757 Chapter 31 Analog-to-Digital Converter (ADC) This error may be reduced by repeatedly sampling the input and averaging the result. Additionally, the techniques discussed in Noise-induced errors reduces this error. Non-monotonicity is defined as when, except for code jitter, the converter converts to a lower code for a higher input voltage.
  • Page 758 Application information K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 759 Chapter 32 Comparator (CMP) 32.1 Introduction NOTE For the chip-specific implementation details of this module's instances see the chip configuration chapter. The Comparator module (CMP) provides a circuit for comparing two analog input voltages. The comparator circuit is designed to operate across the full range of the supply voltage (rail to rail operation).
  • Page 760 6-bit DAC Key Features • Selectable interrupt on rising edge, falling edge, or both rising or falling edges of comparator output • Selectable inversion on comparator output • Comparator output may be: • Sampled • Windowed (ideal for certain PWM zero-crossing-detection applications) •...
  • Page 761 Chapter 32 Comparator (CMP) 32.4 ANMUX Key Features • Two 8 to 1 channel mux • Operates the entire supply range 32.5 CMP, DAC, and ANMUX Diagram The following figure shows the block diagram for the High Speed Comparator, Digital to Analog Converter, and Analog MUX modules.
  • Page 762 CMP Block Diagram VRSEL VOSEL[5:0] DACEN DAC output PSEL[2:0] Reference Input 0 Reference Input 1 Reference Input 2 Reference Input 3 Reference Input 4 Sample Input Reference Input 5 Reference Input 6 Window ANMUX and Filter control CMPO MSEL[2:0] Figure 32-1. CMP, DAC and ANMUX Blocks Diagram 32.6 CMP Block Diagram The following figure shows the block diagram for the Comparator module.
  • Page 763 Chapter 32 Comparator (CMP) INTERNAL BUS FILT_PER FILTER_CNT COUT IER/F CFR/F EN,PMODE,HYSCTRL[1:0] Window Interrupt Polarity Filter Control Select Control Block CMPO COUT (TO OTHER SOC FUNCTIONS)) WINDOW/SAMPLE bus clock Clock COUTA CMPO to divided Prescaler FILT_PER CGMUX clock Figure 32-2. Comparator Module Block Diagram In the CMP block diagram: •...
  • Page 764 Memory Map/Register Definitions • If enabled, the Filter Block will incur up to 1 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. •...
  • Page 765 Chapter 32 Comparator (CMP) CMP memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 32.7.3/ 4007_3012 CMP Filter Period Register (CMP2_FPR) 32.7.4/ 4007_3013 CMP Status and Control Register (CMP2_SCR) 32.7.5/ 4007_3014 DAC Control Register (CMP2_DACCR) 32.7.6/ 4007_3015 MUX Control Register (CMP2_MUXCR)
  • Page 766 Memory Map/Register Definitions CMPx_CR0 field descriptions (continued) Field Description This read-only field is reserved and always has the value zero. Reserved 1–0 Comparator hard block hysteresis control HYSTCTR Defines the programmable hysteresis level. The hysteresis values associated with each level is device- specific.
  • Page 767 Chapter 32 Comparator (CMP) CMPx_CR1 field descriptions (continued) Field Description Refer to the device data sheet's CMP electrical specifications table for details on the impact of the modes below. Low Speed (LS) comparison mode selected. In this mode, CMP has slower output propagation delay and lower current consumption.
  • Page 768 Memory Map/Register Definitions CMPx_FPR field descriptions Field Description 7–0 Filter Sample Period FILT_PER When CR1[SE] is equal to zero, this field specifies the sampling period, in bus clock cycles, of the comparator output filter. Setting FILT_PER to 0x0 disables the filter. Filter programming and latency details appear in the Functional Description.
  • Page 769 Chapter 32 Comparator (CMP) CMPx_SCR field descriptions (continued) Field Description Interrupt disabled. Interrupt enabled. Comparator Interrupt Enable Falling The IEF bit enables the CFF interrupt from the CMP. When this bit is set, an interrupt will be asserted when the CFF bit is set. Interrupt disabled.
  • Page 770 Memory Map/Register Definitions CMPx_DACCR field descriptions Field Description DAC Enable DACEN This bit is used to enable the DAC. When the DAC is disabled, it is powered down to conserve power. DAC is disabled. DAC is enabled. Supply Voltage Reference Source Select VRSEL is selected as resistor ladder network supply reference Vin.
  • Page 771 Chapter 32 Comparator (CMP) CMPx_MUXCR field descriptions (continued) Field Description 5–3 Plus Input MUX Control PSEL Determines which input is selected for the plus input of the comparator. For INx inputs, refer to CMP, DAC and ANMUX Blocks Diagram. 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.
  • Page 772 CMP Functional Description 32.8.1 CMP Functional Modes There are three main sub-blocks to the comparator module: the comparator itself, the window function and the filter function. The filter, CR0[FILTER_CNT] can be clocked from an internally or external clock source. Additionally, the filter is programmable with respect to how many samples must agree before a change on the output is registered.
  • Page 773 Chapter 32 Comparator (CMP) Table 32-29. Comparator Sample/Filter Controls (continued) CR0[FILTER_C Mode # CR1[EN] CR1[WE] CR1[SE] FPR[FILT_PER] Operation 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.
  • Page 774 CMP Functional Description 32.8.1.2 Continuous Mode (#s 2A & 2B) INTERNAL BUS FILT_PER FILTER_CNT COUT IER/F CFR/F EN,PMODE,HYSTCTR[1:0] Window Interrupt Polarity Filter Control Select Control Block CMPO COUT (TO OTHER SOC FUNCTIONS)) WINDOW/SAMPLE bus clock Clock COUTA CMPO to divided Prescaler FILT_PER CGMUX...
  • Page 775 Chapter 32 Comparator (CMP) 32.8.1.3 Sampled, Non-Filtered Mode (#s 3A & 3B) INTERNAL BUS FILT_PER FILTER_CNT COUT IER/F CFR/F EN,PMODE,HYSTCTR[1:0] 0x01 Window Interrupt Polarity Filter Control Select Control Block CMPO COUT (TO OTHER SOC FUNCTIONS) WINDOW/SAMPLE bus clock Clock COUTA CMPO to divided Prescaler...
  • Page 776 CMP Functional Description INTERNAL BUS FILT_PER EN,PMODE,HYSTCTR[1:0] FILTER_CNT COUT IER/F CFR/F 0x01 Window Interrupt Polarity Filter Control Select Control Block CMPO COUT (TO OTHER SOC FUNCTIONS)) WINDOW/SAMPLE bus clock Clock COUTA CMPO to divided bus clock Prescaler FILT_PER CGMUX SE=0 Figure 32-29.
  • Page 777 Chapter 32 Comparator (CMP) INTERNAL BUS FILT_PER FILTER_CNT COUT IER/F CFR/F EN, PMODE, HYSTCTR[1:0] > 0x01 Window Interrupt Polarity Filter Control Select Control Block CMPO COUT (TO OTHER SOC FUNCTIONS) WINDOW/SAMPLE bus clock Clock COUTA CMPO to divided Prescaler FILT_PER CGMUX clock SE=1...
  • Page 778 CMP Functional Description INTERNAL BUS FILT_PER FILTER_CNT COUT IER/F CFR/F EN, PMODE,HYSTCTR[1:0 > 0x01 Window Interrupt Polarity Filter Control Select Control Block CMPO COUT (TO OTHER SOC FUNCTIONS)) WINDOW/SAMPLE bus clock Clock COUTA CMPO to divided Prescaler FILT_PER CGMUX clock SE=0 Figure 32-31.
  • Page 779 Chapter 32 Comparator (CMP) WI NDOW Plus input Minus input CMPO COUTA Figure 32-32. Windowed Mode Operation INTERNAL BUS FILT_PER FILTER_CNT COUT IER/F CFR/F EN, PMODE,HYSCTR[1:0] 0x01 Window Interrupt Polarity Filter Control Select Control Block CMPO COUT (TO OTHER SOC FUNCTIONS)) WINDOW/SAMPLE bus clock Clock...
  • Page 780 CMP Functional Description 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. 32.8.1.6 Windowed/Resampled Mode (# 6) The following figure uses the same input stimulus shown in Figure 32-32, and adds resampling of COUTA to generate COUT.
  • Page 781 Chapter 32 Comparator (CMP) 32.8.1.7 Windowed/Filtered Mode (#7) This is the most complex mode of operation for the comparator block, as it utilizes both windowing and filtering features. It also has the highest latency of any of the modes. This can be approximated: up to 1 bus clock synchronization in the window function + ((CR0[FILTER_CNT] X FPR[FILT_PER]) + 1) X bus clock for the filter function.
  • Page 782 CMP Functional Description 32.8.2.2 Stop Mode Operation Subject to platform-specific clock restrictions, the MCU is brought out of stop when a compare event occurs and the corresponding interrupt is enabled. Similarly, if CR1[OPE] is enabled, the comparator output operates as in the normal operating mode and comparator output is placed onto the external pin.
  • Page 783 Chapter 32 Comparator (CMP) 32.8.4 Low Pass Filter The low-pass filter operates on the unfiltered and unsynchronized and optionally inverted comparator output COUTA and generates the filtered and synchronized output COUT. Both COUTA and COUT can be configured as module outputs and are used for different purposes within the system.
  • Page 784 CMP Functional Description 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 CR0[FILTER_CNT] consecutive samples all agree that the output value has changed. 32.8.4.2 Latency Issues The FPR[FILT_PER] value (or SAMPLE period) should be set such that the sampling period is just larger than the period of the expected noise.
  • Page 785 Chapter 32 Comparator (CMP) Table 32-30. Comparator Sample/Filter Maximum Latencies (continued) CR1[ CR1[ CR1[ CR0[FILTER FPR[FILT_P Mode # Operation Maximum Latency _CNT] > 0x01 0x01 - 0xFF Windowed / Filtered mode + (CR0[FILTER_CNT] x FPR[FILT_PER] x T 1. T represents the intrinsic delay of the analog component plus the polarity select logic. T is the clock period of the SAMPLE external sample clock.
  • Page 786 DAC Functional Description DACEN VOSEL[5:0] VRSEL DACO Figure 32-36. 6-bit DAC Block Diagram 32.12 DAC Functional Description This section provides DAC functional description. 32.12.1 Voltage Reference Source Select • V should be used to connect to the primary voltage source as supply reference of 64 tap resistor ladder •...
  • Page 787 Chapter 32 Comparator (CMP) 32.15 DAC Interrupts This module has no interrupts. K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 788 DAC Interrupts K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 789 Chapter 33 12-bit Digital-to-Analog Converter (DAC) 33.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, Op-Amps, ADC, or other peripherals.
  • Page 790 Memory Map/Register Definition DACREF_2 DACREF_1 DACRFS DACRFS AMP Buffer DACEN LPEN Vout DACDAT[11:0] Hardware Trigger DACBFWMF & DACBWIEN DACSWTRG DACBFWM DACBFRPTF dac_interrupt DATA & DACBFEN BUFFER DACBTIEN DACBFUP DACBFRPBF DACBFRP & DACBBIEN DACBFMD DACTRGSE Figure 33-1. DAC Block Diagram 33.4 Memory Map/Register Definition The DAC has registers to control analog comparator and programmable voltage divider to perform the digital-to-analog functions.
  • Page 791 Chapter 33 12-bit Digital-to-Analog Converter (DAC) DAC memory map Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 33.4.1/ 400C_C000 DAC Data Low Register (DAC0_DAT0L) 33.4.2/ 400C_C001 DAC Data High Register (DAC0_DAT0H) 33.4.1/ 400C_C002 DAC Data Low Register (DAC0_DAT1L) 33.4.2/ 400C_C003 DAC Data High Register (DAC0_DAT1H)
  • Page 792 Memory Map/Register Definition DAC memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 33.4.1/ 400C_C014 DAC Data Low Register (DAC0_DAT10L) 33.4.2/ 400C_C015 DAC Data High Register (DAC0_DAT10H) 33.4.1/ 400C_C016 DAC Data Low Register (DAC0_DAT11L) 33.4.2/ 400C_C017 DAC Data High Register (DAC0_DAT11H)
  • Page 793 Chapter 33 12-bit Digital-to-Analog Converter (DAC) DAC memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 33.4.1/ 400C_D004 DAC Data Low Register (DAC1_DAT2L) 33.4.2/ 400C_D005 DAC Data High Register (DAC1_DAT2H) 33.4.1/ 400C_D006 DAC Data Low Register (DAC1_DAT3L) 33.4.2/ 400C_D007 DAC Data High Register (DAC1_DAT3H)
  • Page 794 Memory Map/Register Definition DAC memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 33.4.1/ 400C_D018 DAC Data Low Register (DAC1_DAT12L) 33.4.2/ 400C_D019 DAC Data High Register (DAC1_DAT12H) 33.4.1/ 400C_D01A DAC Data Low Register (DAC1_DAT13L) 33.4.2/ 400C_D01B DAC Data High Register (DAC1_DAT13H) 33.4.1/...
  • Page 795 Chapter 33 12-bit Digital-to-Analog Converter (DAC) 33.4.2 DAC Data High Register (DACx_DATH) Addresses: 400C_C000h base + 1h offset + (2d × n), where n = 0d to 15d Read DATA[11:8] Write Reset DACx_DATnH field descriptions Field Description 7–4 This read-only field is reserved and always has the value zero. Reserved 3–0 When the DAC Buffer is not enabled, DATA[11:0] controls the output voltage based on the following...
  • Page 796 Memory Map/Register Definition DACx_SR field descriptions (continued) Field Description The DAC buffer read pointer is not zero. The DAC buffer read pointer is zero. DAC buffer read pointer bottom position flag DACBFRPBF The DAC buffer read pointer is not equal to the DACBFUP. The DAC buffer read pointer is equal to the DACBFUP.
  • Page 797 Chapter 33 12-bit Digital-to-Analog Converter (DAC) DACx_C0 field descriptions (continued) Field Description high power mode. low power mode. DAC buffer watermark interrupt enable DACBWIEN The DAC buffer watermark interrupt is disabled. The DAC buffer watermark interrupt is enabled. DAC buffer read pointer top flag interrupt enable DACBTIEN The DAC buffer read pointer top flag interrupt is disabled.
  • Page 798 Functional Description DACx_C1 field descriptions (continued) Field Description 2–1 DAC buffer work mode select DACBFMD Normal Mode Swing Mode One-Time Scan Mode Reserved DAC buffer enable DACBFEN Buffer read pointer disabled. The converted data is always the first word of the buffer. Buffer read pointer enabled.
  • Page 799 Chapter 33 12-bit Digital-to-Analog Converter (DAC) 33.5.1 DAC Data Buffer Operation When the DAC is enabled and the buffer is not enabled, the DAC module always converts the data in DAT0 to analog output voltage. When both the DAC and the buffer are enabled, the DAC converts the data in the data buffer to analog output voltage.
  • Page 800 Functional Description 33.5.1.4 Buffer One-time Scan Mode The read pointer increases by one every time when the trigger occurs. When it reaches the upper limit, it stops at there. If read pointer is reset to the address other than the upper limit, it will increase to the upper address and stop at there again.
  • Page 801 Chapter 33 12-bit Digital-to-Analog Converter (DAC) 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. K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 802 Functional Description K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 803 Chapter 34 Operational Amplifier (OPAMP) 34.1 Introduction NOTE For the chip-specific implementation details of this module's instances see the chip configuration chapter. The General Purpose Operational Amplifier (OPAMP) block is a CMOS single supply, low-input offset voltage, low-input offset, and bias current amplifier that is designed for low-voltage, low-power operation over an input voltage range of 0 to supply.
  • Page 804 Introduction 34.1.2 Block Diagram This diagram illustrates the op-amp module. NOTE The positive and negative inputs are specific to the device using this module. See the device's Chip Configuration details for the connections used for these inputs. AMPNSEL Inverting/ AMPRF Negative Input 0 non-inverting Negative Input 1...
  • Page 805 Chapter 34 Operational Amplifier (OPAMP) 34.1.4 Operating modes The following table shows the valid C0[MODE] and C1[AMPRI, AMPRF] settings. Using a reserved mode results in unpredictable behavior. Table 34-1. Operating modes C0[MODE] C1[AMPRI] C1[AMPRF] Gain Function — Buffer mode — General amplifier mode —...
  • Page 806 Introduction Table 34-1. Operating modes (continued) C0[MODE] C1[AMPRI] C1[AMPRF] Gain Function — Reserved — Reserved — Reserved — Reserved — Reserved — Reserved Inverting PGA mode Inverting PGA mode — Reserved Non-inverting PGA mode Non-inverting PGA mode Non-inverting PGA mode Non-inverting PGA mode Non-inverting PGA mode Non-inverting PGA mode...
  • Page 807 Chapter 34 Operational Amplifier (OPAMP) Table 34-1. Operating modes (continued) C0[MODE] C1[AMPRI] C1[AMPRF] Gain Function — Reserved — Reserved — Reserved — Reserved — Reserved — Reserved Non-inverting PGA mode Non-inverting PGA mode 34.2 Signal Description Table 34-2. Signal Properties Name Description Amplifier positive input terminal...
  • Page 808 Memory Map and Registers 34.3 Memory Map and Registers This section provides a detailed description of all memory and registers. OPAMP memory map Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 34.3.1/ 400F_5000 Control Register 0 (OPAMP0_C0) 34.3.2/ 400F_5001 Control Register 1 (OPAMP0_C1)
  • Page 809 Chapter 34 Operational Amplifier (OPAMP) OPAMPx_C0 field descriptions (continued) Field Description High-speed mode selected. In this mode, OPAMP has faster slew rate and unity gain bandwidth performance with higher current consumption. Low-power mode selected. In this mode, OPAMP has lower current consumption with slower slew rate and unity gain bandwidth performance.
  • Page 810 Memory Map and Registers 34.3.3 Control Register 2 (OPAMPx_C2) Addresses: OPAMP0_C2 is 400F_5000h base + 2h offset = 400F_5002h OPAMP1_C2 is 400F_5800h base + 2h offset = 400F_5802h Read AMPPSEL AMPNSEL Write Reset OPAMPx_C2 field descriptions Field Description This read-only field is reserved and always has the value zero. Reserved 6–4 Amplifier Positive Input Terminal Selector...
  • Page 811 Chapter 34 Operational Amplifier (OPAMP) 34.4 Functional Description This section provides a complete functional description of the OPAMP block, detailing the operation of the design from the end-user perspective. 34.4.1 Operational Amplifier Configuration The following is a block diagram of the OPAMP module in general purpose mode. AMPNSEL Inverting/ AMPRF...
  • Page 812 Functional Description AMPNSEL Inverting/ AMPRF Negative Input 0 non-inverting Negative Input 1 AMPRI control Negative Input 2 Negative Input 3 Negative Input 4 Negative Input 5 Programmable Negative Input 6 resistor network Negative Input 7 Mode select MODE Positive Input 0 Positive Input 1 Positive Input 2 –...
  • Page 813 Chapter 34 Operational Amplifier (OPAMP) AMPNSEL Inverting/ AMPRF Negative Input 0 non-inverting Negative Input 1 AMPRI control Negative Input 2 Negative Input 3 Negative Input 4 Negative Input 5 Programmable Negative Input 6 resistor network Negative Input 7 Mode select MODE Positive Input 0 Positive Input 1...
  • Page 814 Functional Description K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 815 Chapter 35 Transimpedance Amplifier (TRIAMP) 35.1 Introduction NOTE For the chip-specific implementation details of this module's instances see the chip configuration chapter. The TRIAMP block is a CMOS single supply, low input offset voltage, low input offset and bias current amplifier that is designed for low-voltage, low-power operation. The TRIAMP also has control settings that can be software-configured depending on application requirements.
  • Page 816 Introduction 35.1.3 Block Diagram This diagram illustrates the TRIAMP module. lpen_lv inn_3v – out_3v inp_3v en_lv Figure 35-1. TRIAMP Block Diagram 35.1.4 Signal Description The TRIAMP module has the following external pins. Table 35-1. Signal Properties Name Function Direction inp_3v Amplifier positive input terminal inn_3v Amplifier negative input terminal...
  • Page 817 Chapter 35 Transimpedance Amplifier (TRIAMP) 35.2 Memory Map/Register Definition TRIAMP memory map Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 35.2.1/ 400F_8000 Control Register 0 (TRIAMP0_C0) 35.2.1/ 400F_8800 Control Register 0 (TRIAMP1_C0) 35.2.1 Control Register 0 (TRIAMPx_C0) Addresses: TRIAMP0_C0 is 400F_8000h base + 0h offset = 400F_8000h TRIAMP1_C0 is 400F_8800h base + 0h offset = 400F_8800h Read...
  • Page 818 Functional Description 35.3 Functional Description This section provides a complete functional description of the TRIAMP block, detailing the operation of the design from the end-user perspective. 35.3.1 Trans-Impedance Amplifier Configuration 35.3.2 Photodiode Zero-Biased Operation The following figure shows a typical application (supply is 3 V) diagram of the TRIAMP module.
  • Page 819 Chapter 35 Transimpedance Amplifier (TRIAMP) out_3v I photo inn_3v λ photodiode OUT=V photo inp_3v 1.6 > V dac > 0 off_chip Figure 35-6. Reverse-Biased Application Diagram Table 35-8. TRIAMP Module OUT = I × R (Ω) photo photo 1 nA 0.201 V 10 nA 0.210 V...
  • Page 820 Functional Description K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 821 Chapter 36 Voltage Reference (VREFV1) 36.1 Introduction NOTE For the chip-specific implementation details of this module's instances see the chip configuration chapter. The VREFV1 Voltage Reference is intended to supply an accurate voltage output that can be trimmed in 0.5 mV steps. The VREFV1 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.
  • Page 822 Introduction 1.75 V Regulator SC[VREFST] 1.75 V 6 BITS DEDICATED BANDGAP OUTPUT PIN VDDA SC[VREFEN] VREF_OUT 2 BITS SC[MODE_LV] 100 nF REGULATION BUFFER VSSA Figure 36-1. Voltage reference block diagram 36.1.1 Overview The Voltage Reference provides a buffered reference voltage with high output current for use as an external reference.
  • Page 823 Chapter 36 Voltage Reference (VREFV1) • Bandgap enabled/standby (output buffer disabled) • Tight-regulation buffer mode (output buffer enabled) • 1.2 V output at room temperature • Dedicated output pin, VREF_OUT • Load regulation in tight-regulation mode 36.1.3 Modes of Operation The Voltage Reference continues normal operation in Run, Wait, and Stop modes.
  • Page 824 Memory Map and Register Definition VREF memory map Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 36.2.1/ 4007_4000 VREF Trim Register (VREF_TRM) Undefined 36.2.2/ 4007_4001 VREF Status and Control Register (VREF_SC) 36.2.1 VREF Trim Register (VREF_TRM) This register contains bits that contain the trim data for the Voltage Reference.
  • Page 825 Chapter 36 Voltage Reference (VREFV1) 36.2.2 VREF Status and Control Register (VREF_SC) This register contains the control bits used to enable the internal voltage reference and to select the VREF mode to be used. Address: VREF_SC is 4007_4000h base + 1h offset = 4007_4001h Read VREFST VREFEN...
  • Page 826 Functional Description VREF_SC field descriptions (continued) Field Description Tight-regulation buffer enabled Reserved 36.3 Functional Description The Voltage Reference is a bandgap buffer system. Unity gain amplifiers are used. The VREF_OUT signal is available as an internal reference when it is enabled. A 100 nF capacitor must be connected between VREF_OUT and VSSA.
  • Page 827 Chapter 36 Voltage Reference (VREFV1) 36.3.2.1 SC[MODE_LV]=00 The internal 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.
  • Page 828 Initialization/Application Information When the Voltage Reference is already enabled and stabilized, changing SC[MODE_LV] will not clear SC[VREFST] but there will be some startup time before the output voltage at the VREF_OUT pin has settled. This is the buffer start up delay (Tstup) and the value is specified in the appropriate device data sheet.
  • Page 829 Chapter 37 Programmable Delay Block (PDB) 37.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.
  • Page 830 Introduction • Optional back-to-back mode operation, which enables the ADC conversions complete to trigger the next PDB channel • One programmable delay interrupt • One sequence error interrupt • One channel flag and one sequence error flag per pre-trigger • DMA support •...
  • Page 831 Chapter 37 Programmable Delay Block (PDB) • Y — Total number of Pulse-Out's. • y — Pulse-Out number, valid value is 0 to Y-1. NOTE The number of module output triggers to core are chip-specific. For module to core output triggers implementation, refer to the Chip Configuration information.
  • Page 832 Introduction Ack 0 PDBCHnDLY0 Pre-trigger 0 BB[0], TOS[0] EN[0] Ch n pre-trigger 0 Ack m PDBCHnDLYm Pre-trigger m BB[m], TOS[m] EN[m] Ch n pre-trigger m Sequence Error Detection ERR[M - 1:0] Ch n trigger PDBMOD Control DACINTx Logic DAC interval trigger x PDBCNT DAC Interval Counter x...
  • Page 833 Chapter 37 Programmable Delay Block (PDB) 37.1.6 Modes of Operation PDB ADC trigger operates in the following modes. Disabled: Counter is off, all pre-trigger and trigger outputs are low if PDB is not in back- to-back operation of Bypass mode. Debug: Counter is paused when processor is in debug mode, the counter for dac trigger also paused in Debug mode.
  • Page 834 Memory Map and Register Definition PDB memory map Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 37.3.1/ 4003_6000 Status and Control Register (PDB0_SC) 0000_0000h 37.3.2/ 4003_6004 Modulus Register (PDB0_MOD) 0000_FFFFh 37.3.3/ 4003_6008 Counter Register (PDB0_CNT) 0000_0000h 37.3.4/ 4003_600C...
  • Page 835 Chapter 37 Programmable Delay Block (PDB) 37.3.1 Status and Control Register (PDBx_SC) Addresses: PDB0_SC is 4003_6000h base + 0h offset = 4003_6000h LDMOD Reset PRESCALER TRGSEL MULT Reset PDBx_SC field descriptions Field Description 31–20 This read-only field is reserved and always has the value zero. Reserved 19–18 Load Mode Select...
  • Page 836 Memory Map and Register Definition PDBx_SC field descriptions (continued) Field Description DMA Enable DMAEN When DMA is enabled, the PDBIF flag generates a DMA request instead of an interrupt. DMA disabled DMA enabled 14–12 Prescaler Divider Select PRESCALER Counting uses the peripheral clock divided by multiplication factor selected by MULT. Counting uses the peripheral clock divided by twice of the multiplication factor selected by MULT.
  • Page 837 Chapter 37 Programmable Delay Block (PDB) PDBx_SC field descriptions (continued) Field Description This bit is set when the counter value is equal to the IDLY register. Writing zero clears this bit. PDB Interrupt Enable. PDBIE This bit enables the PDB interrupt. When this bit is set and DMAEN is cleared, PDBIF generates a PDB interrupt.
  • Page 838 Memory Map and Register Definition PDBx_MOD field descriptions Field Description 31–16 This read-only field is reserved and always has the value zero. Reserved 15–0 PDB Modulus. These bits specify the period of the counter. When the counter reaches this value, it will be reset back to zero.
  • Page 839 Chapter 37 Programmable Delay Block (PDB) PDBx_IDLY field descriptions (continued) Field Description These bits specify the delay value to schedule the PDB interrupt. It can be used to schedule an independent interrupt at some point in the PDB cycle. If enabled, a PDB interrupt is generated, when the counter is equal to the IDLY.
  • Page 840 Memory Map and Register Definition PDBx_CHnC1 field descriptions (continued) Field Description These bits enable the PDB ADC pre-trigger outputs. Only lower M pre-trigger bits are implemented in this MCU. PDB channel's corresponding pre-trigger disabled. PDB channel's corresponding pre-trigger enabled. 37.3.6 Channel n Status Register (PDBx_CHS) Addresses: PDB0_CH0S is 4003_6000h base + 14h offset = 4003_6014h PDB0_CH1S is 4003_6000h base + 3Ch offset = 4003_603Ch Reset...
  • Page 841 Chapter 37 Programmable Delay Block (PDB) 37.3.7 Channel n Delay 0 Register (PDBx_CHDLY0) Addresses: PDB0_CH0DLY0 is 4003_6000h base + 18h offset = 4003_6018h PDB0_CH1DLY0 is 4003_6000h base + 40h offset = 4003_6040h Reset PDBx_CHnDLY0 field descriptions Field Description 31–16 This read-only field is reserved and always has the value zero. Reserved 15–0 PDB Channel Delay...
  • Page 842 Memory Map and Register Definition 37.3.9 DAC Interval Trigger n Control Register (PDBx_DACINTCn) Addresses: PDB0_DACINTC0 is 4003_6000h base + 150h offset = 4003_6150h PDB0_DACINTC1 is 4003_6000h base + 158h offset = 4003_6158h Reset PDBx_DACINTCn field descriptions Field Description 31–2 This read-only field is reserved and always has the value zero. Reserved DAC External Trigger Input Enable This bit enables the external trigger for DAC interval counter.
  • Page 843 Chapter 37 Programmable Delay Block (PDB) PDBx_DACINTn field descriptions (continued) Field Description 15–0 DAC Interval These bits specify the interval value for DAC interval trigger. DAC interval trigger triggers DAC[1:0] update when the DAC interval counter is equal to the DACINT. Reading these bits returns the value of internal register that is effective for the current PDB cycle.
  • Page 844 Functional Description PDBx_POnDLY field descriptions (continued) Field Description These bits specify the delay 1 value for the PDB Pulse-Out. Pulse-Out goes high when the PDB counter is equal to the DLY1. Reading these bits returns the value of internal register that is effective for the current PDB cycle.
  • Page 845 Chapter 37 Programmable Delay Block (PDB) Trigger input event Ch n pre-trigger 0 Ch n pre-trigger 1 .... Ch n pre-trigger M Ch n trigger Figure 37-52. Pre-trigger and Trigger Outputs The delay in CHnDLYm register can be optionally bypassed, if CHnC1[TOS[m]] is cleared.
  • Page 846 Functional Description 37.4.2 PDB Trigger Input Source Selection The PDB has up to 15 trigger input sources, namely Trigger-In 0 to 14. They are connected to on-chip or off-chip event sources. The PDB can be triggered by software through the SC[SWTRIG]. SC[TRIGSEL] bits select the active trigger input source or software trigger.
  • Page 847 Chapter 37 Programmable Delay Block (PDB) MOD, IDLY CHnDLY1 CHnDLY0 DACINTx x3 DACINTx x2 DACINTx counter Trigger input event .... DAC internal trigger x Ch n pre-trigger 0 Ch n pre-trigger 1 Ch n trigger PDB interrupt Figure 37-53.
  • Page 848 Functional Description • PDB Modulus Register (MOD) • PDB Interrupt Delay Register (IDLY) • PDB Channel n Delay m Register (CHnDLYm) • DAC Interval x Register (DACINTx) • PDB Pulse-Out y Delay Register (POyDLY) The internal registers of them are buffered and any values written to them are written first to their buffers.
  • Page 849 Chapter 37 Programmable Delay Block (PDB) CHnDLY1 CHnDLY0 PDB Counter SC[LDOK] Ch n pre-trigger 0 Ch n pre-trigger 1 Figure 37-55. Registers Update with SC[LDMOD] = x1 37.4.6 Interrupts PDB can generate two interrupts, PDB interrupt and PDB sequence error interrupt. The following table summarizes the interrupts.
  • Page 850 Application Information values of total peripheral clocks that can be detected are even values; if prescaler is set to 4 then the only values of total peripheral clocks that can be decoded as detected are mod(4) and so forth. If the applications need a really long delay value and use 128, then the resolution would be limited to 128 peripheral clock cycles.
  • Page 851 Chapter 38 FlexTimer (FTM) 38.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 which supports input capture, output compare, and the generation of PWM signals to control electric motor and power management applications.
  • Page 852 Introduction FlexTimer input triggers can be from comparators, ADC or other sub modules to initiate timer functions automatically. These triggers can be linked in a variety of ways during integration of the sub modules so please note carefully the options available for used FlexTimer configuration.
  • Page 853 Chapter 38 FlexTimer (FTM) • 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) •...
  • Page 854 Introduction 38.1.4 Block Diagram The FTM uses one input/output (I/O) pin per channel, CHn (FTM channel (n)) where n is the channel number (0–7). The following figure shows the FTM structure. The central component of the FTM is the 16-bit counter with programmable initial and final values and its counting can be up or up-down.
  • Page 855 Chapter 38 FlexTimer (FTM) CLKS FTMEN QUADEN no clock selected (FTM counter disable) system clock fixed frequency clock prescaler external clock synchronizer ( 1, 2, 4, 8, 16, 32, 64 or 128) phase A Quadrature decoder phase B QUADEN CPWMS CAPTEST INITTRIGEN initialization...
  • Page 856 FTM Signal Descriptions 38.2 FTM Signal Descriptions Table 38-1 shows the user-accessible signals for the FTM. Table 38-1. FTM Signal Descriptions Signal Description EXTCLK External clock. FTM external clock can be selected to drive the FTM counter. FTM channel (n), where n can be 7-0 FAULTj Fault input (j), where j can be 3-0 Quadrature decoder phase A input.
  • Page 857 Chapter 38 FlexTimer (FTM) defined for each pair of channels. Since there are several FAULTj inputs, maximum of 4 for the FTM module, each one of these inputs is activated by the FAULTjEN bit in the FLTCTRL register. 38.2.4 PHA — FTM Quadrature Decoder Phase A Input The quadrature decoder phase A input is used as the quadrature decoder mode is selected.
  • Page 858 Memory Map and Register Definition 38.3.2 Register Descriptions This section consists of register descriptions in address order. Accesses to reserved addresses result in transfer errors. Registers for absent channels are considered reserved. FTM memory map Absolute Width Section/ address Register name Access Reset value (in bits)
  • Page 859 Chapter 38 FlexTimer (FTM) FTM memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 38.3.7/ 4003_8040 Channel (n) Value (FTM0_C6V) 0000_0000h 38.3.6/ 4003_8044 Channel (n) Status and Control (FTM0_C7SC) 0000_0000h 38.3.7/ 4003_8048 Channel (n) Value (FTM0_C7V) 0000_0000h 38.3.8/ 4003_804C...
  • Page 860 Memory Map and Register Definition FTM memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 38.3.25/ 4003_8090 FTM Inverting Control (FTM0_INVCTRL) 0000_0000h 38.3.26/ 4003_8094 FTM Software Output Control (FTM0_SWOCTRL) 0000_0000h 38.3.27/ 4003_8098 FTM PWM Load (FTM0_PWMLOAD) 0000_0000h 38.3.3/ 4003_9000...
  • Page 861 Chapter 38 FlexTimer (FTM) FTM memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 38.3.6/ 4003_9044 Channel (n) Status and Control (FTM1_C7SC) 0000_0000h 38.3.7/ 4003_9048 Channel (n) Value (FTM1_C7V) 0000_0000h 38.3.8/ 4003_904C Counter Initial Value (FTM1_CNTIN) 0000_0000h 38.3.9/ 4003_9050...
  • Page 862 Memory Map and Register Definition FTM memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 38.3.26/ 4003_9094 FTM Software Output Control (FTM1_SWOCTRL) 0000_0000h 38.3.27/ 4003_9098 FTM PWM Load (FTM1_PWMLOAD) 0000_0000h 38.3.3/ 400B_8000 Status and Control (FTM2_SC) 0000_0000h 38.3.4/ 400B_8004...
  • Page 863 Chapter 38 FlexTimer (FTM) FTM memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 38.3.7/ 400B_8048 Channel (n) Value (FTM2_C7V) 0000_0000h 38.3.8/ 400B_804C Counter Initial Value (FTM2_CNTIN) 0000_0000h 38.3.9/ 400B_8050 Capture and Compare Status (FTM2_STATUS) 0000_0000h 38.3.10/ 400B_8054...
  • Page 864 Memory Map and Register Definition FTM memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 38.3.27/ 400B_8098 FTM PWM Load (FTM2_PWMLOAD) 0000_0000h 38.3.3 Status and Control (FTMx_SC) SC contains the overflow status flag and control bits used to configure the interrupt enable, FTM configuration, clock source, and prescaler factor.
  • Page 865 Chapter 38 FlexTimer (FTM) FTMx_SC field descriptions (continued) Field Description Disable TOF interrupts. Use software polling. Enable TOF interrupts. An interrupt is generated when TOF equals one. Center-aligned PWM Select CPWMS Selects CPWM mode. This mode configures the FTM to operate in up-down counting mode. This field is write protected.
  • Page 866 Memory Map and Register Definition Addresses: FTM0_CNT is 4003_8000h base + 4h offset = 4003_8004h FTM1_CNT is 4003_9000h base + 4h offset = 4003_9004h FTM2_CNT is 400B_8000h base + 4h offset = 400B_8004h COUNT Reset FTMx_CNT field descriptions Field Description 31–16 This read-only field is reserved and always has the value zero.
  • Page 867 Chapter 38 FlexTimer (FTM) FTMx_MOD field descriptions (continued) Field Description 15–0 Modulo value 38.3.6 Channel (n) Status and Control (FTMx_CSC) CnSC contains the channel-interrupt-status flag and control bits used to configure the interrupt enable, channel configuration, and pin function. Table 38-67. Mode, Edge, and Level Selection DECAPEN COMBINE CPWMS...
  • Page 868 Memory Map and Register Definition Table 38-67. Mode, Edge, and Level Selection (continued) DECAPEN COMBINE CPWMS MSnB:MSnA ELSnB:ELSnA Mode Configuration Input capture Capture on Rising Edge Only Capture on Falling Edge Only Capture on Rising or Falling Edge Output compare Toggle Output on match Clear Output on...
  • Page 869 Chapter 38 FlexTimer (FTM) Table 38-68. Dual Edge Capture Mode — Edge Polarity Selection ELSnB ELSnA Channel Port Enable Detected Edges Disabled No edge Enabled Rising edge Enabled Falling edge Enabled Rising and falling edges Addresses: FTM0_C0SC is 4003_8000h base + Ch offset = 4003_800Ch Reset Reset FTMx_CnSC field descriptions...
  • Page 870 Memory Map and Register Definition FTMx_CnSC field descriptions (continued) Field Description This field is write protected. It can be written only when MODE[WPDIS] = 1. Channel Mode Select Used for further selections in the channel logic. Its functionality is dependent on the channel mode. See Table 38-7.
  • Page 871 Chapter 38 FlexTimer (FTM) FTMx_CnV field descriptions Field Description 31–16 This read-only field is reserved and always has the value zero. Reserved 15–0 Channel Value Captured FTM counter value of the input modes or the match value for the output modes 38.3.8 Counter Initial Value (FTMx_CNTIN) The Counter Initial Value register contains the initial value for the FTM counter.
  • Page 872 Memory Map and Register Definition 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.
  • Page 873 Chapter 38 FlexTimer (FTM) FTMx_STATUS field descriptions (continued) Field Description No channel event has occurred. A channel event has occurred. Channel 4 Flag CH4F See the register description. No channel event has occurred. A channel event has occurred. Channel 3 Flag CH3F See the register description.
  • Page 874 Memory Map and Register Definition 38.3.10 Features Mode Selection (FTMx_MODE) This register contains the control bits used to configure the fault interrupt and fault control, capture test mode, PWM synchronization, write protection, channel output initialization, and enable the enhanced features of the FTM. These controls relate to all channels within this module.
  • Page 875 Chapter 38 FlexTimer (FTM) FTMx_MODE field descriptions (continued) Field Description Capture Test Mode Enable CAPTEST Enables the capture test mode. This field is write protected. It can be written only when MODE[WPDIS] = 1. Capture test mode is disabled. Capture test mode is enabled. PWM Synchronization Mode PWMSYNC Selects which triggers can be used by MOD, CnV, OUTMASK, and FTM counter synchronization...
  • Page 876 Memory Map and Register Definition NOTE The software trigger (SWSYNC bit) and hardware triggers (TRIG0, TRIG1, and TRIG2 bits) have a potential conflict if used together when SYNCMODE = 0. It is recommended using only hardware or software triggers but not both at the same time, otherwise unpredictable behavior is likely to happen.
  • Page 877 Chapter 38 FlexTimer (FTM) FTMx_SYNC field descriptions (continued) Field Description Software trigger is not selected. Software trigger is selected. PWM Synchronization Hardware Trigger 2 TRIG2 Enables hardware trigger 2 to the PWM synchronization. Hardware trigger 2 happens when a rising edge is detected at the trigger 2 input signal.
  • Page 878 Memory Map and Register Definition FTMx_SYNC field descriptions (continued) Field Description The minimum loading point is disabled. The minimum loading point is enabled. 38.3.12 Initial State for Channels Output (FTMx_OUTINIT) Addresses: FTM0_OUTINIT is 4003_8000h base + 5Ch offset = 4003_805Ch FTM1_OUTINIT is 4003_9000h base + 5Ch offset = 4003_905Ch FTM2_OUTINIT is 400B_8000h base + 5Ch offset = 400B_805Ch Reset...
  • Page 879 Chapter 38 FlexTimer (FTM) FTMx_OUTINIT field descriptions (continued) Field Description Selects the value that is forced into the channel output when the initialization occurs. The initialization value is 0. The initialization value is 1. Channel 2 Output Initialization Value CH2OI Selects the value that is forced into the channel output when the initialization occurs.
  • Page 880 Memory Map and Register Definition FTMx_OUTMASK field descriptions Field Description 31–8 This read-only field is reserved and always has the value zero. Reserved Channel 7 Output Mask CH7OM Defines if the channel output is masked (forced to its inactive state) or unmasked (it continues to operate normally).
  • Page 881 Chapter 38 FlexTimer (FTM) FTMx_OUTMASK field descriptions (continued) Field Description Channel 0 Output Mask CH0OM Defines if the channel output is masked (forced to its inactive state) or unmasked (it continues to operate normally). Channel output is not masked. It continues to operate normally. Channel output is masked.
  • Page 882 Memory Map and Register Definition FTMx_COMBINE field descriptions (continued) Field Description Synchronization Enable for n = 6 SYNCEN3 Enables PWM synchronization of registers C(n)V and C(n+1)V. The PWM synchronization in this pair of channels is disabled. The PWM synchronization in this pair of channels is enabled. Deadtime Enable for n = 6 DTEN3 Enables the deadtime insertion in the channels (n) and (n+1).
  • Page 883 Chapter 38 FlexTimer (FTM) FTMx_COMBINE field descriptions (continued) Field Description This read-only field is reserved and always has the value zero. Reserved Fault Control Enable for n = 4 FAULTEN2 Enables the fault control in channels (n) and (n+1). This field is write protected. It can be written only when MODE[WPDIS] = 1. The fault control in this pair of channels is disabled.
  • Page 884 Memory Map and Register Definition FTMx_COMBINE field descriptions (continued) Field Description The channel (n+1) output is the same as the channel (n) output. The channel (n+1) output is the complement of the channel (n) output. Combine Channels for n = 4 COMBINE2 Enables the combine feature for channels (n) and (n+1).
  • Page 885 Chapter 38 FlexTimer (FTM) FTMx_COMBINE field descriptions (continued) Field Description The dual edge capture mode in this pair of channels is disabled. The dual edge capture mode in this pair of channels is enabled. Complement of Channel (n) for n = 2 COMP1 Enables complementary mode for the combined channels.
  • Page 886 Memory Map and Register Definition FTMx_COMBINE field descriptions (continued) Field Description Dual Edge Capture Mode Enable for n = 0 DECAPEN0 Enables the dual edge capture mode in the channels (n) and (n+1). This bit reconfigures the function of MSnA, ELSnB:ELSnA and ELS(n+1)B:ELS(n+1)A bits in dual edge capture mode according to Table 38-7.
  • Page 887 Chapter 38 FlexTimer (FTM) FTMx_DEADTIME field descriptions (continued) Field Description 7–6 Deadtime Prescaler Value DTPS Selects the division factor of the system clock. This prescaled clock is used by the deadtime counter. This field is write protected. It can be written only when MODE[WPDIS] = 1. Divide the system clock by 1.
  • Page 888 Memory Map and Register Definition Addresses: FTM0_EXTTRIG is 4003_8000h base + 6Ch offset = 4003_806Ch FTM1_EXTTRIG is 4003_9000h base + 6Ch offset = 4003_906Ch FTM2_EXTTRIG is 400B_8000h base + 6Ch offset = 400B_806Ch Reserved[bit 8] Reset Reserved[7:0] Reset FTMx_EXTTRIG field descriptions Field Description 31–8...
  • Page 889 Chapter 38 FlexTimer (FTM) FTMx_EXTTRIG field descriptions (continued) Field Description Enable the generation of the channel trigger when the FTM counter is equal to the CnV register. The generation of the channel trigger is disabled. The generation of the channel trigger is enabled. Channel 4 Trigger Enable CH4TRIG Enable the generation of the channel trigger when the FTM counter is equal to the CnV register.
  • Page 890 Memory Map and Register Definition FTMx_POL field descriptions Field Description 31–8 This field is reserved. Reserved Channel 7 Polarity POL7 Defines the polarity of the channel output. This field is write protected. It can be written only when MODE[WPDIS] = 1. The channel polarity is active high.
  • Page 891 Chapter 38 FlexTimer (FTM) FTMx_POL field descriptions (continued) Field Description The channel polarity is active high. The channel polarity is active low. Channel 0 Polarity POL0 Defines the polarity of the channel output. This field is write protected. It can be written only when MODE[WPDIS] = 1. The channel polarity is active high.
  • Page 892 Memory Map and Register Definition FTMx_FMS field descriptions (continued) Field Description Fault Detection Flag FAULTF Represents the logic OR of the individual FAULTFj bits (where j = 3, 2, 1, 0). Clear FAULTF by reading the FMS register while FAULTF is set and then writing a 0 to FAULTF while there is no existing fault condition at the enabled fault inputs.
  • Page 893 Chapter 38 FlexTimer (FTM) FTMx_FMS field descriptions (continued) Field Description No fault condition was detected at the fault input. A fault condition was detected at the fault input. Fault Detection Flag 1 FAULTF1 Set by hardware when fault control is enabled, the corresponding fault input is enabled and a fault condition is detected at the fault input.
  • Page 894 Memory Map and Register Definition Addresses: FTM0_FILTER is 4003_8000h base + 78h offset = 4003_8078h FTM1_FILTER is 4003_9000h base + 78h offset = 4003_9078h FTM2_FILTER is 400B_8000h base + 78h offset = 400B_8078h Reserved CH3FVAL CH2FVAL CH1FVAL CH0FVAL Reset FTMx_FILTER field descriptions Field Description 31–16...
  • Page 895 Chapter 38 FlexTimer (FTM) 38.3.20 Fault Control (FTMx_FLTCTRL) This register selects the filter value for the fault inputs, enables the fault inputs and the fault inputs filter. Addresses: FTM0_FLTCTRL is 4003_8000h base + 7Ch offset = 4003_807Ch FTM1_FLTCTRL is 4003_9000h base + 7Ch offset = 4003_907Ch FTM2_FLTCTRL is 400B_8000h base + 7Ch offset = 400B_807Ch Reset FFVAL...
  • Page 896 Memory Map and Register Definition FTMx_FLTCTRL field descriptions (continued) Field Description Fault Input 1 Filter Enable FFLTR1EN Enables the filter for the fault input. This field is write protected. It can be written only when MODE[WPDIS] = 1. Fault input filter is disabled. Fault input filter is enabled.
  • Page 897 Chapter 38 FlexTimer (FTM) 38.3.21 Quadrature Decoder Control and Status (FTMx_QDCTRL) This register has the control and status bits for the quadrature decoder mode. Addresses: FTM0_QDCTRL is 4003_8000h base + 80h offset = 4003_8080h FTM1_QDCTRL is 4003_9000h base + 80h offset = 4003_9080h FTM2_QDCTRL is 400B_8000h base + 80h offset = 400B_8080h Reset Reset...
  • Page 898 Memory Map and Register Definition FTMx_QDCTRL field descriptions (continued) Field Description Normal polarity. Phase A input signal is not inverted before identifying the rising and falling edges of this signal. Inverted polarity. Phase A input signal is inverted before identifying the rising and falling edges of this signal.
  • Page 899 Chapter 38 FlexTimer (FTM) 38.3.22 Configuration (FTMx_CONF) This register selects the number of times that the FTM counter overflow should occur before the TOF bit to be set, the FTM behavior in BDM modes, the use of an external global time base, and the global time base signal generation. Addresses: FTM0_CONF is 4003_8000h base + 84h offset = 4003_8084h FTM1_CONF is 4003_9000h base + 84h offset = 4003_9084h FTM2_CONF is 400B_8000h base + 84h offset = 400B_8084h...
  • Page 900 Memory Map and Register Definition FTMx_CONF field descriptions (continued) Field Description 4–0 TOF Frequency NUMTOF Selects the ratio between the number of counter overflows to the number of times the TOF bit is set. NUMTOF = 0: The TOF bit is set for each counter overflow. NUMTOF = 1: The TOF bit is set for the first counter overflow but not for the next overflow.
  • Page 901 Chapter 38 FlexTimer (FTM) FTMx_FLTPOL field descriptions (continued) Field Description 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. The fault input polarity is active high. A one at the fault input indicates a fault. The fault input polarity is active low.
  • Page 902 Memory Map and Register Definition 38.3.24 Synchronization Configuration (FTMx_SYNCONF) This register selects the PWM synchronization configuration, SWOCTRL, INVCTRL and CNTIN registers synchronization, if FTM clears the TRIGj bit (where j = 0, 1, 2) when the hardware trigger j is detected. Addresses: FTM0_SYNCONF is 4003_8000h base + 8Ch offset = 4003_808Ch FTM1_SYNCONF is 4003_9000h base + 8Ch offset = 4003_908Ch FTM2_SYNCONF is 400B_8000h base + 8Ch offset = 400B_808Ch...
  • Page 903 Chapter 38 FlexTimer (FTM) FTMx_SYNCONF field descriptions (continued) Field Description FTM counter synchronization is activated by a hardware trigger. HWRSTCNT A hardware trigger does not activate the FTM counter synchronization. A hardware trigger activates the FTM counter synchronization. 15–13 This read-only field is reserved and always has the value zero. Reserved Software output control synchronization is activated by the software trigger.
  • Page 904 Memory Map and Register Definition FTMx_SYNCONF field descriptions (continued) Field Description CNTIN register is updated with its buffer value at all rising edges of system clock. CNTIN register is updated with its buffer value by the PWM synchronization. This read-only field is reserved and always has the value zero. Reserved Hardware Trigger Mode HWTRIGMODE...
  • Page 905 Chapter 38 FlexTimer (FTM) FTMx_INVCTRL field descriptions (continued) Field Description Inverting is disabled. Inverting is enabled. Pair Channels 0 Inverting Enable INV0EN Inverting is disabled. Inverting is enabled. 38.3.26 FTM Software Output Control (FTMx_SWOCTRL) This register enables software control of channel (n) output and defines the value forced to the channel (n) output: •...
  • Page 906 Memory Map and Register Definition FTMx_SWOCTRL field descriptions (continued) Field Description Channel 7 Software Output Control Value CH7OCV The software output control forces 0 to the channel output. The software output control forces 1 to the channel output. Channel 6 Software Output Control Value CH6OCV The software output control forces 0 to the channel output.
  • Page 907 Chapter 38 FlexTimer (FTM) FTMx_SWOCTRL field descriptions (continued) Field Description The channel output is not affected by software output control. The channel output is affected by software output control. Channel 3 Software Output Control Enable CH3OC The channel output is not affected by software output control. The channel output is affected by software output control.
  • Page 908 Memory Map and Register Definition FTMx_PWMLOAD field descriptions Field Description 31–10 This read-only field is reserved and always has the value zero. Reserved Load Enable LDOK Enables the loading of the MOD, CNTIN, and CV registers with the values of their write buffers. Loading updated values is disabled.
  • Page 909 Chapter 38 FlexTimer (FTM) 38.4 Functional Description The following sections describe the FTM features. The notation used in this document to represent the counters and the generation of the signals is shown in the following figure. FTM counting is up. Channel (n) is in high-true EPWM mode.
  • Page 910 Functional Description The fixed frequency clock is an alternative clock source for the FTM counter that allows the selection of a clock other than the system clock or an external clock. This clock input is defined by chip integration. Refer the chip specific documentation for further information.
  • Page 911 Chapter 38 FlexTimer (FTM) 38.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.
  • Page 912 Functional Description FTM counting is up CNTIN = 0x0000 MOD = 0x0004 FTM counter TOF bit set TOF bit set TOF bit set TOF bit period of FTM counter clock period of counting = (MOD - CNTIN + 0x0001) x period of FTM counter clock = (MOD + 0x0001) x period of FTM counter clock Figure 38-169.
  • Page 913 Chapter 38 FlexTimer (FTM) FTM counting is up MOD = 0x0005 CNTIN = 0x0015 load of CNTIN load of CNTIN FTM counter 0x0005 0x0015 0x0016 0xFFFE 0xFFFF 0x0000 0x0001 0x0002 0x0003 0x0004 0x0005 0x0015 0x0016 TOF bit set TOF bit set TOF bit Figure 38-170.
  • Page 914 Functional Description FTM counting is up-down CNTIN = 0x0000 MOD = 0x0004 FTM counter TOF bit set TOF bit set TOF bit period of FTM counter clock period of counting = 2 x (MOD - CNTIN) x period of FTM counter clock = 2 x MOD x period of FTM counter clock Figure 38-171.
  • Page 915 Chapter 38 FlexTimer (FTM) 38.4.3.4 Counter Reset Any write to CNT resets the FTM counter to the value in the CNTIN register and the channels output to its initial value (except for channels in output compare mode). The FTM counter synchronization (see FTM Counter Synchronization) can also be used to force the value of CNTIN into the FTM counter and the channels output to its initial...
  • Page 916 Functional Description 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.
  • Page 917 Chapter 38 FlexTimer (FTM) Firstly the input signal is synchronized by the system clock. Following synchronization, the input signal enters the filter block (see the following figure). 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.
  • Page 918 Functional Description 38.4.5 Output Compare Mode The output compare mode is selected when (DECAPEN = 0), (COMBINE = 0), (CPWMS = 0), and (MSnB:MSnA = 0:1). In output compare mode, the FTM can generate timed pulses with programmable position, polarity, duration, and frequency. When the counter matches the value in the CnV register of an output compare channel, the channel (n) output can be set, cleared, or toggled.
  • Page 919 Chapter 38 FlexTimer (FTM) MOD = 0x0005 CnV = 0x0003 channel (n) counter counter channel (n) counter overflow match overflow match overflow channel (n) output previous value previous value CHnF bit TOF bit Figure 38-180. Example of the Output Compare Mode when the Match Sets the Channel Output It is possible to use the output compare mode with (ELSnB:ELSnA = 0:0).
  • Page 920 Functional Description 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).
  • Page 921 Chapter 38 FlexTimer (FTM) 38.4.7 Center-Aligned PWM (CPWM) Mode The center-aligned mode is selected when (QUADEN = 0), (DECAPEN = 0), (COMBINE = 0), and (CPWMS = 1). The CPWM pulse width (duty cycle) is determined by 2 × (CnV − CNTIN) and the period is determined by 2 ×...
  • Page 922 Functional Description counter counter MOD = 0x0008 overflow overflow CnV = 0x0005 channel (n) match in channel (n) match in channel (n) match in down counting down counting up counting channel (n) output previous value CHnF bit TOF bit Figure 38-185. CPWM Signal with ELSnB:ELSnA = 1:0 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).
  • Page 923 Chapter 38 FlexTimer (FTM) 38.4.8 Combine Mode The combine mode is selected when (FTMEN = 1), (QUADEN = 0), (DECAPEN = 0), (COMBINE = 1), and (CPWMS = 0). In combine mode, the channel (n) (an even channel) and channel (n+1) (the adjacent odd channel) are combined to generate a PWM signal in the channel (n) output.
  • Page 924 Functional Description FTM counter C(n+1)V C(n)V CNTIN channel (n) output with ELSnB:ELSnA = 1:0 channel (n) output with ELSnB:ELSnA = X:1 Figure 38-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...
  • Page 925 Chapter 38 FlexTimer (FTM) FTM counter MOD = C(n+1)V C(n)V CNTIN not fully 100% duty cycle channel (n) output with ELSnB:ELSnA = 1:0 not fully 0% duty cycle channel (n) output with ELSnB:ELSnA = X:1 Figure 38-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 C(n+1)V...
  • Page 926 Functional Description FTM counter C(n+1)V CNTIN C(n)V channel (n) output 0% duty cycle with ELSnB:ELSnA = 1:0 channel (n) output 100% duty cycle with ELSnB:ELSnA = X:1 Figure 38-193. Channel (n) Output If C(n)V and C(n+1)V Are Not Between CNTIN and FTM counter C(n+1)V = C(n)V CNTIN...
  • Page 927 Chapter 38 FlexTimer (FTM) FTM counter C(n)V = C(n+1)V = CNTIN channel (n) output 0% duty cycle with ELSnB:ELSnA = 1:0 channel (n) output 100% duty cycle with ELSnB:ELSnA = X:1 Figure 38-195. Channel (n) Output If (C(n)V = C(n+1)V = CNTIN) FTM counter MOD = C(n+1)V =...
  • Page 928 Functional Description FTM counter C(n+1)V CNTIN C(n)V channel (n) output 0% duty cycle with ELSnB:ELSnA = 1:0 channel (n) output 100% duty cycle with ELSnB:ELSnA = X:1 Figure 38-198. Channel (n) Output If (C(n)V < CNTIN) and (CNTIN < C(n+1)V < MOD) FTM counter C(n)V CNTIN...
  • Page 929 Chapter 38 FlexTimer (FTM) FTM counter C(n)V C(n+1)V CNTIN channel (n) output 0% duty cycle with ELSnB:ELSnA = 1:0 channel (n) output 100% duty cycle with ELSnB:ELSnA = X:1 Figure 38-200. Channel (n) Output If (C(n)V > MOD) and (CNTIN < C(n+1)V < MOD) FTM counter C(n+1)V C(n)V...
  • Page 930 Functional Description FTM counter C(n+1)V MOD = C(n)V CNTIN channel (n) output not fully 0% duty cycle with ELSnB:ELSnA = 1:0 channel (n) output not fully 100% duty cycle with ELSnB:ELSnA = X:1 Figure 38-202. Channel (n) Output If (C(n+1)V > MOD) and (CNTIN < C(n)V = MOD) 38.4.8.1 Asymmetrical PWM In combine mode, the control of the PWM signal first edge (when the channel (n) match occurs, that is, FTM counter = C(n)V) is independent of the control of the PWM signal...
  • Page 931 Chapter 38 FlexTimer (FTM) channel (n+1) match FTM counter channel (n) match channel (n) output with ELSnB:ELSnA = 1:0 channel (n+1) output with COMP = 0 channel (n+1) output with COMP = 1 Figure 38-203. Channel (n+1) Output in Complementary Mode with (ELSnB:ELSnA = 1:0) channel (n+1) match FTM counter channel (n) match...
  • Page 932 Functional Description If (CLKS[1:0] ≠ 0:0 and FTMEN = 0), then MOD register is updated according to the CPWMS bit, that is: • If the selected mode is not CPWM then MOD register is updated after MOD register was written and the FTM counter changes from MOD to CNTIN. If the FTM counter is at free-running counter mode then this update occurs when the FTM counter changes from 0xFFFF to 0x0000.
  • Page 933 Chapter 38 FlexTimer (FTM) • If the selected mode is output compare then CnV register is updated according to the SYNCEN bit. If (SYNCEN = 0) then CnV register is updated after CnV register was written at the next change of the FTM counter (end of the prescaler counting). If (SYNCEN = 1) then CnV register is updated by the CnV register synchronization (C(n)V and C(n+1)V Register Synchronization).
  • Page 934 Functional Description system clock write 1 to TRIG0 bit TRIG0 bit trigger_0 input synchronized trigger_0 by system clock trigger 0 event Note All hardware trigger inputs have the same behavior. Figure 38-205. Hardware Trigger Event with HWTRIGMODE = 0 If HWTRIGMODE = 1 then the TRIGn bit is only cleared when 0 is written to it. NOTE It is expected that the HWTRIGMODE bit be 1 only with enhanced PWM synchronization (SYNCMODE = 1).
  • Page 935 Chapter 38 FlexTimer (FTM) system clock system clock write 1 to SWSYNC bit write 1 to SWSYNC bit SWSYNC bit SWSYNC bit software trigger event software trigger event PWM synchronization PWM synchronization selected loading point Figure 38-206. Software Trigger Event 38.4.11.3 Boundary Cycle and Loading Points The boundary cycle definition is important for the loading points for the registers MOD, CNTIN and C(n)V.
  • Page 936 Functional Description loading points if CNTMAX = 1 or CNTMIN = 1 CNT = MOD -> CNTIN up counting mode loading points if CNTMAX = 1 CNT = (MOD - 0x0001) -> MOD up-down counting mode CNT = (CNTIN + 0x0001) -> CNTIN loading points if CNTMIN = 1 Figure 38-207.
  • Page 937 Chapter 38 FlexTimer (FTM) begin legacy SYNCMODE PWM synchronization bit ? enhanced PWM synchronization MOD register is MOD register is updated by software trigger updated by hardware trigger SWWRBUF HWWRBUF bit ? bit ? hardware software trigger trigger TRIGn SWSYNC bit ? bit ? FTM counter is reset by...
  • Page 938 Functional Description 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 write 1 to SWSYNC bit SWSYNC bit software trigger event selected loading point MOD register is updated...
  • Page 939 Chapter 38 FlexTimer (FTM) system clock write 1 to SWSYNC bit SWSYNC bit software trigger event MOD register is updated Figure 38-211. MOD Synchronization with (SYNCMODE = 0), (PWMSYNC = 0), (REINIT = 1), and (Software Trigger Was Used) system clock write 1 to TRIG0 bit TRIG0 bit trigger 0 event...
  • Page 940 Functional Description 38.4.11.5 CNTIN Register Synchronization The CNTIN register synchronization updates the CNTIN register with its buffer value. This synchronization is enabled if (FTMEN = 1), (SYNCMODE = 1) and (CNTINC = 1). The CNTIN register synchronization can be done only by the enhanced PWM synchronization (SYNCMODE = 1).
  • Page 941 Chapter 38 FlexTimer (FTM) begin update OUTMASK register at update OUTMASK register by each rising edge of system clock PWM synchronization SYNCHOM bit ? SYNCMODE rising edge no = bit ? of system clock ? legacy = yes PWM synchronization update OUTMASK with its buffer value enhanced PWM synchronization...
  • Page 942 Functional Description If (SYNCMODE = 0), (SYNCHOM = 1) and (PWMSYNC = 0) then this synchronization is done on the next enabled trigger event. 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 TRIGn bit is cleared according to Hardware Trigger.
  • Page 943 Chapter 38 FlexTimer (FTM) system clock write 1 to TRIG0 bit TRIG0 bit trigger 0 event OUTMASK register is updated and TRIG0 bit is cleared Figure 38-217. OUTMASK Synchronization with (SYNCMODE = 0), (HWTRIGMODE = 0), (SYNCHOM = 1), (PWMSYNC = 1), and (a Hardware Trigger Was Used) 38.4.11.8 INVCTRL Register Synchronization The INVCTRL register synchronization updates the INVCTRL register with its buffer value.
  • Page 944 Functional Description begin update INVCTRL register at update INVCTRL register by each rising edge of system clock PWM synchronization INVC bit ? SYNCMODE bit ? rising edge no = of system clock ? = yes update INVCTRL with its buffer value enhanced PWM synchronization INVCTRL is updated INVCTRL is updated...
  • Page 945 Chapter 38 FlexTimer (FTM) 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.
  • Page 946 Functional Description 38.4.11.10 FTM Counter Synchronization The FTM counter synchronization is a mechanism that allows the FTM to re-start the PWM generation at a certain point in the PWM period. The channels outputs are forced to their initial value (except for channels in output compare mode) and the FTM counter is forced to its initial counting value defined by CNTIN register.
  • Page 947 Chapter 38 FlexTimer (FTM) begin legacy SYNCMODE PWM synchronization bit ? enhanced PWM synchronization FTM counter is reset by FTM counter is reset by software trigger hardware trigger SWRSTCNT HWRSTCNT bit ? bit ? hardware TRIGn software SWSYNC trigger bit ? trigger bit ? wait hardware trigger n...
  • Page 948 Functional Description system clock write 1 to SWSYNC bit SWSYNC bit software trigger event FTM counter is updated with the CNTIN register value and channel outputs are forced to their initial value Figure 38-222. FTM Counter Synchronization with (SYNCMODE = 0), (REINIT = 1), (PWMSYNC = 0), and (Software Trigger Was Used) system clock write 1 to TRIG0 bit...
  • Page 949 Chapter 38 FlexTimer (FTM) 38.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.
  • Page 950 Functional Description channel (n+1) match FTM counter channel (n) match channel (n) output before the inverting channel (n+1) output before the inverting write 1 to INV(m) bit INV(m) bit buffer INVCTRL register synchronization INV(m) bit channel (n) output after the inverting channel (n+1) output after the inverting NOTE...
  • Page 951 Chapter 38 FlexTimer (FTM) channel (n+1) match FTM counter channel (n) match channel (n) output after the software output control channel (n+1) output after the software output control CH(n)OC buffer CH(n+1)OC buffer write to SWOCTRL register write to SWOCTRL register CH(n)OC bit CH(n+1)OC bit SWOCTRL register synchronization...
  • Page 952 Functional Description Note • It is expected that the software output control feature be used only in combine mode. • The CH(n)OC and CH(n+1)OC bits should be equal. • The COMP bit should not be modified when software output control is enabled, that is, CH(n)OC = 1 and/or CH(n+1)OC = 1.
  • Page 953 Chapter 38 FlexTimer (FTM) channel (n+1) match FTM counter channel (n) match channel (n) output (before deadtime insertion) channel (n+1) output (before deadtime insertion) channel (n) output (after deadtime insertion) channel (n+1) output (after deadtime insertion) Figure 38-228. Deadtime Insertion with ELSnB:ELSnA = 1:0, POL(n) = 0, and POL(n+1) = channel (n+1) match FTM counter channel (n) match...
  • Page 954 Functional Description • 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 –...
  • Page 955 Chapter 38 FlexTimer (FTM) 38.4.15 Output Mask The output mask can be used to force channels output to their inactive state through software (for example: to control a BLDC motor). Any write to the OUTMASK register updates its write buffer. The OUTMASK register is updated with its buffer value by PWM synchronization (OUTMASK Register Synchronization).
  • Page 956 Functional Description Note It is expected the output mask feature be used only in combine mode. 38.4.16 Fault Control The fault control is enabled if (FTMEN = 1) and (FAULTM[1:0] ≠ 0:0). FTM can have up to four fault inputs. FAULTnEN bit (where n = 0, 1, 2, 3) enables the fault input n and FFLTRnEN bit enables the fault input n filter.
  • Page 957 Chapter 38 FlexTimer (FTM) (FFVAL[3:0] 0000) and (FFLTRnEN*) FLTnPOL fault input n* value synchronizer fault input fault input n* polarity rising edge FAULTFn* control detector Fault filter (5-bit counter) system clock * where n = 3, 2, 1, 0 Figure 38-233. Fault Input n Control Block Diagram If the fault control and fault input n are enabled and a rising edge at the fault input n signal is detected, then the FAULTFn bit is set.
  • Page 958 Functional Description 38.4.16.1 Automatic Fault Clearing If the automatic fault clearing is selected (FAULTM[1:0] = 1:1), then the channels output disabled by fault control is again enabled when the fault input signal (FAULTIN) returns to zero and a new PWM cycle begins (see the following figure). the beginning of new PWM cycles FTM counter channel (n) output...
  • Page 959 Chapter 38 FlexTimer (FTM) the beginning of new PWM cycles FTM counter channel (n) output (before fault control) FAULTIN bit channel (n) output (after fault control with manual fault clearing and POLn=0) FAULTF bit FAULTF bit is cleared NOTE The channel (n) output is after the fault control with manual fault clearing and POLn = 0. Figure 38-236.
  • Page 960 Functional Description Note It is expected that the polarity control be used only in combine mode. 38.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.
  • Page 961 Chapter 38 FlexTimer (FTM) pair channels (m) - channels (n) and (n+1) FTM counter QUADEN DECAPEN COMBINE(m) CPWMS C(n)V MS(n)B CH(n)OC MS(n)A CH(n)OCV POL(n) POL(n+1) ELS(n)B CH(n+1)OC CH(n)OI CH(n)OM ELS(n)A CH(n+1)OCV DTEN(m) CH(n+1)OI INV(m)EN COMP(m) CH(n+1)OM FAULTEN(m) channel generation of channel (n) output output signal...
  • Page 962 Functional Description The FTM is able to generate multiple triggers in one PWM period. Since 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 FTM counter = C5V FTM counter = C4V FTM counter = C3V...
  • Page 963 Chapter 38 FlexTimer (FTM) • When there is a write to CNT register • When there is the FTM counter synchronization (FTM Counter Synchronization) • If (CNT = CNTIN), (CLKS[1:0] = 0:0), and a value different from zero is written to CLKS[1:0] bits The following figures show the cases.
  • Page 964 Functional Description CNTIN = 0x0000 MOD = 0x000F CPWMS = 0 system clock 0x00 0x01 0x02 0x03 0x04 0x05 FTM counter CLKS[1:0] bits initialization trigger Figure 38-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.
  • Page 965 Chapter 38 FlexTimer (FTM) FTM counter clock set CAPTEST clear CAPTEST write to MODE CAPTEST bit FTM counter 0x1053 0x1054 0x1055 0x1056 0x78AD 0x78AE0x78AF 0x78B0 0x78AC write 0x78AC write to CNT CHnF bit 0x0300 0x78AC 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) Figure 38-243.
  • Page 966 Functional Description Table 38-248. Clear CHnF Bit when DMA = 1 CHnIE How CHnF Bit Can Be Cleared CHnF bit is cleared either when the channel DMA transfer is done or by reading CnSC while CHnF is set and then writing a 0 to CHnF bit. CHnF bit is cleared when the channel DMA transfer is done.
  • Page 967 Chapter 38 FlexTimer (FTM) 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, the pair channels coherency mechanism ensures coherent data when the C(n)V and C(n+1)V registers are read.
  • Page 968 Functional Description 38.4.24.2 Continuous Capture Mode The continuous capture mode is selected when (FTMEN = 1), (DECAPEN = 1), and (MS(n)A = 1). In this capture mode, the edges at the channel (n) input are captured continuously. The ELS(n)B:ELS(n)A bits select the initial edge to be captured, and ELS(n+1)B:ELS(n+1)A bits select the final edge to be captured.
  • Page 969 Chapter 38 FlexTimer (FTM) FTM counter channel (n) input (after the filter channel input) DECAPEN bit set DECAPEN DECAP bit set DECAP C(n)V CH(n)F bit clear CH(n)F C(n+1)V 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.
  • Page 970 Functional Description FTM counter channel (n) input (after the filter channel input) DECAPEN bit set DECAPEN DECAP bit set DECAP C(n)V CH(n)F bit clear CH(n)F C(n+1)V 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 38-246.
  • Page 971 Chapter 38 FlexTimer (FTM) 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 keeps set in all operation mode. The DECAP bit is set to enable the measurement of next period.
  • Page 972 Functional Description 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.
  • Page 973 Chapter 38 FlexTimer (FTM) 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.
  • Page 974 Functional Description (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.
  • Page 975 Chapter 38 FlexTimer (FTM) phase B (counting direction) phase A (counting rate) FTM counter +1 +1 +1 +1 +1 +1 +1 +1 -1 -1 -1 -1 -1 increment/decrement FTM counter CNTIN 0x0000 Time Figure 38-251. Quadrature Decoder – Count and Direction Encoding Mode If QUADMODE = 0, then the phase A and phase B encoding mode (see the following figure) is enabled.
  • Page 976 Functional Description 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 +1 +1 +1 +1 +1 +1 increment/decrement FTM counter CNTIN 0x0000...
  • Page 977 Chapter 38 FlexTimer (FTM) phase A phase B FTM counter increment/decrement FTM counter CNTIN 0x0000 Time set TOF set TOF clear TOFDIR clear TOFDIR Figure 38-254. FTM Counter Overflow in Down Counting for Quadrature Decoder Mode 38.4.25.1 Quadrature Decoder Boundary Conditions The following figures are examples of motor jittering which causes the FTM counter transitions as indicated by these figures.
  • Page 978 Functional Description The following figure shows motor jittering produced by the phase B and A pulses respectively. 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.
  • Page 979 Chapter 38 FlexTimer (FTM) Table 38-249. FTM Behavior When the Chip Is in BDM Mode (continued) BDMMODE CH(n)F Bit FTM Channels Output Writes to MOD, CNTIN, and C(n)V Registers Counter Stopped is not set The channels outputs are frozen Writes to these registers bypass the registers when the chip enters in BDM buffers mode...
  • Page 980 Functional Description After enabling the loading points, the LDOK bit needs to be set for the load to occur. In this case the load occurs at the next enabled loading point according to the following conditions: • If a new value was written to the MOD register, then the MOD register is updated with its write buffer value.
  • Page 981 Chapter 38 FlexTimer (FTM) 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.
  • Page 982 Reset Overview 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).
  • Page 983 Chapter 38 FlexTimer (FTM) When the FTM exits from reset: • the FTM counter and the prescaler counter are zero and are stopped (CLKS[1:0] = 00b); • the timer overflow interrupt is zero (Timer Overflow Interrupt); • the channels interrupts are zero (Channel (n) Interrupt);...
  • Page 984 FTM Interrupts 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).
  • Page 985 Chapter 38 FlexTimer (FTM) 38.6.3 Fault Interrupt The fault interrupt is generated when (FAULTIE = 1) and (FAULTF = 1). K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 986 FTM Interrupts K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 987 Chapter 39 Periodic Interrupt Timer (PIT) 39.1 Introduction NOTE For the chip-specific implementation details of this module's instances see the chip configuration chapter. The PIT timer module is an array of timers that can be used to raise interrupts and trigger DMA channels.
  • Page 988 Signal Description Peripheral Registers load_value Timer 1 I i nterrupts Triggers Timer n Peripheral Bus Clock Figure 39-1. Block diagram of the PIT NOTE Refer to the Chip Configuration information for the number of PIT channels used in this MCU. 39.1.2 Features The main features of this block are: •...
  • Page 989 Chapter 39 Periodic Interrupt Timer (PIT) 39.3 Memory Map/Register Description This section provides a detailed description of all registers accessible in the PIT module. NOTE Reserved registers will read as 0, writes will have no effect. NOTE Refer to the Chip Configuration information for the number of PIT channels used in this MCU.
  • Page 990 Memory Map/Register Description PIT memory map (continued) Absolute Width Section/ address Register name Access Reset value (in bits) page (hex) 39.3.2/ 4003_7130 Timer Load Value Register (PIT_LDVAL3) 0000_0000h 39.3.3/ 4003_7134 Current Timer Value Register (PIT_CVAL3) 0000_0000h 39.3.4/ 4003_7138 Timer Control Register (PIT_TCTRL3) 0000_0000h 39.3.5/ 4003_713C...
  • Page 991 Chapter 39 Periodic Interrupt Timer (PIT) 39.3.2 Timer Load Value Register (PIT_LDVALn) These registers select the timeout period for the timer interrupts. Addresses: PIT_LDVAL0 is 4003_7000h base + 100h offset = 4003_7100h PIT_LDVAL1 is 4003_7000h base + 110h offset = 4003_7110h PIT_LDVAL2 is 4003_7000h base + 120h offset = 4003_7120h PIT_LDVAL3 is 4003_7000h base + 130h offset = 4003_7130h Reset...
  • Page 992 Memory Map/Register Description 39.3.4 Timer Control Register (PIT_TCTRLn) These register contain the control bits for each timer. Addresses: PIT_TCTRL0 is 4003_7000h base + 108h offset = 4003_7108h PIT_TCTRL1 is 4003_7000h base + 118h offset = 4003_7118h PIT_TCTRL2 is 4003_7000h base + 128h offset = 4003_7128h PIT_TCTRL3 is 4003_7000h base + 138h offset = 4003_7138h Reset PIT_TCTRLn field descriptions...
  • Page 993 Chapter 39 Periodic Interrupt Timer (PIT) PIT_TFLGn field descriptions Field Description 31–1 This read-only field is reserved and always has the value zero. Reserved Timer Interrupt Flag. TIF is set to 1 at the end of the timer period. This flag can be cleared only by writing it with 1. Writing 0 has no effect.
  • Page 994 Functional Description Timer Enabled Disable Re-Enable Start Value = p1 Timer Timer Trigger Event Figure 39-23. Stopping and Starting a Timer 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). Disable Timer Enabled Re-Enable...
  • Page 995 Chapter 39 Periodic Interrupt Timer (PIT) 39.4.2 Interrupts All of the timers support interrupt generation. Refer to the MCU specification for related vector addresses and priorities. Timer interrupts can be enabled by setting the TIE bits. The timer interrupt flags (TIF) are set to 1 when a timeout occurs on the associated timer, and are cleared to 0 by writing a 1 to that TIF bit.
  • Page 996 Initialization and Application Information PIT_LDVAL3 = 0x0016E35F; // setup timer 3for 1500000 cycles PIT_TCTRL3 |= TEN; // start Timer 3 K51 Sub-Family Reference Manual, Rev. 6, Nov 2011 Freescale Semiconductor, Inc.
  • Page 997 Chapter 40 Low power timer (LPTMR) 40.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.
  • Page 998 LPTMR signal descriptions 40.1.2.2 Wait mode In wait mode, the LPTMR continues to operate normally and may be configured to exit the low power mode by generating an interrupt request. 40.1.2.3 Stop mode In stop mode, the LPTMR continues to operate normally and may be configured to exit the low power mode by generating an interrupt request.
  • Page 999 Chapter 40 Low power timer (LPTMR) 40.2.1 Detailed signal descriptions Table 40-2. LPTMR interface-detailed signal descriptions Signal Description LPTMR_ALTn Pulse counter input. The LPTMR can select one of the input pins to be used in pulse counter mode. State meaning Assertion-If configured for pulse counter mode with active high input then assertion causes the LPTMR counter register to increment.
  • Page 1000 Memory map and register definition 40.3.1 Low Power Timer Control Status Register (LPTMRx_CSR) Addresses: LPTMR0_CSR is 4004_0000h base + 0h offset = 4004_0000h Reset Reset LPTMRx_CSR field descriptions Field Description 31–8 This read-only field is reserved and always has the value zero. Reserved Timer Compare Flag The timer compare flag is set when the LPTMR is enabled and the LPTMR Counter Register equals the...

This manual is also suitable for:

Freescale mk51dx256zcmc10Freescale mk51dn512zcmc10

Table of Contents