0
登录后你可以
  • 下载海量资料
  • 学习在线课程
  • 观看技术视频
  • 写文章/发帖/加入社区
会员中心
创作中心
发布
  • 发文章

  • 发资料

  • 发帖

  • 提问

  • 发视频

创作活动
MC9S12XS128

MC9S12XS128

  • 厂商:

    FREESCALE(飞思卡尔)

  • 封装:

  • 描述:

    MC9S12XS128 - HCS12 Microcontrollers - Freescale Semiconductor, Inc

  • 数据手册
  • 价格&库存
MC9S12XS128 数据手册
MC9S12XS256 Reference Manual Covers MC9S12XS Family MC9S12XS256 MC9S12XS128 MC9S12XS64 HCS12 Microcontrollers MC9S12XS256RMV1 Rev. 1.09 09/2009 freescale.com To provide the most up-to-date information, the document revision on the World Wide Web is the most current. A printed copy may be an earlier revision. To verify you have the latest information available, refer to: http://freescale.com/ This document contains information for the complete S12XS Family and thus includes a set of separate flash (FTMR) module sections to cover the whole family. A full list of family members and options is included in the appendices. This document contains information for all constituent modules, with the exception of the CPU. For CPU information please refer to CPU12XV1 in the CPU12/CPU12X Reference Manual. Revision History Date March, 2009 Revision Level 1.07 Description Corrected pin name in 112LQPF pinout Updated XMMC, MSCAN, PIM sections Removed all KGD references Corrected Detailed Register Map (FERSTAT) Corrected statement on VDDA/VDDX protection diodes Updated Chapter 8 S12XE Clocks and Reset Generator (S12XECRGV1) Updated Chapter 14 Serial Communication Interface (S12SCIV5) Updated Chapter 16 Timer Module (TIM16B8CV2) Block Description Updated Chapter 18 256 KByte Flash Module (S12XFTMR256K1V1) Updated Chapter 19 128 KByte Flash Module (S12XFTMR128K1V1) Updated Chapter 20 64 KByte Flash Module (S12XFTMR64K1V1) May, 2009 1.08 September, 2009 1.09 Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 10 Chapter 11 Chapter 12 Chapter 13 Chapter 14 Chapter 15 Chapter 16 Chapter 17 Chapter 18 Chapter 19 Chapter 20 Appendix A Appendix B Appendix C Appendix D Appendix E Appendix F Device Overview S12XS Family . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 Port Integration Module (S12XSPIMV1) . . . . . . . . . . . . . . . . . . . . . . . . . . .57 Memory Mapping Control (S12XMMCV4) . . . . . . . . . . . . . . . . . . . . . . . .125 Interrupt (S12XINTV2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .149 Background Debug Module (S12XBDMV2) . . . . . . . . . . . . . . . . . . . . . . .165 S12X Debug (S12XDBGV3) Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . .191 Security (S12XS9SECV2). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .227 S12XE Clocks and Reset Generator (S12XECRGV1) . . . . . . . . . . . . . . .233 Pierce Oscillator (S12XOSCLCPV2) . . . . . . . . . . . . . . . . . . . . . . . . . . . .263 Analog-to-Digital Converter (ADC12B16CV1) . . . . . . . . . . . . . . . . . . . . .267 Freescale’s Scalable Controller Area Network (S12MSCANV3) . . . . . .293 Periodic Interrupt Timer (S12PIT24B4CV1) . . . . . . . . . . . . . . . . . . . . . . .347 Pulse-Width Modulator (S12PWM8B8CV1) . . . . . . . . . . . . . . . . . . . . . . .363 Serial Communication Interface (S12SCIV5) . . . . . . . . . . . . . . . . . . . . . .395 Serial Peripheral Interface (S12SPIV5) . . . . . . . . . . . . . . . . . . . . . . . . . . .433 Timer Module (TIM16B8CV2) Block Description . . . . . . . . . . . . . . . . . . .459 Voltage Regulator (S12VREGL3V3V1) . . . . . . . . . . . . . . . . . . . . . . . . . . .487 256 KByte Flash Module (S12XFTMR256K1V1). . . . . . . . . . . . . . . . . . . .505 128 KByte Flash Module (S12XFTMR128K1V1). . . . . . . . . . . . . . . . . . . .555 64 KByte Flash Module (S12XFTMR64K1V1). . . . . . . . . . . . . . . . . . . . . .605 Electrical Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .655 Package Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .696 PCB Layout Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .706 Derivative Differences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .710 Detailed Register Address Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .711 Ordering Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .733 S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 3 S12XS Family Reference Manual, Rev. 1.09 4 Freescale Semiconductor Chapter 1 Device Overview S12XS Family 1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 1.1.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 1.1.2 Modes of Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 1.1.3 Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 1.1.4 Device Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 1.1.5 Address Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 1.1.6 Detailed Register Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 1.1.7 Part ID Assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 Signal Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 1.2.1 Device Pinout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 1.2.2 Pin Assignment Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 1.2.3 Detailed Signal Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 1.2.4 Power Supply Pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 System Clock Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Modes of Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 1.4.1 Chip Configuration Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 1.4.2 Power Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 1.4.3 Freeze Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Resets and Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 1.6.1 Resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 1.6.2 Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 1.6.3 Effects of Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 ATD0 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 1.7.1 External Trigger Input Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 1.7.2 ATD0 Channel[17] Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 VREG Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 1.8.1 Temperature Sensor Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 Oscillator Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 Chapter 2 Port Integration Module (S12XSPIMV1) 2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 2.1.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 2.1.2 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 External Signal Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 Memory Map and Register Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 2.3.1 Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 5 2.2 2.3 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.3.10 2.3.11 2.3.12 2.3.13 2.3.14 2.3.15 2.3.16 2.3.17 2.3.18 2.3.19 2.3.20 2.3.21 2.3.22 2.3.23 2.3.24 2.3.25 2.3.26 2.3.27 2.3.28 2.3.29 2.3.30 2.3.31 2.3.32 2.3.33 2.3.34 2.3.35 2.3.36 2.3.37 2.3.38 2.3.39 2.3.40 2.3.41 2.3.42 2.3.43 2.3.44 2.3.45 2.3.46 Register Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 Port A Data Register (PORTA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Port B Data Register (PORTB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Port A Data Direction Register (DDRA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 Port B Data Direction Register (DDRB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 PIM Reserved Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 Port E Data Register (PORTE) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 Port E Data Direction Register (DDRE) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 Ports ABEK, BKGD pin Pull-up Control Register (PUCR) . . . . . . . . . . . . . . . . . . . . . . 77 Ports ABEK Reduced Drive Register (RDRIV) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 ECLK Control Register (ECLKCTL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 PIM Reserved Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 IRQ Control Register (IRQCR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 PIM Reserved Register PIMTEST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 Port K Data Register (PORTK) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 Port K Data Direction Register (DDRK) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 Port T Data Register (PTT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 Port T Input Register (PTIT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 Port T Data Direction Register (DDRT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 Port T Reduced Drive Register (RDRT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 Port T Pull Device Enable Register (PERT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 Port T Polarity Select Register (PPST) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 PIM Reserved Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 Port T Routing Register (PTTRR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 Port S Data Register (PTS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 Port S Input Register (PTIS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 Port S Data Direction Register (DDRS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 Port S Reduced Drive Register (RDRS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 Port S Pull Device Enable Register (PERS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 Port S Polarity Select Register (PPSS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 Port S Wired-Or Mode Register (WOMS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 PIM Reserved Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 Port M Data Register (PTM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 Port M Input Register (PTIM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 Port M Data Direction Register (DDRM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 Port M Reduced Drive Register (RDRM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 Port M Pull Device Enable Register (PERM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 Port M Polarity Select Register (PPSM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 Port M Wired-Or Mode Register (WOMM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 Module Routing Register (MODRR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 Port P Data Register (PTP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 Port P Input Register (PTIP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 Port P Data Direction Register (DDRP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Port P Reduced Drive Register (RDRP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 Port P Pull Device Enable Register (PERP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 S12XS Family Reference Manual, Rev. 1.09 6 Freescale Semiconductor 2.4 2.5 2.3.47 Port P Polarity Select Register (PPSP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 2.3.48 Port P Interrupt Enable Register (PIEP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 2.3.49 Port P Interrupt Flag Register (PIFP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 2.3.50 Port H Data Register (PTH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 2.3.51 Port H Input Register (PTIH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 2.3.52 Port H Data Direction Register (DDRH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 2.3.53 Port H Reduced Drive Register (RDRH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 2.3.54 Port H Pull Device Enable Register (PERH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 2.3.55 Port H Polarity Select Register (PPSH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 2.3.56 Port H Interrupt Enable Register (PIEH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 2.3.57 Port H Interrupt Flag Register (PIFH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 2.3.58 Port J Data Register (PTJ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 2.3.59 Port J Input Register (PTIJ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 2.3.60 Port J Data Direction Register (DDRJ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 2.3.61 Port J Reduced Drive Register (RDRJ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 2.3.62 Port J Pull Device Enable Register (PERJ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 2.3.63 Port J Polarity Select Register (PPSJ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 2.3.64 Port J Interrupt Enable Register (PIEJ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 2.3.65 Port J Interrupt Flag Register (PIFJ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 2.3.66 Port AD0 Data Register 0 (PT0AD0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 2.3.67 Port AD0 Data Register 1 (PT1AD0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 2.3.68 Port AD0 Data Direction Register 0 (DDR0AD0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 2.3.69 Port AD0 Data Direction Register 1 (DDR1AD0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 2.3.70 Port AD0 Reduced Drive Register 0 (RDR0AD0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 2.3.71 Port AD0 Reduced Drive Register 1 (RDR1AD0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 2.3.72 Port AD0 Pull Up Enable Register 0 (PER0AD0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 2.3.73 Port AD0 Pull Up Enable Register 1 (PER1AD0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 2.3.74 PIM Reserved Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 2.4.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 2.4.2 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 2.4.3 Pins and Ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 2.4.4 Pin interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 Initialization Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 2.5.1 Port Data and Data Direction Register writes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 Chapter 3 Memory Mapping Control (S12XMMCV4) 3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 3.1.1 Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 3.1.2 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 3.1.3 S12X Memory Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 3.1.4 Modes of Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 3.1.5 Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 External Signal Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 7 3.2 3.3 3.4 3.5 Memory Map and Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 3.3.1 Module Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 3.3.2 Register Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 3.4.1 MCU Operating Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 3.4.2 Memory Map Scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 3.4.3 Chip Bus Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 Initialization/Application Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 3.5.1 CALL and RTC Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 Chapter 4 Interrupt (S12XINTV2) 4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 4.1.1 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 4.1.2 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 4.1.3 Modes of Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 4.1.4 Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 External Signal Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 Memory Map and Register Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 4.3.1 Module Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 4.3.2 Register Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 4.4.1 S12X Exception Requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 4.4.2 Interrupt Prioritization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 4.4.3 XGATE Requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 4.4.4 Priority Decoders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 4.4.5 Reset Exception Requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 4.4.6 Exception Priority . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 Initialization/Application Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 4.5.1 Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 4.5.2 Interrupt Nesting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 4.5.3 Wake Up from Stop or Wait Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 4.2 4.3 4.4 4.5 Chapter 5 Background Debug Module (S12XBDMV2) 5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 5.1.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 5.1.2 Modes of Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 5.1.3 Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 External Signal Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 Memory Map and Register Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 5.3.1 Module Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 5.3.2 Register Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 5.3.3 Family ID Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 5.2 5.3 S12XS Family Reference Manual, Rev. 1.09 8 Freescale Semiconductor 5.4 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 5.4.1 Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 5.4.2 Enabling and Activating BDM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 5.4.3 BDM Hardware Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 5.4.4 Standard BDM Firmware Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 5.4.5 BDM Command Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 5.4.6 BDM Serial Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 5.4.7 Serial Interface Hardware Handshake Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 5.4.8 Hardware Handshake Abort Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 5.4.9 SYNC — Request Timed Reference Pulse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 5.4.10 Instruction Tracing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 5.4.11 Serial Communication Time Out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 Chapter 6 S12X Debug (S12XDBGV3) Module 6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 6.1.1 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 6.1.2 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 6.1.3 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 6.1.4 Modes of Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 6.1.5 Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 External Signal Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 Memory Map and Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 6.3.1 Module Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 6.3.2 Register Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 6.4.1 S12XDBG Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 6.4.2 Comparator Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 6.4.3 Trigger Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 6.4.4 State Sequence Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 6.4.5 Trace Buffer Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 6.4.6 Tagging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 6.4.7 Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 6.2 6.3 6.4 Chapter 7 Security (S12XS9SECV2) 7.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 7.1.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 7.1.2 Modes of Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 7.1.3 Securing the Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 7.1.4 Operation of the Secured Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 7.1.5 Unsecuring the Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231 7.1.6 Reprogramming the Security Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231 7.1.7 Complete Memory Erase (Special Modes) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232 S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 9 Chapter 8 S12XE Clocks and Reset Generator (S12XECRGV1) 8.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 8.1.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 8.1.2 Modes of Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234 8.1.3 Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234 Signal Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 8.2.1 VDDPLL, VSSPLL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 8.2.2 RESET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 Memory Map and Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236 8.3.1 Module Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236 8.3.2 Register Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 8.4.1 Functional Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 8.4.2 Operation Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 8.4.3 Low Power Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256 Resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 8.5.1 Description of Reset Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 8.6.1 Description of Interrupt Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 8.2 8.3 8.4 8.5 8.6 Chapter 9 Pierce Oscillator (S12XOSCLCPV2) 9.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 9.1.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 9.1.2 Modes of Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 9.1.3 Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264 External Signal Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264 9.2.1 VDDPLL and VSSPLL — Operating and Ground Voltage Pins . . . . . . . . . . . . . . . . . . . . 264 9.2.2 EXTAL and XTAL — Input and Output Pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264 Memory Map and Register Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 9.4.1 Gain Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 9.4.2 Clock Monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 9.4.3 Wait Mode Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 9.4.4 Stop Mode Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 9.2 9.3 9.4 Chapter 10 Analog-to-Digital Converter (ADC12B16CV1) 10.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267 10.1.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267 10.1.2 Modes of Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 10.1.3 Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270 10.2 Signal Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 S12XS Family Reference Manual, Rev. 1.09 10 Freescale Semiconductor 10.3 10.4 10.5 10.6 10.2.1 Detailed Signal Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 Memory Map and Register Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 10.3.1 Module Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 10.3.2 Register Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290 10.4.1 Analog Sub-Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290 10.4.2 Digital Sub-Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290 Resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 Chapter 11 Freescale’s Scalable Controller Area Network (S12MSCANV3) 11.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 11.1.1 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294 11.1.2 Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294 11.1.3 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 11.1.4 Modes of Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 11.2 External Signal Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 11.2.1 RXCAN — CAN Receiver Input Pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 11.2.2 TXCAN — CAN Transmitter Output Pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 11.2.3 CAN System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 11.3 Memory Map and Register Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 11.3.1 Module Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 11.3.2 Register Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299 11.3.3 Programmer’s Model of Message Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318 11.4 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 11.4.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 11.4.2 Message Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 11.4.3 Identifier Acceptance Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332 11.4.4 Modes of Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338 11.4.5 Low-Power Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340 11.4.6 Reset Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344 11.4.7 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344 11.5 Initialization/Application Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346 11.5.1 MSCAN initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346 11.5.2 Bus-Off Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346 Chapter 12 Periodic Interrupt Timer (S12PIT24B4CV1) 12.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347 12.1.1 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347 12.1.2 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347 12.1.3 Modes of Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347 12.1.4 Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348 S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 11 12.2 External Signal Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348 12.3 Register Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349 12.4 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358 12.4.1 Timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358 12.4.2 Interrupt Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359 12.4.3 Hardware Trigger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360 12.5 Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360 12.5.1 Startup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360 12.5.2 Shutdown . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360 12.5.3 Flag Clearing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360 12.6 Application Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361 Chapter 13 Pulse-Width Modulator (S12PWM8B8CV1) 13.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363 13.1.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363 13.1.2 Modes of Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364 13.1.3 Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364 13.2 External Signal Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364 13.2.1 PWM7 — PWM Channel 7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 13.2.2 PWM6 — PWM Channel 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 13.2.3 PWM5 — PWM Channel 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 13.2.4 PWM4 — PWM Channel 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 13.2.5 PWM3 — PWM Channel 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 13.2.6 PWM3 — PWM Channel 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 13.2.7 PWM3 — PWM Channel 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 13.2.8 PWM3 — PWM Channel 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 13.3 Memory Map and Register Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 13.3.1 Module Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 13.3.2 Register Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366 13.4 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381 13.4.1 PWM Clock Select . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381 13.4.2 PWM Channel Timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384 13.5 Resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392 13.6 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393 Chapter 14 Serial Communication Interface (S12SCIV5) 14.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395 14.1.1 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395 14.1.2 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396 14.1.3 Modes of Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396 14.1.4 Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397 14.2 External Signal Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398 S12XS Family Reference Manual, Rev. 1.09 12 Freescale Semiconductor 14.2.1 TXD — Transmit Pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398 14.2.2 RXD — Receive Pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398 14.3 Memory Map and Register Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398 14.3.1 Module Memory Map and Register Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398 14.3.2 Register Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399 14.4 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411 14.4.1 Infrared Interface Submodule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412 14.4.2 LIN Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412 14.4.3 Data Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413 14.4.4 Baud Rate Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414 14.4.5 Transmitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415 14.4.6 Receiver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420 14.4.7 Single-Wire Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428 14.4.8 Loop Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429 14.5 Initialization/Application Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429 14.5.1 Reset Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429 14.5.2 Modes of Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429 14.5.3 Interrupt Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 430 14.5.4 Recovery from Wait Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432 14.5.5 Recovery from Stop Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432 Chapter 15 Serial Peripheral Interface (S12SPIV5) 15.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433 15.1.1 Glossary of Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433 15.1.2 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433 15.1.3 Modes of Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433 15.1.4 Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434 15.2 External Signal Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435 15.2.1 MOSI — Master Out/Slave In Pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435 15.2.2 MISO — Master In/Slave Out Pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435 15.2.3 SS — Slave Select Pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436 15.2.4 SCK — Serial Clock Pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436 15.3 Memory Map and Register Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436 15.3.1 Module Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436 15.3.2 Register Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437 15.4 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445 15.4.1 Master Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446 15.4.2 Slave Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447 15.4.3 Transmission Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448 15.4.4 SPI Baud Rate Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453 15.4.5 Special Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454 15.4.6 Error Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455 15.4.7 Low Power Mode Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456 S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 13 Chapter 16 Timer Module (TIM16B8CV2) Block Description 16.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459 16.1.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460 16.1.2 Modes of Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460 16.1.3 Block Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461 16.2 External Signal Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463 16.2.1 IOC7 — Input Capture and Output Compare Channel 7 Pin . . . . . . . . . . . . . . . . . . . . 463 16.2.2 IOC6 — Input Capture and Output Compare Channel 6 Pin . . . . . . . . . . . . . . . . . . . . 463 16.2.3 IOC5 — Input Capture and Output Compare Channel 5 Pin . . . . . . . . . . . . . . . . . . . . 463 16.2.4 IOC4 — Input Capture and Output Compare Channel 4 Pin . . . . . . . . . . . . . . . . . . . . 463 16.2.5 IOC3 — Input Capture and Output Compare Channel 3 Pin . . . . . . . . . . . . . . . . . . . . 463 16.2.6 IOC2 — Input Capture and Output Compare Channel 2 Pin . . . . . . . . . . . . . . . . . . . . 463 16.2.7 IOC1 — Input Capture and Output Compare Channel 1 Pin . . . . . . . . . . . . . . . . . . . . 464 16.2.8 IOC0 — Input Capture and Output Compare Channel 0 Pin . . . . . . . . . . . . . . . . . . . . 464 16.3 Memory Map and Register Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464 16.3.1 Module Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464 16.3.2 Register Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464 16.4 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481 16.4.1 Prescaler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482 16.4.2 Input Capture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483 16.4.3 Output Compare . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483 16.4.4 Pulse Accumulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484 16.4.5 Event Counter Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484 16.4.6 Gated Time Accumulation Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484 16.5 Resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485 16.6 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485 16.6.1 Channel [7:0] Interrupt (C[7:0]F) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485 16.6.2 Pulse Accumulator Input Interrupt (PAOVI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485 16.6.3 Pulse Accumulator Overflow Interrupt (PAOVF) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485 16.6.4 Timer Overflow Interrupt (TOF) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486 Chapter 17 Voltage Regulator (S12VREGL3V3V1) 17.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487 17.1.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487 17.1.2 Modes of Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487 17.1.3 Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488 17.2 External Signal Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490 17.2.1 VDDR — Regulator Power Input Pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490 17.2.2 VDDA, VSSA — Regulator Reference Supply Pins . . . . . . . . . . . . . . . . . . . . . . . . . . . 490 17.2.3 VDD, VSS — Regulator Output1 (Core Logic) Pins . . . . . . . . . . . . . . . . . . . . . . . . . . 490 17.2.4 VDDF — Regulator Output2 (NVM Logic) Pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491 17.2.5 VDDPLL, VSSPLL — Regulator Output3 (PLL) Pins . . . . . . . . . . . . . . . . . . . . . . . . . 491 S12XS Family Reference Manual, Rev. 1.09 14 Freescale Semiconductor 17.2.6 VDDX — Power Input Pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491 17.2.7 VREGEN — Optional Regulator Enable Pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491 17.2.8 VREG_API — Optional Autonomous Periodical Interrupt Output Pin . . . . . . . . . . . . . . 491 17.3 Memory Map and Register Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491 17.3.1 Module Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492 17.3.2 Register Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493 17.4 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500 17.4.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500 17.4.2 Regulator Core (REG) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500 17.4.3 Low-Voltage Detect (LVD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500 17.4.4 Power-On Reset (POR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500 17.4.5 Low-Voltage Reset (LVR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500 17.4.6 HTD - High Temperature Detect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501 17.4.7 Regulator Control (CTRL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501 17.4.8 Autonomous Periodical Interrupt (API) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501 17.4.9 Resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502 17.4.10Description of Reset Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502 17.4.11Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502 Chapter 18 256 KByte Flash Module (S12XFTMR256K1V1) 18.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505 18.1.1 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506 18.1.2 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507 18.1.3 Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507 18.2 External Signal Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508 18.3 Memory Map and Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508 18.3.1 Module Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509 18.3.2 Register Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512 18.4 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533 18.4.1 Flash Command Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533 18.4.2 Flash Command Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 538 18.4.3 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551 18.4.4 Wait Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552 18.4.5 Stop Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552 18.5 Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552 18.5.1 Unsecuring the MCU using Backdoor Key Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552 18.5.2 Unsecuring the MCU in Special Single Chip Mode using BDM . . . . . . . . . . . . . . . . . 553 18.5.3 Mode and Security Effects on Flash Command Availability . . . . . . . . . . . . . . . . . . . . . 554 18.6 Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554 Chapter 19 128 KByte Flash Module (S12XFTMR128K1V1) 19.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 555 S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 15 19.2 19.3 19.4 19.5 19.6 19.1.1 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556 19.1.2 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 557 19.1.3 Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 557 External Signal Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 558 Memory Map and Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 558 19.3.1 Module Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559 19.3.2 Register Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 562 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583 19.4.1 Flash Command Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583 19.4.2 Flash Command Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 588 19.4.3 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601 19.4.4 Wait Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602 19.4.5 Stop Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602 Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602 19.5.1 Unsecuring the MCU using Backdoor Key Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602 19.5.2 Unsecuring the MCU in Special Single Chip Mode using BDM . . . . . . . . . . . . . . . . . 603 19.5.3 Mode and Security Effects on Flash Command Availability . . . . . . . . . . . . . . . . . . . . . 604 Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604 Chapter 20 64 KByte Flash Module (S12XFTMR64K1V1) 20.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 605 20.1.1 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 606 20.1.2 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607 20.1.3 Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 608 20.2 External Signal Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 608 20.3 Memory Map and Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 609 20.3.1 Module Memory Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 609 20.3.2 Register Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613 20.4 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633 20.4.1 Flash Command Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633 20.4.2 Flash Command Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 638 20.4.3 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 651 20.4.4 Wait Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 652 20.4.5 Stop Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 652 20.5 Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 652 20.5.1 Unsecuring the MCU using Backdoor Key Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . 653 20.5.2 Unsecuring the MCU in Special Single Chip Mode using BDM . . . . . . . . . . . . . . . . . 653 20.5.3 Mode and Security Effects on Flash Command Availability . . . . . . . . . . . . . . . . . . . . . 654 20.6 Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654 Appendix A Electrical Characteristics A.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 655 S12XS Family Reference Manual, Rev. 1.09 16 Freescale Semiconductor A.2 A.3 A.4 A.5 A.6 A.7 A.8 A.1.1 Parameter Classification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 655 A.1.2 Power Supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 655 A.1.3 Pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 656 A.1.4 Current Injection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657 A.1.5 Absolute Maximum Ratings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657 A.1.6 ESD Protection and Latch-up Immunity. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 658 A.1.7 Operating Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 659 A.1.8 Power Dissipation and Thermal Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 660 A.1.9 I/O Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 664 A.1.10 Supply Currents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 667 ATD Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 671 A.2.1 ATD Operating Characteristics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 671 A.2.2 Factors Influencing Accuracy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 671 A.2.3 ATD Accuracy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 673 NVM, Flash. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 677 A.3.1 Timing Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 677 A.3.2 NVM Reliability Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 681 Voltage Regulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 683 Output Loads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 684 A.5.1 Resistive Loads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 684 A.5.2 Capacitive Loads. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 684 A.5.3 Chip Power-up and Voltage Drops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 684 Reset, Oscillator and PLL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 686 A.6.1 Startup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 686 A.6.2 Oscillator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 688 A.6.3 Phase Locked Loop. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 689 MSCAN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 691 SPI Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 692 A.8.1 Master Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 692 A.8.2 Slave Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 694 Appendix B Package Information B.1 112-pin LQFP Mechanical Dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 697 B.2 80-Pin QFP Mechanical Dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700 B.3 64-Pin LQFP Mechanical Dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703 Appendix C PCB Layout Guidelines C.1 General C.1.1 C.1.2 C.1.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 706 112-Pin LQFP Recommended PCB Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707 80-Pin QFP Recommended PCB Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 708 64-Pin LQFP Recommended PCB Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 709 S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 17 Appendix D Derivative Differences D.1 Memory Sizes and Package Options S12XS family . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 710 Appendix E Detailed Register Address Map E.1 Detailed Register Map. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 711 Appendix F Ordering Information F.1 Ordering Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733 S12XS Family Reference Manual, Rev. 1.09 18 Freescale Semiconductor Chapter 1 Device Overview S12XS Family 1.1 Introduction The new S12XS family of 16-bit micro controllers is a compatible, reduced version of the S12XE family. These families provide an easy approach to develop common platforms from low-end to high-end applications, minimizing the redesign of software and hardware. Targeted at generic automotive applications and CAN nodes, some typical examples of these applications are: Body Controllers, Occupant Detection, Door Modules, RKE Receivers, Smart Actuators, Lighting Modules and Smart Junction Boxes amongst many others. The S12XS family retains many of the features of the S12XE family including Error Correction Code (ECC) on Flash memory, a separate Data-Flash Module for code or data storage, a Frequency Modulated Locked Loop (IPLL) that improves the EMC performance and a fast ATD converter. S12XS family delivers 32-bit performance with all the advantages and efficiencies of a 16-bit MCU while retaining the low cost, power consumption, EMC and code-size efficiency advantages currently enjoyed by users of Freescale’s existing 16-bit S12 and S12X MCU families. Like members of other S12X families, the S12XS family runs 16-bit wide accesses without wait states for all peripherals and memories. The S12XS family is available in 112-pin LQFP, 80-pin QFP, 64-pin LQFP package options and maintains a high level of pin compatibility with the S12XE family. In addition to the I/O ports available in each module, up to 18 further I/O ports are available with interrupt capability allowing Wake-Up from stop or wait modes. The peripheral set includes MSCAN, SPI, two SCIs, an 8-channel 24-bit periodic interrupt timer, 8channel 16-bit Timer, 8-channel PWM and up to 16- channel 12-bit ATD converter. Software controlled peripheral-to-port routing enables access to a flexible mix of the peripheral modules in the lower pin count package options. 1.1.1 Features Features of the S12XS Family are listed here. Please see Table D-1 for memory options and Table D-2 for the peripheral features that are available on the different family members. • 16-bit CPU12X — Upward compatible with S12 instruction set with the exception of five Fuzzy instructions (MEM, WAV, WAVR, REV, REVW) which have been removed — Enhanced indexed addressing — Access to large data segments independent of PPAGE S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 19 Device Overview S12XS Family • • • • • • • • INT (interrupt module) — Seven levels of nested interrupts — Flexible assignment of interrupt sources to each interrupt level. — External non-maskable high priority interrupt (XIRQ) — The following inputs can act as Wake-up Interrupts – IRQ and non-maskable XIRQ – CAN receive pins – SCI receive pins – Depending on the package option up to 20 pins on ports J, H and P configurable as rising or falling edge sensitive MMC (module mapping control) DBG (debug module) — Monitoring of CPU bus with tag-type or force-type breakpoint requests — 64 x 64-bit circular trace buffer captures change-of-flow or memory access information BDM (background debug mode) OSC_LCP (oscillator) — Low power loop control Pierce oscillator utilizing a 4MHz to 16MHz crystal — Good noise immunity — Full-swing Pierce option utilizing a 2MHz to 40MHz crystal — Transconductance sized for optimum start-up margin for typical crystals IPLL (Internally filtered, frequency modulated phase-locked-loop clock generation) — No external components required — Configurable option to spread spectrum for reduced EMC radiation (frequency modulation) CRG (clock and reset generation) — COP watchdog — Real time interrupt — Clock monitor — Fast wake up from STOP in self clock mode Memory Options — 64K, 128K and 256K byte Flash — Flash General Features – 64 data bits plus 8 syndrome ECC (Error Correction Code) bits allow single bit failure correction and double fault detection – Erase sector size 1024 bytes – Automated program and erase algorithm – Protection scheme to prevent accidental program or erase – Security option to prevent unauthorized access – Sense-amp margin level setting for reads — 4K and 8K byte Data Flash space S12XS Family Reference Manual, Rev. 1.09 20 Freescale Semiconductor Device Overview S12XS Family • • • • – 16 data bits plus 6 syndrome ECC (Error Correction Code) bits allow single bit failure correction and double fault detection – Erase sector size 256 bytes – Automated program and erase algorithm — 4K, 8K and 12K byte RAM 16-channel, 12-bit Analog-to-Digital converter — 8/10/12 Bit resolution — 3µs, 10-bit single conversion time — Left or right justified result data — External and internal conversion trigger capability — Internal oscillator for conversion in Stop modes — Wake from low power modes on analog comparison > or Addmax Two types of triggers — Tagged — This triggers just before a specific instruction begins execution — Force — This triggers on the first instruction boundary after a match occurs. The following types of breakpoints — CPU12X breakpoint entering BDM on breakpoint (BDM) — CPU12X breakpoint executing SWI on breakpoint (SWI) TRIG Immediate software trigger independent of comparators Four trace modes — Normal: change of flow (COF) PC information is stored (see Section 6.4.5.2.1) for change of flow definition. • • • • • S12XS Family Reference Manual, Rev. 1.09 192 Freescale Semiconductor S12X Debug (S12XDBGV3) Module • — Loop1: same as Normal but inhibits consecutive duplicate source address entries — Detail: address and data for all cycles except free cycles and opcode fetches are stored — Pure PC: All program counter addresses are stored. 4-stage state sequencer for trace buffer control — Tracing session trigger linked to Final State of state sequencer — Begin, End, and Mid alignment of tracing to trigger 6.1.4 Modes of Operation The S12XDBG module can be used in all MCU functional modes. During BDM hardware accesses and whilst the BDM module is active, CPU12X monitoring is disabled. Thus breakpoints, comparators, and CPU12X bus tracing are disabled . When the CPU12X enters active BDM Mode through a BACKGROUND command, with the S12XDBG module armed, the S12XDBG remains armed. The S12XDBG module tracing is disabled if the MCU is secure. However, breakpoints can still be generated if the MCU is secure. Table 6-3. Mode Dependent Restriction Summary BDM Enable x 0 0 1 1 BDM Active x 0 1 0 1 MCU Secure 1 0 0 0 0 Yes No Comparator Matches Enabled Yes Yes Breakpoints Possible Yes Only SWI Yes No Tagging Possible Yes Yes Yes No Tracing Possible No Yes Yes No Active BDM not possible when not enabled S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 193 S12X Debug (S12XDBGV3) Module 6.1.5 Block Diagram TAGS BREAKPOINT REQUESTS TAGHITS SECURE COMPARATOR A COMPARATOR B COMPARATOR C COMPARATOR D MATCH0 COMPARATOR MATCH CONTROL MATCH1 MATCH2 MATCH3 TAG & TRIGGER CONTROL LOGIC TRIGGER S12XCPU S12XCPU BUS BUS INTERFACE STATE STATE SEQUENCER STATE TRACE CONTROL TRIGGER TRACE BUFFER READ TRACE DATA (DBG READ DATA BUS) Figure 6-1. Debug Module Block Diagram 6.2 External Signal Description The S12XDBG sub-module features no external signals. 6.3 6.3.1 Memory Map and Registers Module Memory Map A summary of the registers associated with the S12XDBG sub-block is shown in Table 6-2. Detailed descriptions of the registers and bits are given in the subsections that follow. Address 0x0020 Name DBGC1 R W R W Bit 7 ARM TBF 6 0 TRIG 0 5 reserved 0 4 BDM 0 3 DBGBRK 0 2 reserved SSF2 1 Bit 0 COMRV SSF1 SSF0 0x0021 DBGSR 0x0022 DBGTCR R reserved W R W 0 TSOURCE 0 0 TRANGE 0 TRCMOD TALIGN 0x0023 DBGC2 CDCM ABCM Figure 6-2. Quick Reference to S12XDBG Registers S12XS Family Reference Manual, Rev. 1.09 194 Freescale Semiconductor S12X Debug (S12XDBGV3) Module Address 0x0024 Name DBGTBH R W R W R W R W R W Bit 7 Bit 15 6 Bit 14 5 Bit 13 4 Bit 12 3 Bit 11 2 Bit 10 1 Bit 9 Bit 0 Bit 8 0x0025 DBGTBL Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 0x0026 DBGCNT 0 CNT 0x0027 0x0027 0x00281 0x00282 DBGSCRX DBGMFR 0 0 0 0 0 0 0 0 SC3 MC3 SC2 MC2 SC1 MC1 SC0 MC0 DBGXCTL R (COMPA/C) W DBGXCTL R (COMPB/D) W DBGXAH R W R W R W R W R W R W 0 NDB SZ TAG TAG BRK BRK RW RW RWE RWE reserved reserved COMPE COMPE SZE 0 0x0029 Bit 22 21 20 19 18 17 Bit 16 0x002A DBGXAM Bit 15 14 13 12 11 10 9 Bit 8 0x002B DBGXAL Bit 7 6 5 4 3 2 1 Bit 0 0x002C DBGXDH Bit 15 14 13 12 11 10 9 Bit 8 0x002D DBGXDL Bit 7 6 5 4 3 2 1 Bit 0 0x002E DBGXDHM Bit 15 14 13 12 11 10 9 Bit 8 R Bit 7 6 5 4 3 2 W 1 This represents the contents if the Comparator A or C control register is blended into this address. 2 This represents the contents if the Comparator B or D control register is blended into this address 0x002F DBGXDLM 1 Bit 0 Figure 6-2. Quick Reference to S12XDBG Registers 6.3.2 Register Descriptions This section consists of the S12XDBG control and trace buffer register descriptions in address order. Each comparator has a bank of registers that are visible through an 8-byte window between 0x0028 and 0x002F in the S12XDBG module register address map. When ARM is set in DBGC1, the only bits in the S12XDBG module registers that can be written are ARM, TRIG, and COMRV[1:0] S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 195 S12X Debug (S12XDBGV3) Module 6.3.2.1 Debug Control Register 1 (DBGC1) Address: 0x0020 7 6 5 4 3 2 1 0 R W Reset ARM 0 0 TRIG 0 reserved 0 BDM 0 DBGBRK 0 reserved 0 0 COMRV 0 Figure 6-3. Debug Control Register (DBGC1) Read: Anytime Write: Bits 7, 1, 0 anytime Bit 6 can be written anytime but always reads back as 0. Bits 5:2 anytime S12XDBG is not armed. NOTE If a write access to DBGC1 with the ARM bit position set occurs simultaneously to a hardware disarm from an internal trigger event, then the ARM bit is cleared due to the hardware disarm. NOTE When disarming the S12XDBG by clearing ARM with software, the contents of bits[5:2] are not affected by the write, since up until the write operation, ARM = 1 preventing these bits from being written. These bits must be cleared using a second write if required. Table 6-4. DBGC1 Field Descriptions Field 7 ARM Description Arm Bit — The ARM bit controls whether the S12XDBG module is armed. This bit can be set and cleared by user software and is automatically cleared on completion of a tracing session, or if a breakpoint is generated with tracing not enabled. On setting this bit the state sequencer enters State1. 0 Debugger disarmed 1 Debugger armed Immediate Trigger Request Bit — This bit when written to 1 requests an immediate trigger independent of comparator signal status. When tracing is complete a forced breakpoint may be generated depending upon DBGBRK and BDM bit settings. This bit always reads back a 0. Writing a 0 to this bit has no effect. If TSOURCE is clear no tracing is carried out. If tracing has already commenced using BEGIN- or MID trigger alignment, it continues until the end of the tracing session as defined by the TALIGN bit settings, thus TRIG has no affect. In secure mode tracing is disabled and writing to this bit has no effect. 0 Do not trigger until the state sequencer enters the Final State. 1 Trigger immediately . This bit is reserved, setting it has no meaning or effect. Background Debug Mode Enable — This bit determines if an S12X breakpoint causes the system to enter Background Debug Mode (BDM) or initiate a Software Interrupt (SWI). If this bit is set but the BDM is not enabled by the ENBDM bit in the BDM module, then breakpoints default to SWI. 0 Breakpoint to Software Interrupt if BDM inactive. Otherwise no breakpoint. 1 Breakpoint to BDM, if BDM enabled. Otherwise breakpoint to SWI 6 TRIG 5 reserved 4 BDM S12XS Family Reference Manual, Rev. 1.09 196 Freescale Semiconductor S12X Debug (S12XDBGV3) Module Table 6-4. DBGC1 Field Descriptions (continued) Field 3 DBGBRK Description S12XDBG Breakpoint Enable Bit — The DBGBRK bit controls whether the debugger will request a breakpoint to S12XCPU upon reaching the state sequencer Final State. If tracing is enabled, the breakpoint is generated on completion of the tracing session. If tracing is not enabled, the breakpoint is generated immediately. Please refer to Section 6.4.7 for further details. 0 No breakpoint on trigger. 1 Breakpoint on trigger Comparator Register Visibility Bits — These bits determine which bank of comparator register is visible in the 8-byte window of the S12XDBG module address map, located between 0x0028 to 0x002F. Furthermore these bits determine which register is visible at the address 0x0027. See Table 6-5. 1–0 COMRV Table 6-5. COMRV Encoding COMRV 00 01 10 11 Visible Comparator Comparator A Comparator B Comparator C Comparator D Visible Register at 0x0027 DBGSCR1 DBGSCR2 DBGSCR3 DBGMFR 6.3.2.2 Debug Status Register (DBGSR) 7 6 5 4 3 2 1 0 Address: 0x0021 R W Reset POR — 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 TBF 0 0 0 0 SSF2 SSF1 SSF0 = Unimplemented or Reserved Figure 6-4. Debug Status Register (DBGSR) Read: Anytime Write: Never Table 6-6. DBGSR Field Descriptions Field 7 TBF Description Trace Buffer Full — The TBF bit indicates that the trace buffer has stored 64 or more lines of data since it was last armed. If this bit is set, then all 64 lines will be valid data, regardless of the value of DBGCNT bits CNT[6:0]. The TBF bit is cleared when ARM in DBGC1 is written to a one. The TBF is cleared by the power on reset initialization. Other system generated resets have no affect on this bit State Sequencer Flag Bits — The SSF bits indicate in which state the State Sequencer is currently in. During a debug session on each transition to a new state these bits are updated. If the debug session is ended by software clearing the ARM bit, then these bits retain their value to reflect the last state of the state sequencer before disarming. If a debug session is ended by an internal trigger, then the state sequencer returns to state0 and these bits are cleared to indicate that state0 was entered during the session. On arming the module the state sequencer enters state1 and these bits are forced to SSF[2:0] = 001. See Table 6-7. 2–0 SSF[2:0] S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 197 S12X Debug (S12XDBGV3) Module Table 6-7. SSF[2:0] — State Sequence Flag Bit Encoding SSF[2:0] 000 001 010 011 100 101,110,111 Current State State0 (disarmed) State1 State2 State3 Final State Reserved 6.3.2.3 Debug Trace Control Register (DBGTCR) 7 6 5 4 3 2 1 0 Address: 0x0022 R W Reset reserved 0 TSOURCE 0 0 TRANGE 0 0 TRCMOD 0 0 TALIGN 0 Figure 6-5. Debug Trace Control Register (DBGTCR) Read: Anytime Write: Bits 7:6 only when S12XDBG is neither secure nor armed. Bits 5:0 anytime the module is disarmed. WARNING DBGTCR[7] is reserved. Setting this bit maps the tracing to an unimplemented bus, thus preventing proper operation. Table 6-8. DBGTCR Field Descriptions Field 6 TSOURCE Description Trace Source Control Bits — The TSOURCE enables the tracing session. If the MCU system is secured, this bit cannot be set and tracing is inhibited. 0 No tracing selected 1 Tracing selected Trace Range Bits — The TRANGE bits allow filtering of trace information from a selected address range when tracing from the CPU12X in Detail Mode. To use a comparator for range filtering, the corresponding COMPE bits must remain cleared. If the COMPE bit is not clear then the comparator will also be used to generate state sequence triggers. See Table 6-9. Trace Mode Bits — See Section 6.4.5.2 for detailed Trace Mode descriptions. In Normal Mode, change of flow information is stored. In Loop1 Mode, change of flow information is stored but redundant entries into trace memory are inhibited. In Detail Mode, address and data for all memory and register accesses is stored. See Table 6-10. Trigger Align Bits — These bits control whether the trigger is aligned to the beginning, end or the middle of a tracing session. See Table 6-11. 5–4 TRANGE 3–2 TRCMOD 1–0 TALIGN S12XS Family Reference Manual, Rev. 1.09 198 Freescale Semiconductor S12X Debug (S12XDBGV3) Module Table 6-9. TRANGE Trace Range Encoding TRANGE 00 01 10 11 Tracing Range Trace from all addresses (No filter) Trace only in address range from $00000 to Comparator D Trace only in address range from Comparator C to $7FFFFF Trace only in range from Comparator C to Comparator D Table 6-10. TRCMOD Trace Mode Bit Encoding TRCMOD 00 01 10 11 Description Normal Loop1 Detail Pure PC Table 6-11. TALIGN Trace Alignment Encoding TALIGN 00 01 10 11 Description Trigger at end of stored data Trigger before storing data Trace buffer entries before and after trigger Reserved 6.3.2.4 Debug Control Register2 (DBGC2) Address: 0x0023 7 6 5 4 3 2 1 0 R W Reset 0 0 0 0 0 0 0 0 0 CDCM 0 0 ABCM 0 = Unimplemented or Reserved Figure 6-6. Debug Control Register2 (DBGC2) Read: Anytime Write: Anytime the module is disarmed. This register configures the comparators for range matching. Table 6-12. DBGC2 Field Descriptions Field 3–2 CDCM[1:0] 1–0 ABCM[1:0] Description C and D Comparator Match Control — These bits determine the C and D comparator match mapping as described in Table 6-13. A and B Comparator Match Control — These bits determine the A and B comparator match mapping as described in Table 6-14. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 199 S12X Debug (S12XDBGV3) Module Table 6-13. CDCM Encoding CDCM 00 01 10 Description Match2 mapped to comparator C match....... Match3 mapped to comparator D match. Match2 mapped to comparator C/D inside range....... Match3 disabled. Match2 mapped to comparator C/D outside range....... Match3 disabled. 11 Reserved1 1 Currently defaults to Match2 mapped to comparator C : Match3 mapped to comparator D Table 6-14. ABCM Encoding ABCM 00 01 10 Description Match0 mapped to comparator A match....... Match1 mapped to comparator B match. Match 0 mapped to comparator A/B inside range....... Match1 disabled. Match 0 mapped to comparator A/B outside range....... Match1 disabled. 11 Reserved1 Currently defaults to Match0 mapped to comparator A : Match1 mapped to comparator B 1 6.3.2.5 Debug Trace Buffer Register (DBGTBH:DBGTBL) Address: 0x0024, 0x0025 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 R W POR Other Resets Bit 15 Bit 14 Bit 13 Bit 12 Bit 11 Bit 10 Bit 9 X — X — X — X — X — X — X — Bit 8 X — Bit 7 X — Bit 6 X — Bit 5 X — Bit 4 X — Bit 3 X — Bit 2 X — Bit 1 X — Bit 0 X — Figure 6-7. Debug Trace Buffer Register (DBGTB) Read: Only when unlocked AND not secured AND not armed AND with the TSOURCE bit set. Write: Aligned word writes when disarmed unlock the trace buffer for reading but do not affect trace buffer contents. Table 6-15. DBGTB Field Descriptions Field 15–0 Bit[15:0] Description Trace Buffer Data Bits — The Trace Buffer Register is a window through which the 64-bit wide data lines of the Trace Buffer may be read 16 bits at a time. Each valid read of DBGTB increments an internal trace buffer pointer which points to the next address to be read. When the ARM bit is written to 1 the trace buffer is locked to prevent reading. The trace buffer can only be unlocked for reading by writing to DBGTB with an aligned word write when the module is disarmed. The DBGTB register can be read only as an aligned word, any byte reads or misaligned access of these registers will return 0 and will not cause the trace buffer pointer to increment to the next trace buffer address. The same is true for word reads while the debugger is armed. The POR state is undefined Other resets do not affect the trace buffer contents. . S12XS Family Reference Manual, Rev. 1.09 200 Freescale Semiconductor S12X Debug (S12XDBGV3) Module 6.3.2.6 Debug Count Register (DBGCNT) Address: 0x0026 7 6 5 4 3 2 1 0 R W Reset POR 0 0 0 — 0 — 0 — 0 CNT — 0 — 0 — 0 — 0 = Unimplemented or Reserved Figure 6-8. Debug Count Register (DBGCNT) Read: Anytime Write: Never Table 6-16. DBGCNT Field Descriptions Field 6–0 CNT[6:0] Description Count Value — The CNT bits [6:0] indicate the number of valid data 64-bit data lines stored in the Trace Buffer. Table 6-17 shows the correlation between the CNT bits and the number of valid data lines in the Trace Buffer. When the CNT rolls over to zero, the TBF bit in DBGSR is set and incrementing of CNT will continue in endtrigger or mid-trigger mode. The DBGCNT register is cleared when ARM in DBGC1 is written to a one. The DBGCNT register is cleared by power-on-reset initialization but is not cleared by other system resets. Thus should a reset occur during a debug session, the DBGCNT register still indicates after the reset, the number of valid trace buffer entries stored before the reset occurred. The DBGCNT register is not decremented when reading from the trace buffer. Table 6-17. CNT Decoding Table TBF (DBGSR) 0 0 0 CNT[6:0] 0000000 0000001 0000010 0000100 0000110 .. 1111100 1111110 0000000 0000010 .. .. 1111110 Description No data valid 32 bits of one line valid 1 line valid 2 lines valid 3 lines valid .. 62 lines valid 63 lines valid 64 lines valid; if using Begin trigger alignment, ARM bit will be cleared and the tracing session ends. 64 lines valid, oldest data has been overwritten by most recent data 0 1 1 6.3.2.7 Debug State Control Registers There is a dedicated control register for each of the state sequencer states 1 to 3 that determines if transitions from that state are allowed, depending upon comparator matches or tag hits, and defines the S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 201 S12X Debug (S12XDBGV3) Module next state for the state sequencer following a match. The three debug state control registers are located at the same address in the register address map (0x0027). Each register can be accessed using the COMRV bits in DBGC1 to blend in the required register. The COMRV = 11 value blends in the match flag register (DBGMFR). Table 6-18. State Control Register Access Encoding COMRV 00 01 10 11 Visible State Control Register DBGSCR1 DBGSCR2 DBGSCR3 DBGMFR 6.3.2.7.1 Address: 0x0027 7 Debug State Control Register 1 (DBGSCR1) 6 5 4 3 2 1 0 R W Reset 0 0 0 0 0 0 0 0 SC3 0 SC2 0 SC1 0 SC0 0 = Unimplemented or Reserved Figure 6-9. Debug State Control Register 1 (DBGSCR1) Read: If COMRV[1:0] = 00 Write: If COMRV[1:0] = 00 and S12XDBG is not armed. This register is visible at 0x0027 only with COMRV[1:0] = 00. The state control register 1 selects the targeted next state whilst in State1. The matches refer to the match channels of the comparator match control logic as depicted in Figure 6-1 and described in Section 6.3.2.8.1”. Comparators must be enabled by setting the comparator enable bit in the associated DBGXCTL control register. Table 6-19. DBGSCR1 Field Descriptions Field 3–0 SC[3:0] Description These bits select the targeted next state whilst in State1, based upon the match event. Table 6-20. State1 Sequencer Next State Selection SC[3:0] 0000 0001 0010 0011 0100 0101 0110 Description Any match triggers to state2 Any match triggers to state3 Any match triggers to Final State Match2 triggers to State2....... Other matches have no effect Match2 triggers to State3....... Other matches have no effect Match2 triggers to Final State....... Other matches have no effect Match0 triggers to State2....... Match1 triggers to State3....... Other matches have no effect S12XS Family Reference Manual, Rev. 1.09 202 Freescale Semiconductor S12X Debug (S12XDBGV3) Module Table 6-20. State1 Sequencer Next State Selection (continued) SC[3:0] 0111 1000 1001 1010 1011 1100 1101 1110 1111 Description Match1 triggers to State3....... Match0 triggers Final State....... Other matches have no effect Match0 triggers to State2....... Match2 triggers to State3....... Other matches have no effect Match2 triggers to State3....... Match0 triggers Final State....... Other matches have no effect Match1 triggers to State2....... Match3 triggers to State3....... Other matches have no effect Match3 triggers to State3....... Match1 triggers to Final State....... Other matches have no effect Match3 has no effect....... All other matches (M0,M1,M2) trigger to State2 Reserved. (No match triggers state sequencer transition) Reserved. (No match triggers state sequencer transition) Reserved. (No match triggers state sequencer transition) The trigger priorities described in Table 6-39 dictate that in the case of simultaneous matches, the match on the lower channel number (0,1,2,3) has priority. The SC[3:0] encoding ensures that a match leading to final state has priority over all other matches. 6.3.2.7.2 Address: 0x0027 7 6 5 4 3 2 1 0 Debug State Control Register 2 (DBGSCR2) R W Reset 0 0 0 0 0 0 0 0 SC3 0 SC2 0 SC1 0 SC0 0 = Unimplemented or Reserved Figure 6-10. Debug State Control Register 2 (DBGSCR2) Read: If COMRV[1:0] = 01 Write: If COMRV[1:0] = 01 and S12XDBG is not armed. This register is visible at 0x0027 only with COMRV[1:0] = 01. The state control register 2 selects the targeted next state whilst in State2. The matches refer to the match channels of the comparator match control logic as depicted in Figure 6-1 and described in Section 6.3.2.8.1”. Comparators must be enabled by setting the comparator enable bit in the associated DBGXCTL control register. Table 6-21. DBGSCR2 Field Descriptions Field 3–0 SC[3:0] Description These bits select the targeted next state whilst in State2, based upon the match event. Table 6-22. State2 —Sequencer Next State Selection SC[3:0] 0000 0001 0010 0011 0100 Description Any match triggers to state1 Any match triggers to state3 Any match triggers to Final State Match3 triggers to State1....... Other matches have no effect Match3 triggers to State3....... Other matches have no effect S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 203 S12X Debug (S12XDBGV3) Module Table 6-22. State2 —Sequencer Next State Selection (continued) SC[3:0] 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 Description Match3 triggers to Final State....... Other matches have no effect Match0 triggers to State1....... Match1 triggers to State3....... Other matches have no effect Match1 triggers to State3....... Match0 triggers Final State....... Other matches have no effect Match0 triggers to State1....... Match2 triggers to State3....... Other matches have no effect Match2 triggers to State3....... Match0 triggers Final State....... Other matches have no effect Match1 triggers to State1....... Match3 triggers to State3....... Other matches have no effect Match3 triggers to State3....... Match1 triggers Final State....... Other matches have no effect Match2 triggers to State1..... Match3 trigger to Final State Match2 has no affect, all other matches (M0,M1,M3) trigger to Final State Reserved. (No match triggers state sequencer transition) Reserved. (No match triggers state sequencer transition) The trigger priorities described in Table 6-39 dictate that in the case of simultaneous matches, the match on the lower channel number (0,1,2,3) has priority. The SC[3:0] encoding ensures that a match leading to final state has priority over all other matches. 6.3.2.7.3 Address: 0x0027 7 6 5 4 3 2 1 0 Debug State Control Register 3 (DBGSCR3) R W Reset 0 0 0 0 0 0 0 0 SC3 0 SC2 0 SC1 0 SC0 0 = Unimplemented or Reserved Figure 6-11. Debug State Control Register 3 (DBGSCR3) Read: If COMRV[1:0] = 10 Write: If COMRV[1:0] = 10 and S12XDBG is not armed. This register is visible at 0x0027 only with COMRV[1:0] = 10. The state control register three selects the targeted next state whilst in State3. The matches refer to the match channels of the comparator match control logic as depicted in Figure 6-1 and described in Section 6.3.2.8.1”. Comparators must be enabled by setting the comparator enable bit in the associated DBGXCTL control register. Table 6-23. DBGSCR3 Field Descriptions Field 3–0 SC[3:0] Description These bits select the targeted next state whilst in State3, based upon the match event. Table 6-24. State3 — Sequencer Next State Selection SC[3:0] 0000 0001 Description Any match triggers to state1 Any match triggers to state2 S12XS Family Reference Manual, Rev. 1.09 204 Freescale Semiconductor S12X Debug (S12XDBGV3) Module Table 6-24. State3 — Sequencer Next State Selection SC[3:0] 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 Description Any match triggers to Final State Match0 triggers to State1....... Other matches have no effect Match0 triggers to State2....... Other matches have no effect Match0 triggers to Final State.......Match1 triggers to State1...Other matches have no effect Match1 triggers to State1....... Other matches have no effect Match1 triggers to State2....... Other matches have no effect Match1 triggers to Final State....... Other matches have no effect Match2 triggers to State2....... Match0 triggers to Final State....... Other matches have no effect Match1 triggers to State1....... Match3 triggers to State2....... Other matches have no effect Match3 triggers to State2....... Match1 triggers to Final State....... Other matches have no effect Match2 triggers to Final State....... Other matches have no effect Match3 triggers to Final State....... Other matches have no effect Reserved. (No match triggers state sequencer transition) Reserved. (No match triggers state sequencer transition) The trigger priorities described in Table 6-39 dictate that in the case of simultaneous matches, the match on the lower channel number (0,1,2,3) has priority. The SC[3:0] encoding ensures that a match leading to final state has priority over all other matches. 6.3.2.7.4 Address: 0x0027 7 6 5 4 3 2 1 0 Debug Match Flag Register (DBGMFR) R W Reset 0 0 0 0 0 0 0 0 MC3 0 MC2 0 MC1 0 MC0 0 = Unimplemented or Reserved Figure 6-12. Debug Match Flag Register (DBGMFR) Read: If COMRV[1:0] = 11 Write: Never DBGMFR is visible at 0x0027 only with COMRV[1:0] = 11. It features four flag bits each mapped directly to a channel. Should a match occur on the channel during the debug session, then the corresponding flag is set and remains set until the next time the module is armed by writing to the ARM bit. Thus the contents are retained after a debug session for evaluation purposes. These flags cannot be cleared by software, they are cleared only when arming the module. A set flag does not inhibit the setting of other flags. Once a flag is set, further triggers on the same channel have no affect. 6.3.2.8 Comparator Register Descriptions Each comparator has a bank of registers that are visible through an 8-byte window in the S12XDBG module register address map. Comparators A and C consist of 8 register bytes (3 address bus compare registers, two data bus compare registers, two data bus mask registers and a control register). S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 205 S12X Debug (S12XDBGV3) Module Comparators B and D consist of four register bytes (three address bus compare registers and a control register). Each set of comparator registers is accessible in the same 8-byte window of the register address map and can be accessed using the COMRV bits in the DBGC1 register. If the Comparators B or D are accessed through the 8-byte window, then only the address and control bytes are visible, the 4 bytes associated with data bus and data bus masking read as zero and cannot be written. Furthermore the control registers for comparators B and D differ from those of comparators A and C. Table 6-25. Comparator Register Layout 0x0028 0x0029 0x002A 0x002B 0x002C 0x002D 0x002E 0x002F CONTROL ADDRESS HIGH ADDRESS MEDIUM ADDRESS LOW DATA HIGH COMPARATOR DATA LOW COMPARATOR DATA HIGH MASK DATA LOW MASK Read/Write Read/Write Read/Write Read/Write Read/Write Read/Write Read/Write Read/Write Comparators A,B,C,D Comparators A,B,C,D Comparators A,B,C,D Comparators A,B,C,D Comparator A and C only Comparator A and C only Comparator A and C only Comparator A and C only 6.3.2.8.1 Debug Comparator Control Register (DBGXCTL) The contents of this register bits 7 and 6 differ depending upon which comparator registers are visible in the 8-byte window of the DBG module register address map. Address: 0x0028 7 6 5 4 3 2 1 0 R W Reset 0 0 NDB 0 TAG 0 BRK 0 RW 0 RWE 0 reserved 0 COMPE 0 = Unimplemented or Reserved Figure 6-13. Debug Comparator Control Register (Comparators A and C) Address: 0x0028 7 6 5 4 3 2 1 0 R W Reset SZE 0 SZ 0 TAG 0 BRK 0 RW 0 RWE 0 reserved 0 COMPE 0 Figure 6-14. Debug Comparator Control Register (Comparators B and D) Read: Anytime. See Table 6-26 for visible register encoding. Write: If DBG not armed. See Table 6-26 for visible register encoding. WARNING DBGXCTL[1] is reserved. Setting this bit maps the corresponding comparator to an S12XS Family Reference Manual, Rev. 1.09 206 Freescale Semiconductor S12X Debug (S12XDBGV3) Module unimplemented bus, thus preventing proper operation. The DBGC1_COMRV bits determine which comparator control, address, data and datamask registers are visible in the 8-byte window from 0x0028 to 0x002F as shown in Section Table 6-26. Table 6-26. Comparator Address Register Visibility COMRV 00 01 10 11 Visible Comparator DBGACTL, DBGAAH ,DBGAAM, DBGAAL, DBGADH, DBGADL, DBGADHM, DBGADLM DBGBCTL, DBGBAH, DBGBAM, DBGBAL DBGCCTL, DBGCAH, DBGCAM, DBGCAL, DBGCDH, DBGCDL, DBGCDHM, DBGCDLM DBGDCTL, DBGDAH, DBGDAM, DBGDAL Table 6-27. DBGXCTL Field Descriptions Field 7 SZE (Comparators B and D) 6 NDB (Comparators A and C Description Size Comparator Enable Bit — The SZE bit controls whether access size comparison is enabled for the associated comparator. This bit is ignored if the TAG bit in the same register is set. 0 Word/Byte access size is not used in comparison 1 Word/Byte access size is used in comparison Not Data Bus — The NDB bit controls whether the match occurs when the data bus matches the comparator register value or when the data bus differs from the register value. Furthermore data bus bits can be individually masked using the comparator data mask registers. This bit is only available for comparators A and C. This bit is ignored if the TAG bit in the same register is set. This bit position has an SZ functionality for comparators B and D. 0 Match on data bus equivalence to comparator register contents 1 Match on data bus difference to comparator register contents Size Comparator Value Bit — The SZ bit selects either word or byte access size in comparison for the associated comparator. This bit is ignored if the SZE bit is cleared or if the TAG bit in the same register is set. This bit position has NDB functionality for comparators A and C 0 Word access size will be compared 1 Byte access size will be compared Tag Select — This bit controls whether the comparator match will cause a trigger or tag the opcode at the matched address. Tagged opcodes trigger only if they reach the execution stage of the instruction queue. 0 Trigger immediately on match 1 On match, tag the opcode. If the opcode is about to be executed a trigger is generated Break — This bit controls whether a channel match terminates a debug session immediately, independent of state sequencer state. To generate an immediate breakpoint the module breakpoints must be enabled using DBGBRK. 0 The debug session termination is dependent upon the state sequencer and trigger conditions. 1 A match on this channel terminates the debug session immediately; breakpoints if active are generated, tracing, if active, is terminated and the module disarmed. Read/Write Comparator Value Bit — The RW bit controls whether read or write is used in compare for the associated comparator . The RW bit is not used if RWE = 0. 0 Write cycle will be matched 1 Read cycle will be matched Read/Write Enable Bit — The RWE bit controls whether read or write comparison is enabled for the associated comparator. This bit is not used for tagged operations. 0 Read/Write is not used in comparison 1 Read/Write is used in comparison 6 SZ (Comparators B and D) 5 TAG 4 BRK 3 RW 2 RWE S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 207 S12X Debug (S12XDBGV3) Module Table 6-27. DBGXCTL Field Descriptions (continued) Field 0 COMPE Description Determines if comparator is enabled 0 The comparator is not enabled 1 The comparator is enabled for state sequence triggers or tag generation Table 6-28 shows the effect for RWE and RW on the comparison conditions. These bits are not useful for tagged operations since the trigger occurs based on the tagged opcode reaching the execution stage of the instruction queue. Thus these bits are ignored if tagged triggering is selected. Table 6-28. Read or Write Comparison Logic Table RWE Bit 0 0 1 1 1 1 RW Bit x x 0 0 1 1 RW Signal 0 1 0 1 0 1 Comment RW not used in comparison RW not used in comparison Write No match No match Read 6.3.2.8.2 Address: 0x0029 7 Debug Comparator Address High Register (DBGXAH) 6 5 4 3 2 1 0 R W Reset 0 0 Bit 22 0 Bit 21 0 Bit 20 0 Bit 19 0 Bit 18 0 Bit 17 0 Bit 16 0 = Unimplemented or Reserved Figure 6-15. Debug Comparator Address High Register (DBGXAH) Read: Anytime. See Table 6-26 for visible register encoding. Write: If DBG not armed. See Table 6-26 for visible register encoding. Table 6-29. DBGXAH Field Descriptions Field 6–0 Bit[22:16] Description Comparator Address High Compare Bits — The Comparator address high compare bits control whether the selected comparator will compare the address bus bits [22:16] to a logic one or logic zero. . 0 Compare corresponding address bit to a logic zero 1 Compare corresponding address bit to a logic one S12XS Family Reference Manual, Rev. 1.09 208 Freescale Semiconductor S12X Debug (S12XDBGV3) Module 6.3.2.8.3 Address: 0x002A 7 Debug Comparator Address Mid Register (DBGXAM) 6 5 4 3 2 1 0 R W Reset Bit 15 0 Bit 14 0 Bit 13 0 Bit 12 0 Bit 11 0 Bit 10 0 Bit 9 0 Bit 8 0 Figure 6-16. Debug Comparator Address Mid Register (DBGXAM) Read: Anytime. See Table 6-26 for visible register encoding. Write: If DBG not armed. See Table 6-26 for visible register encoding. Table 6-30. DBGXAM Field Descriptions Field 7–0 Bit[15:8] Description Comparator Address Mid Compare Bits— The Comparator address mid compare bits control whether the selected comparator will compare the address bus bits [15:8] to a logic one or logic zero. 0 Compare corresponding address bit to a logic zero 1 Compare corresponding address bit to a logic one 6.3.2.8.4 Address: 0x002B 7 Debug Comparator Address Low Register (DBGXAL) 6 5 4 3 2 1 0 R W Reset Bit 7 0 Bit 6 0 Bit 5 0 Bit 4 0 Bit 3 0 Bit 2 0 Bit 1 0 Bit 0 0 Figure 6-17. Debug Comparator Address Low Register (DBGXAL) Read: Anytime. See Table 6-26 for visible register encoding. Write: If DBG not armed. See Table 6-26 for visible register encoding. Table 6-31. DBGXAL Field Descriptions Field 7–0 Bits[7:0] Description Comparator Address Low Compare Bits — The Comparator address low compare bits control whether the selected comparator will compare the address bus bits [7:0] to a logic one or logic zero. 0 Compare corresponding address bit to a logic zero 1 Compare corresponding address bit to a logic one S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 209 S12X Debug (S12XDBGV3) Module 6.3.2.8.5 Address: 0x002C 7 Debug Comparator Data High Register (DBGXDH) 6 5 4 3 2 1 0 R W Reset Bit 15 0 Bit 14 0 Bit 13 0 Bit 12 0 Bit 11 0 Bit 10 0 Bit 9 0 Bit 8 0 Figure 6-18. Debug Comparator Data High Register (DBGXDH) Read: Anytime. See Table 6-26 for visible register encoding. Write: If DBG not armed. See Table 6-26 for visible register encoding. Table 6-32. DBGXAH Field Descriptions Field 7–0 Bits[15:8] Description Comparator Data High Compare Bits — The Comparator data high compare bits control whether the selected comparator compares the data bus bits [15:8] to a logic one or logic zero. The comparator data compare bits are only used in comparison if the corresponding data mask bit is logic 1. This register is available only for comparators A and C. 0 Compare corresponding data bit to a logic zero 1 Compare corresponding data bit to a logic one 6.3.2.8.6 Address: 0x002D 7 Debug Comparator Data Low Register (DBGXDL) 6 5 4 3 2 1 0 R W Reset Bit 7 0 Bit 6 0 Bit 5 0 Bit 4 0 Bit 3 0 Bit 2 0 Bit 1 0 Bit 0 0 Figure 6-19. Debug Comparator Data Low Register (DBGXDL) Read: Anytime. See Table 6-26 for visible register encoding. Write: If DBG not armed. See Table 6-26 for visible register encoding. Table 6-33. DBGXDL Field Descriptions Field 7–0 Bits[7:0] Description Comparator Data Low Compare Bits — The Comparator data low compare bits control whether the selected comparator compares the data bus bits [7:0] to a logic one or logic zero. The comparator data compare bits are only used in comparison if the corresponding data mask bit is logic 1. This register is available only for comparators A and C. 0 Compare corresponding data bit to a logic zero 1 Compare corresponding data bit to a logic one S12XS Family Reference Manual, Rev. 1.09 210 Freescale Semiconductor S12X Debug (S12XDBGV3) Module 6.3.2.8.7 Address: 0x002E 7 Debug Comparator Data High Mask Register (DBGXDHM) 6 5 4 3 2 1 0 R W Reset Bit 15 0 Bit 14 0 Bit 13 0 Bit 12 0 Bit 11 0 Bit 10 0 Bit 9 0 Bit 8 0 Figure 6-20. Debug Comparator Data High Mask Register (DBGXDHM) Read: Anytime. See Table 6-26 for visible register encoding. Write: If DBG not armed. See Table 6-26 for visible register encoding. Table 6-34. DBGXDHM Field Descriptions Field 7–0 Bits[15:8] Description Comparator Data High Mask Bits — The Comparator data high mask bits control whether the selected comparator compares the data bus bits [15:8] to the corresponding comparator data compare bits. This register is available only for comparators A and C. 0 Do not compare corresponding data bit 1 Compare corresponding data bit 6.3.2.8.8 Address: 0x002F 7 Debug Comparator Data Low Mask Register (DBGXDLM) 6 5 4 3 2 1 0 R W Reset Bit 7 0 Bit 6 0 Bit 5 0 Bit 4 0 Bit 3 0 Bit 2 0 Bit 1 0 Bit 0 0 Figure 6-21. Debug Comparator Data Low Mask Register (DBGXDLM) Read: Anytime. See Table 6-26 for visible register encoding. Write: If DBG not armed. See Table 6-26 for visible register encoding. Table 6-35. DBGXDLM Field Descriptions Field 7–0 Bits[7:0] Description Comparator Data Low Mask Bits — The Comparator data low mask bits control whether the selected comparator compares the data bus bits [7:0] to the corresponding comparator data compare bits. This register is available only for comparators A and C. 0 Do not compare corresponding data bit 1 Compare corresponding data bit 6.4 Functional Description This section provides a complete functional description of the S12XDBG module. If the part is in secure mode, the S12XDBG module can generate breakpoints but tracing is not possible. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 211 S12X Debug (S12XDBGV3) Module 6.4.1 S12XDBG Operation Arming the S12XDBG module by setting ARM in DBGC1 allows triggering, and storing of data in the trace buffer and can be used to cause breakpoints to the CPU12X . The DBG module is made up of four main blocks, the comparators, control logic, the state sequencer, and the trace buffer. The comparators monitor the bus activity of the CPU12X . Comparators can be configured to monitor address and databus. Comparators can also be configured to mask out individual data bus bits during a compare and to use R/W and word/byte access qualification in the comparison. When a match with a comparator register value occurs the associated control logic can trigger the state sequencer to another state (see Figure 6-22). Either forced or tagged triggers are possible. Using a forced trigger, the trigger is generated immediately on a comparator match. Using a tagged trigger, at a comparator match, the instruction opcode is tagged and only if the instruction reaches the execution stage of the instruction queue is a trigger generated. In the case of a transition to Final State, bus tracing is triggered and/or a breakpoint can be generated. Independent of the state sequencer, a breakpoint can be triggered by writing to the TRIG bit in the DBGC1 control register. The trace buffer is visible through a 2-byte window in the register address map and can be read out using standard 16-bit word reads. 6.4.2 Comparator Modes The S12XDBG contains four comparators, A, B, C, and D. Each comparator compares the selected address bus with the address stored in DBGXAH, DBGXAM, and DBGXAL. Furthermore, comparators A and C also compare the data buses to the data stored in DBGXDH, DBGXDL and allow masking of individual data bus bits. S12X comparator matches are disabled in BDM and during BDM accesses. The comparator match control logic configures comparators to monitor the buses for an exact address or an address range. The comparator configuration is controlled by the control register contents and the range control by the DBGC2 contents. On a match a trigger can initiate a transition to another state sequencer state (see Section 6.4.3”). The comparator control register also allows the type of access to be included in the comparison through the use of the RWE, RW, SZE, and SZ bits. The RWE bit controls whether read or write comparison is enabled for the associated comparator and the RW bit selects either a read or write access for a valid match. Similarly the SZE and SZ bits allows the size of access (word or byte) to be considered in the compare. Only comparators B and D feature SZE and SZ. The TAG bit in each comparator control register is used to determine the triggering condition. By setting TAG, the comparator will qualify a match with the output of opcode tracking logic and a trigger occurs before the tagged instruction executes (tagged-type trigger). Whilst tagging, the RW, RWE, SZE, and SZ bits are ignored and the comparator register must be loaded with the exact opcode address. If the TAG bit is clear (forced type trigger) a comparator match is generated when the selected address appears on the system address bus. If the selected address is an opcode address, the match is generated S12XS Family Reference Manual, Rev. 1.09 212 Freescale Semiconductor S12X Debug (S12XDBGV3) Module when the opcode is fetched from the memory. This precedes the instruction execution by an indefinite number of cycles due to instruction pipe lining. For a comparator match of an opcode at an odd address when TAG = 0, the corresponding even address must be contained in the comparator register. Thus for an opcode at odd address (n), the comparator register must contain address (n–1). Once a successful comparator match has occurred, the condition that caused the original match is not verified again on subsequent matches. Thus if a particular data value is verified at a given address, this address may not still contain that data value when a subsequent match occurs. Comparators C and D can also be used to select an address range to trace from. This is determined by the TRANGE bits in the DBGTCR register. The TRANGE encoding is shown in Table 6-9. If the TRANGE bits select a range definition using comparator D, then comparator D is configured for trace range definition and cannot be used for address bus comparisons. Similarly if the TRANGE bits select a range definition using comparator C, then comparator C is configured for trace range definition and cannot be used for address bus comparisons. Match[0, 1, 2, 3] map directly to Comparators[A, B, C, D] respectively, except in range modes (see Section 6.3.2.4”). Comparator priority rules are described in the trigger priority section (Section 6.4.3.4”). 6.4.2.1 Exact Address Comparator Match (Comparators A and C) With range comparisons disabled, the match condition is an exact equivalence of address/data bus with the value stored in the comparator address/data registers. Further qualification of the type of access (R/W, word/byte) is possible. Comparators A and C do not feature SZE or SZ control bits, thus the access size is not compared. Table 637 lists access considerations without data bus compare. Table 6-36 lists access considerations with data bus comparison. To compare byte accesses DBGxDH must be loaded with the data byte, the low byte must be masked out using the DBGxDLM mask register. On word accesses the data byte of the lower address is mapped to DBGxDH. Table 6-36. Comparator A and C Data Bus Considerations Access Word Byte Word Word Address ADDR[n] ADDR[n] ADDR[n] ADDR[n] DBGxDH Data[n] Data[n] Data[n] x DBGxDL Data[n+1] x x Data[n+1] DBGxDHM $FF $FF $FF $00 DBGxDLM $FF $00 $00 $FF Example Valid Match MOVW #$WORD ADDR[n] MOVB #$BYTE ADDR[n] MOVW #$WORD ADDR[n] MOVW #$WORD ADDR[n] config1 config2 config2 config3 Code may contain various access forms of the same address, i.e. a word access of ADDR[n] or byte access of ADDR[n+1] both access n+1. At a word access of ADDR[n], address ADDR[n+1] does not appear on the address bus and so cannot cause a comparator match if the comparator contains ADDR[n]. Thus it is not possible to monitor all data accesses of ADDR[n+1] with one comparator. To detect an access of ADDR[n+1] through a word access of ADDR[n] the comparator can be configured to ADDR[n], DBGxDL is loaded with the data pattern and DBGxDHM is cleared so only the data[n+1] is compared on accesses of ADDR[n]. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 213 S12X Debug (S12XDBGV3) Module NOTE Using this configuration, a byte access of ADDR[n] can cause a comparator match if the databus low byte by chance contains the same value as ADDR[n+1] because the databus comparator does not feature access size comparison and uses the mask as a “don’t care” function. Thus masked bits do not prevent a match. Comparators A and C feature an NDB control bit to determine if a match occurs when the data bus differs to comparator register contents or when the data bus is equivalent to the comparator register contents. 6.4.2.2 Exact Address Comparator Match (Comparators B and D) Comparators B and D feature SZ and SZE control bits. If SZE is clear, then the comparator address match qualification functions the same as for comparators A and C. If the SZE bit is set the access size (word or byte) is compared with the SZ bit value such that only the specified type of access causes a match. Thus if configured for a byte access of a particular address, a word access covering the same address does not lead to match. Table 6-37. Comparator Access Size Considerations Comparator Comparators A and C Comparators B and D Comparators B and D Address ADDR[n] SZE — SZ8 — Condition For Valid Match Word and byte accesses of ADDR[n]1 MOVB #$BYTE ADDR[n] MOVW #$WORD ADDR[n] Word and byte accesses of ADDR[n]1 MOVB #$BYTE ADDR[n] MOVW #$WORD ADDR[n] Word accesses of ADDR[n]1 MOVW #$WORD ADDR[n] ADDR[n] 0 X ADDR[n] 1 0 Comparators ADDR[n] 1 1 Byte accesses of ADDR[n] B and D MOVB #$BYTE ADDR[n] A word access of ADDR[n-1] also accesses ADDR[n] but does not generate a match. 1 The comparator address register must contain the exact address used in the code. 6.4.2.3 Data Bus Comparison NDB Dependency Comparators A and C each feature an NDB control bit, which allows data bus comparators to be configured to either trigger on equivalence or trigger on difference. This allows monitoring of a difference in the contents of an address location from an expected value. When matching on an equivalence (NDB=0), each individual data bus bit position can be masked out by clearing the corresponding mask bit (DBGxDHM/DBGxDLM), so that it is ignored in the comparison. A match occurs when all data bus bits with corresponding mask bits set are equivalent. If all mask register bits are clear, then a match is based on the address bus only, the data bus is ignored. When matching on a difference, mask bits can be cleared to ignore bit positions. A match occurs when any data bus bit with corresponding mask bit set is different. Clearing all mask bits, causes all bits to be ignored and prevents a match because no difference can be detected. In this case address bus equivalence does not cause a match. S12XS Family Reference Manual, Rev. 1.09 214 Freescale Semiconductor S12X Debug (S12XDBGV3) Module Table 6-38. NDB and MASK bit dependency NDB 0 0 1 1 DBGxDHM[n] / DBGxDLM[n] 0 1 0 1 Comment Do not compare data bus bit. Compare data bus bit. Match on equivalence. Do not compare data bus bit. Compare data bus bit. Match on difference. 6.4.2.4 Range Comparisons When using the AB comparator pair for a range comparison, the data bus can also be used for qualification by using the comparator A data and data mask registers. Furthermore the DBGACTL RW and RWE bits can be used to qualify the range comparison on either a read or a write access. The corresponding DBGBCTL bits are ignored. Similarly when using the CD comparator pair for a range comparison, the data bus can also be used for qualification by using the comparator C data and data mask registers. Furthermore the DBGCCTL RW and RWE bits can be used to qualify the range comparison on either a read or a write access if tagging is not selected. The corresponding DBGDCTL bits are ignored. The SZE and SZ control bits are ignored in range mode. The comparator A and C TAG bits are used to tag range comparisons for the AB and CD ranges respectively. The comparator B and D TAG bits are ignored in range modes. In order for a range comparison using comparators A and B, both COMPEA and COMPEB must be set; to disable range comparisons both must be cleared. Similarly for a range CD comparison, both COMPEC and COMPED must be set. The comparator A and C BRK bits are used for the AB and CD ranges respectively, the comparator B and D BRK bits are ignored in range mode. When configured for range comparisons and tagging, the ranges are accurate only to word boundaries. 6.4.2.4.1 Inside Range (CompAC_Addr ≤ address ≤ CompBD_Addr) In the Inside Range comparator mode, either comparator pair A and B or comparator pair C and D can be configured for range comparisons by the control register (DBGC2). The match condition requires that a valid match for both comparators happens on the same bus cycle. A match condition on only one comparator is not valid. An aligned word access which straddles the range boundary will cause a trigger only if the aligned address is inside the range. 6.4.2.4.2 Outside Range (address < CompAC_Addr or address > CompBD_Addr) In the Outside Range comparator mode, either comparator pair A and B or comparator pair C and D can be configured for range comparisons. A single match condition on either of the comparators is recognized as valid. An aligned word access which straddles the range boundary will cause a trigger only if the aligned address is outside the range. Outside range mode in combination with tagged triggers can be used to detect if the opcode fetches are from an unexpected range. In forced trigger modes the outside range trigger would typically be activated at any interrupt vector fetch or register access. This can be avoided by setting the upper or lower range limit to $7FFFFF or $000000 respectively. Interrupt vector fetches do not cause taghits S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 215 S12X Debug (S12XDBGV3) Module 6.4.3 Trigger Modes Trigger modes are used as qualifiers for a state sequencer change of state. The control logic determines the trigger mode and provides a trigger to the state sequencer. The individual trigger modes are described in the following sections. 6.4.3.1 Forced Trigger On Comparator Match If a forced trigger comparator match occurs, the trigger immediately initiates a transition to the next state sequencer state whereby the corresponding flags in DBGSR are set. The state control register for the current state determines the next state for each trigger. Forced triggers are generated as soon as the matching address appears on the address bus, which in the case of opcode fetches occurs several cycles before the opcode execution. For this reason a forced trigger at an opcode address precedes a tagged trigger at the same address by several cycles. 6.4.3.2 Trigger On Comparator Related Taghit If a CPU12X taghit occurs, a transition to another state sequencer state is initiated and the corresponding DBGSR flags are set. For a comparator related taghit to occur, the S12XDBG must first generate tags based on comparator matches. When the tagged instruction reaches the execution stage of the instruction queue a taghit is generated by the CPU12X. The state control register for the current state determines the next state for each trigger. 6.4.3.3 TRIG Immediate Trigger Independent of comparator matches it is possible to initiate a tracing session and/or breakpoint by writing the TRIG bit in DBGC1 to a logic “1”. If configured for begin or mid aligned tracing, this triggers the state sequencer into the Final State, if configured for end alignment, setting the TRIG bit disarms the module, ending the session. If breakpoints are enabled, a forced breakpoint request is issued immediately (end alignment) or when tracing has completed (begin or mid alignment). 6.4.3.4 Trigger Priorities In case of simultaneous triggers, the priority is resolved according to Table 6-39. The lower priority trigger is suppressed. It is thus possible to miss a lower priority trigger if it occurs simultaneously with a trigger of a higher priority. The trigger priorities described in Table 6-39 dictate that in the case of simultaneous matches, the match on the lower channel number (0,1,2,3) has priority. The SC[3:0] encoding ensures that a match leading to final state has priority over all other matches in each state sequencer state. When configured for range modes a simultaneous match of comparators A and C generates an active match0 whilst match2 is suppressed. If a write access to DBGC1 with the ARM bit position set occurs simultaneously to a hardware disarm from an internal trigger event, then the ARM bit is cleared due to the hardware disarm. Table 6-39. Trigger Priorities Priority Source Action S12XS Family Reference Manual, Rev. 1.09 216 Freescale Semiconductor S12X Debug (S12XDBGV3) Module Table 6-39. Trigger Priorities Highest TRIG Match0 (force or tag hit) Match1 (force or tag hit) Match2 (force or tag hit) Lowest Match3 (force or tag hit) Trigger immediately to final state (begin or mid aligned tracing enabled) Trigger immediately to state 0 (end aligned or no tracing enabled) Trigger to next state as defined by state control registers Trigger to next state as defined by state control registers Trigger to next state as defined by state control registers Trigger to next state as defined by state control registers 6.4.4 State Sequence Control ARM = 0 State 0 (Disarmed) ARM = 1 State1 ARM = 0 Session Complete (Disarm) Final State ARM = 0 State3 State2 Figure 6-22. State Sequencer Diagram The state sequencer allows a defined sequence of events to provide a trigger point for tracing of data in the trace buffer. Once the S12XDBG module has been armed by setting the ARM bit in the DBGC1 register, then state1 of the state sequencer is entered. Further transitions between the states are then controlled by the state control registers and depend upon a selected trigger mode condition being met. From Final State the only permitted transition is back to the disarmed state0. Transition between any of the states 1 to 3 is not restricted. Each transition updates the SSF[2:0] flags in DBGSR accordingly to indicate the current state. Alternatively by setting the TRIG bit in DBGSC1, the state machine can be triggered to state0 or Final State depending on tracing alignment. Independent of the state sequencer, each comparator channel can be individually configured to generate an immediate breakpoint when a match occurs through the use of the BRK bits in the DBGxCTL registers. Thus it is possible to generate an immediate breakpoint on selected channels, whilst a state sequencer transition can be initiated by a match on other channels. If a debug session is ended by a trigger on a channel with BRK = 1, the state sequencer transitions through Final State for a clock cycle to state0. This is independent of tracing and breakpoint activity, thus with tracing and breakpoints disabled, the state sequencer enters state0 and the debug module is disarmed. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 217 S12X Debug (S12XDBGV3) Module 6.4.4.1 Final State On entering Final State a trigger may be issued to the trace buffer according to the trace position control as defined by the TALIGN field (see Section 6.3.2.3”). If TSOURCE in the trace control register DBGTCR is cleared then the trace buffer is disabled and the transition to Final State can only generate a breakpoint request. In this case or upon completion of a tracing session when tracing is enabled, the ARM bit in the DBGC1 register is cleared, returning the module to the disarmed state0. If tracing is enabled, a breakpoint request can occur at the end of the tracing session. If neither tracing nor breakpoints are enabled then when the final state is reached it returns automatically to state0 and the debug module is disarmed. 6.4.5 Trace Buffer Operation The trace buffer is a 64 lines deep by 64-bits wide RAM array. The S12XDBG module stores trace information in the RAM array in a circular buffer format. The RAM array can be accessed through a register window (DBGTBH:DBGTBL) using 16-bit wide word accesses. After each complete 64-bit trace buffer line is read, an internal pointer into the RAM is incremented so that the next read will receive fresh information. Data is stored in the format shown in Table 6-40. After each store the counter register bits DBGCNT[6:0] are incremented. Tracing of CPU12X activity is disabled when the BDM is active. Reading the trace buffer whilst the DBG is armed returns invalid data and the trace buffer pointer is not incremented. 6.4.5.1 Trace Trigger Alignment Using the TALIGN bits (see Section 6.3.2.3”) it is possible to align the trigger with the end, the middle, or the beginning of a tracing session. If End or Mid tracing is selected, tracing begins when the ARM bit in DBGC1 is set and State1 is entered. The transition to Final State if End is selected signals the end of the tracing session. The transition to Final State if Mid is selected signals that another 32 lines will be traced before ending the tracing session. Tracing with Begin-Trigger starts at the opcode of the trigger. 6.4.5.1.1 Storing with Begin-Trigger Storing with Begin-Trigger, data is not stored in the Trace Buffer until the Final State is entered. Once the trigger condition is met the S12XDBG module will remain armed until 64 lines are stored in the Trace Buffer. If the trigger is at the address of the change-of-flow instruction the change of flow associated with the trigger will be stored in the Trace Buffer. Using Begin-trigger together with tagging, if the tagged instruction is about to be executed then the trace is started. Upon completion of the tracing session the breakpoint is generated, thus the breakpoint does not occur at the tagged instruction boundary. 6.4.5.1.2 Storing with Mid-Trigger Storing with Mid-Trigger, data is stored in the Trace Buffer as soon as the S12XDBG module is armed. When the trigger condition is met, another 32 lines will be traced before ending the tracing session, irrespective of the number of lines stored before the trigger occurred, then the S12XDBG module is disarmed and no more data is stored. Using Mid-trigger with tagging, if the tagged instruction is about to S12XS Family Reference Manual, Rev. 1.09 218 Freescale Semiconductor S12X Debug (S12XDBGV3) Module be executed then the trace is continued for another 32 lines. Upon tracing completion the breakpoint is generated, thus the breakpoint does not occur at the tagged instruction boundary. 6.4.5.1.3 Storing with End-Trigger Storing with End-Trigger, data is stored in the Trace Buffer until the Final State is entered, at which point the S12XDBG module will become disarmed and no more data will be stored. If the trigger is at the address of a change of flow instruction the trigger event will not be stored in the Trace Buffer. 6.4.5.2 Trace Modes The S12XDBG module can operate in four trace modes. The mode is selected using the TRCMOD bits in the DBGTCR register. The modes are described in the following subsections. The trace buffer organization is shown in Table 6-40. 6.4.5.2.1 Normal Mode In Normal Mode, change of flow (COF) program counter (PC) addresses will be stored. COF addresses are defined as follows : • Source address of taken conditional branches (long, short, bit-conditional, and loop primitives) • Destination address of indexed JMP, JSR, and CALL instruction • Destination address of RTI, RTS, and RTC instructions. • Vector address of interrupts, except for SWI and BDM vectors LBRA, BRA, BSR, BGND as well as non-indexed JMP, JSR, and CALL instructions are not classified as change of flow and are not stored in the trace buffer. Change-of-flow addresses stored include the full 23-bit address bus of CPU12X and an information byte, which contains a source/destination bit to indicate whether the stored address was a source address or destination address. NOTE When an CPU12X COF instruction with destination address is executed, the destination address is stored to the trace buffer on instruction completion, indicating the COF has taken place. If an interrupt occurs simultaneously then the next instruction carried out is actually from the interrupt service routine. The instruction at the destination address of the original program flow gets exectuted after the interrupt service routine. In the following example an IRQ interrupt occurs during execution of the indexed JMP at address MARK1. The BRN at the destination (SUB_1) is not executed until after the IRQ service routine but the destination address is entered into the trace buffer to indicate that the indexed JMP COF has taken place. MARK1 MARK2 LDX JMP NOP #SUB_1 0,X ; IRQ interrupt occurs during execution of this ; S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 219 S12X Debug (S12XDBGV3) Module SUB_1 BRN NOP DBNE LDAB STAB RTI * ADDR1 IRQ_ISR A,PART5 #$F0 VAR_C1 ; JMP Destination address TRACE BUFFER ENTRY 1 ; RTI Destination address TRACE BUFFER ENTRY 3 ; ; Source address TRACE BUFFER ENTRY 4 ; IRQ Vector $FFF2 = TRACE BUFFER ENTRY 2 ; The execution flow taking into account the IRQ is as follows MARK1 IRQ_ISR LDX JMP LDAB STAB RTI BRN NOP DBNE #SUB_1 0,X #$F0 VAR_C1 * A,PART5 ; ; ; ; ; SUB_1 ADDR1 6.4.5.2.2 Loop1 Mode Loop1 Mode, similarly to Normal Mode also stores only COF address information to the trace buffer, it however allows the filtering out of redundant information. The intent of Loop1 Mode is to prevent the Trace Buffer from being filled entirely with duplicate information from a looping construct such as delays using the DBNE instruction or polling loops using BRSET/BRCLR instructions. Immediately after address information is placed in the Trace Buffer, the S12XDBG module writes this value into a background register. This prevents consecutive duplicate address entries in the Trace Buffer resulting from repeated branches. Loop1 Mode only inhibits consecutive duplicate source address entries that would typically be stored in most tight looping constructs. It does not inhibit repeated entries of destination addresses or vector addresses, since repeated entries of these would most likely indicate a bug in the user’s code that the S12XDBG module is designed to help find. 6.4.5.2.3 Detail Mode In Detail Mode, address and data for all memory and register accesses is stored in the trace buffer. This mode also features information byte entries to the trace buffer, for each address byte entry. The information byte indicates the size of access (word or byte) and the type of access (read or write). When tracing CPU12X activity in Detail Mode, all cycles are traced except those when the CPU12X is either in a free or opcode fetch cycle, the address range can be limited to a range specified by the TRANGE bits in DBGTCR. This function uses comparators C and D to define an address range inside which CPU12X activity should be traced (see Table 6-40). Thus the traced CPU12X activity can be restricted to particular register range accesses. 6.4.5.2.4 Pure PC Mode In Pure PC Mode, tracing from the CPU the PC addresses of all executed opcodes, including illegal opcodes, are stored. S12XS Family Reference Manual, Rev. 1.09 220 Freescale Semiconductor S12X Debug (S12XDBGV3) Module 6.4.5.3 Trace Buffer Organization Referring to Table 6-40. ADRH, ADRM, ADRL denote address high, middle and low byte respectively. INF bytes contain control information (R/W, S/D etc.). The numerical suffix indicates which tracing step. The information format for Loop1 Mode and PurePC Mode is the same as that of Normal Mode. Whilst tracing in Normal or Loop1 modes each array line contains 2 data entries, thus in this case the DBGCNT[0] is incremented after each separate entry. In Detail mode DBGCNT[0] remains cleared whilst the other DBGCNT bits are incremented on each trace buffer entry. When a COF occurs a trace buffer entry is made and the corresponding CDV bit is set. Single byte data accesses in Detail Mode are always stored to the low byte of the trace buffer (CDATAL ) and the high byte is cleared. When tracing word accesses, the byte at the lower address is always stored to trace buffer byte3 and the byte at the higher address is stored to byte2 Table 6-40. Trace Buffer Organization Mode 8-Byte Wide Word Buffer 7 CXINF1 CXINF2 CINF1 CINF3 6 CADRH1 CADRH2 CPCH1 CPCH3 5 CADRM1 CADRM2 CPCM1 CPCM3 4 CADRL1 CADRL2 CPCL1 CPCL3 3 CDATAH1 CDATAH2 CINF0 CINF2 2 CDATAL1 CDATAL2 CPCH0 CPCH2 CPCM0 CPCM2 CPCL0 CPCL2 1 0 S12XCPU Detail CPU12X Other Modes S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 221 S12X Debug (S12XDBGV3) Module 6.4.5.3.1 Information Byte Organization The format of the control information byte is dependent upon the active trace mode as described below. In Normal, Loop1, or Pure PC modes tracing of CPU12X activity, CINF is used to store control information. In Detail Mode, CXINF contains the control information CPU12X Information Byte Bit 7 CSD Bit 6 CVA Bit 5 0 Bit 4 CDV Bit 3 0 Bit 2 0 Bit 1 0 Bit 0 0 Figure 6-23. CPU12X Information Byte CINF Table 6-41. CINF Field Descriptions Field 7 CSD Description Source Destination Indicator — This bit indicates if the corresponding stored address is a source or destination address. This is only used in Normal and Loop1 mode tracing. 0 Source address 1 Destination address Vector Indicator — This bit indicates if the corresponding stored address is a vector address.. Vector addresses are destination addresses, thus if CVA is set, then the corresponding CSD is also set. This is only used in Normal and Loop1 mode tracing. This bit has no meaning in Pure PC mode. 0 Indexed jump destination address 1 Vector destination address Data Invalid Indicator — This bit indicates if the trace buffer entry is invalid. It is only used when tracing from both sources in Normal, Loop1 and Pure PC modes, to indicate that the CPU12X trace buffer entry is valid. 0 Trace buffer entry is invalid 1 Trace buffer entry is valid 6 CVA 4 CDV CXINF Information Byte Bit 7 Bit 6 CSZ Bit 5 CRW Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Figure 6-24. Information Byte CXINF This describes the format of the information byte used only when tracing in Detail Mode. When tracing from the CPU12X in Detail Mode, information is stored to the trace buffer on all cycles except opcode fetch and free cycles. In this case the CSZ and CRW bits indicate the type of access being made by the CPU12X. Table 6-42. CXINF Field Descriptions Field 6 CSZ Description Access Type Indicator — This bit indicates if the access was a byte or word size access.This bit only contains valid information when tracing CPU12X activity in Detail Mode. 0 Word Access 1 Byte Access S12XS Family Reference Manual, Rev. 1.09 222 Freescale Semiconductor S12X Debug (S12XDBGV3) Module Table 6-42. CXINF Field Descriptions (continued) Field 5 CRW Description Read Write Indicator — This bit indicates if the corresponding stored address corresponds to a read or write access. This bit only contains valid information when tracing CPU12X activity in Detail Mode. 0 Write Access 1 Read Access 6.4.5.4 Reading Data from Trace Buffer The data stored in the Trace Buffer can be read using either the background debug module (BDM) module or the CPU12X provided the S12XDBG module is not armed, is configured for tracing and the system not secured. When the ARM bit is written to 1 the trace buffer is locked to prevent reading. The trace buffer can only be unlocked for reading by an aligned word write to DBGTB when the module is disarmed. The Trace Buffer can only be read through the DBGTB register using aligned word reads, any byte or misaligned reads return 0 and do not cause the trace buffer pointer to increment to the next trace buffer address. The Trace Buffer data is read out first-in first-out. By reading CNT in DBGCNT the number of valid 64-bit lines can be determined. DBGCNT will not decrement as data is read. Whilst reading an internal pointer is used to determine the next line to be read. After a tracing session, the pointer points to the oldest data entry, thus if no overflow has occurred, the pointer points to line0, otherwise it points to the line with the oldest entry. The pointer is initialized by each aligned write to DBGTBH to point to the oldest data again. This enables an interrupted trace buffer read sequence to be easily restarted from the oldest data entry. The least significant word of each 64-bit wide array line is read out first. This corresponds to the bytes 1 and 0 of Table 6-40. The bytes containing invalid information (shaded in Table 6-40) are also read out. Reading the Trace Buffer while the S12XDBG module is armed will return invalid data and no shifting of the RAM pointer will occur. 6.4.5.5 Trace Buffer Reset State The Trace Buffer contents are not initialized by a system reset. Thus should a system reset occur, the trace session information from immediately before the reset occurred can be read out. The DBGCNT bits are not cleared by a system reset. Thus should a reset occur, the number of valid lines in the trace buffer is indicated by DBGCNT. The internal pointer to the current trace buffer address is initialized by unlocking the trace buffer thus points to the oldest valid data even if a reset occurred during the tracing session. Generally debugging occurrences of system resets is best handled using mid or end trigger alignment since the reset may occur before the trace trigger, which in the begin trigger alignment case means no information would be stored in the trace buffer. NOTE An external pin RESET that occurs simultaneous to a trace buffer entry can, in very seldom cases, lead to either that entry being corrupted or the first entry of the session being corrupted. In such cases the other contents of the trace buffer still contain valid tracing information. The case occurs when the reset assertion coincides with the trace buffer entry clock edge. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 223 S12X Debug (S12XDBGV3) Module 6.4.6 Tagging A tag follows program information as it advances through the instruction queue. When a tagged instruction reaches the head of the queue a tag hit occurs and triggers the state sequencer. Each comparator control register features a TAG bit, which controls whether the comparator match will cause a trigger immediately or tag the opcode at the matched address. If a comparator is enabled for tagged comparisons, the address stored in the comparator match address registers must be an opcode address for the trigger to occur. Using Begin trigger together with tagging, if the tagged instruction is about to be executed then the transition to the next state sequencer state occurs. If the transition is to the Final State, tracing is started. Only upon completion of the tracing session can a breakpoint be generated. Similarly using Mid trigger with tagging, if the tagged instruction is about to be executed then the trace is continued for another 32 lines. Upon tracing completion the breakpoint is generated. Using End trigger, when the tagged instruction is about to be executed and the next transition is to Final State then a breakpoint is generated immediately, before the tagged instruction is carried out. Read/Write (R/W), access size (SZ) monitoring and data bus monitoring is not useful if tagged triggering is selected, since the tag is attached to the opcode at the matched address and is not dependent on the data bus nor on the type of access. Thus these bits are ignored if tagged triggering is selected. When configured for range comparisons and tagging, the ranges are accurate only to word boundaries. S12X tagging is disabled when the BDM becomes active. 6.4.7 Breakpoints Breakpoints can be generated as follows. • From comparator channel triggers to final state. • Using software to write to the TRIG bit in the DBGC1 register. Breakpoints generated via the BDM BACKGROUND command have no affect on the CPU12X in STOP or WAIT mode. 6.4.7.1 Breakpoints From Internal Comparator Channel Final State Triggers Breakpoints can be generated when internal comparator channels trigger the state sequencer to the Final State. If configured for tagging, then the breakpoint is generated when the tagged opcode reaches the execution stage of the instruction queue. If a tracing session is selected by TSOURCE, breakpoints are requested when the tracing session has completed, thus if Begin or Mid aligned triggering is selected, the breakpoint is requested only on completion of the subsequent trace (see Table 6-43). If no tracing session is selected, breakpoints are requested immediately. If the BRK bit is set on the triggering channel, then the breakpoint is generated immediately independent of tracing trigger alignment. S12XS Family Reference Manual, Rev. 1.09 224 Freescale Semiconductor S12X Debug (S12XDBGV3) Module Table 6-43. Breakpoint Setup BRK 0 0 0 0 0 0 1 1 x TALIGN 00 00 01 01 10 10 00,01,10 00,01,10 11 DBGBRK 0 1 0 1 0 1 1 0 x Breakpoint Alignment Fill Trace Buffer until trigger (no breakpoints — keep running) Fill Trace Buffer until trigger, then breakpoint request occurs Start Trace Buffer at trigger (no breakpoints — keep running) Start Trace Buffer at trigger A breakpoint request occurs when Trace Buffer is full Store a further 32 Trace Buffer line entries after trigger (no breakpoints — keep running) Store a further 32 Trace Buffer line entries after trigger Request breakpoint after the 32 further Trace Buffer entries Terminate tracing and generate breakpoint immediately on trigger Terminate tracing immediately on trigger Reserved 6.4.7.2 Breakpoints Generated Via The TRIG Bit If a TRIG triggers occur, the Final State is entered. If a tracing session is selected by TSOURCE, breakpoints are requested when the tracing session has completed, thus if Begin or Mid aligned triggering is selected, the breakpoint is requested only on completion of the subsequent trace (see Table 6-43). If no tracing session is selected, breakpoints are requested immediately. TRIG breakpoints are possible even if the S12XDBG module is disarmed. 6.4.7.3 S12XDBG Breakpoint Priorities If a TRIG trigger occurs after Begin or Mid aligned tracing has already been triggered by a comparator instigated transition to Final State, then TRIG no longer has an effect. When the associated tracing session is complete, the breakpoint occurs. Similarly if a TRIG is followed by a subsequent trigger from a comparator channel, it has no effect, since tracing has already started. 6.4.7.3.1 S12XDBG Breakpoint Priorities And BDM Interfacing Breakpoint operation is dependent on the state of the S12XBDM module. If the S12XBDM module is active, the CPU12X is executing out of BDM firmware and S12X breakpoints are disabled. In addition, while executing a BDM TRACE command, tagging into BDM is disabled. If BDM is not active, the breakpoint will give priority to BDM requests over SWI requests if the breakpoint coincides with a SWI instruction in the user’s code. On returning from BDM, the SWI from user code gets executed. Table 6-44. Breakpoint Mapping Summary DBGBRK (DBGC1[3]) 0 1 1 BDM Bit (DBGC1[4]) X 0 0 BDM Enabled X X X BDM Active X 0 1 S12X Breakpoint Mapping No Breakpoint Breakpoint to SWI No Breakpoint S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 225 S12X Debug (S12XDBGV3) Module Table 6-44. Breakpoint Mapping Summary 1 1 1 1 1 1 0 1 1 X 0 1 Breakpoint to SWI Breakpoint to BDM No Breakpoint BDM cannot be entered from a breakpoint unless the ENABLE bit is set in the BDM. If entry to BDM via a BGND instruction is attempted and the ENABLE bit in the BDM is cleared, the CPU12X actually executes the BDM firmware code. It checks the ENABLE and returns if ENABLE is not set. If not serviced by the monitor then the breakpoint is re-asserted when the BDM returns to normal CPU12X flow. If the comparator register contents coincide with the SWI/BDM vector address then an SWI in user code and DBG breakpoint could occur simultaneously. The CPU12X ensures that BDM requests have a higher priority than SWI requests. Returning from the BDM/SWI service routine care must be taken to avoid re triggering a breakpoint. NOTE When program control returns from a tagged breakpoint using an RTI or BDM GO command without program counter modification it will return to the instruction whose tag generated the breakpoint. To avoid re triggering a breakpoint at the same location reconfigure the S12XDBG module in the SWI routine, if configured for an SWI breakpoint, or over the BDM interface by executing a TRACE command before the GO to increment the program flow past the tagged instruction. S12XS Family Reference Manual, Rev. 1.09 226 Freescale Semiconductor Chapter 7 Security (S12XS9SECV2) Table 7-1. Revision History Version Number 02.00 02.01 02.02 Revision Date 27 Aug 2004 21 Feb 2007 19 Apr 2007 Effective Date 08 Sep 2004 21 Feb 2007 19 Apr 2007 Author Description of Changes reviewed and updated for S12XD architecture added S12XE, S12XF and S12XS architectures corrected statement about Backdoor key access via BDM on XE, XF, XS 7.1 Introduction NOTE No security feature is absolutely secure. However, Freescale’s strategy is to make reading or copying the FLASH and/or EEPROM difficult for unauthorized users. This specification describes the function of the security mechanism in the S12XS chip family (9SEC). 7.1.1 Features The user must be reminded that part of the security must lie with the application code. An extreme example would be application code that dumps the contents of the internal memory. This would defeat the purpose of security. At the same time, the user may also wish to put a backdoor in the application program. An example of this is the user downloads a security key through the SCI, which allows access to a programming routine that updates parameters stored in another section of the Flash memory. The security features of the S12XS chip family (in secure mode) are: • Protect the content of non-volatile memories (Flash, EEPROM) • Execution of NVM commands is restricted • Disable access to internal memory via background debug module (BDM) Table 7-2 gives an overview over availability of security relevant features in unsecure and secure modes. Table 7-2. Feature Availability in Unsecure and Secure Modes on S12XS Unsecure Mode NS Flash Array Access ✔ SS ✔ NX ES EX ST NS ✔ SS ✔ Secure Mode NX ES EX ST S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 227 Security (S12XS9SECV2) Table 7-2. Feature Availability in Unsecure and Secure Modes on S12XS Unsecure Mode NS EEPROM Array Access NVM Commands BDM ✔ ✔1 ✔ SS ✔ ✔ ✔ NX ES EX ST NS ✔ ✔1 — SS ✔ ✔1 ✔2 Secure Mode NX ES EX ST DBG Module Trace ✔ ✔ — — Restricted NVM command set only. Please refer to the NVM wrapper block guides for detailed information. 1 2 BDM hardware commands restricted to peripheral registers only. 7.1.2 7.1.3 Modes of Operation Securing the Microcontroller Once the user has programmed the Flash and EEPROM, the chip can be secured by programming the security bits located in the options/security byte in the Flash memory array. These non-volatile bits will keep the device secured through reset and power-down. The options/security byte is located at address 0xFF0F (= global address 0x7F_FF0F) in the Flash memory array. This byte can be erased and programmed like any other Flash location. Two bits of this byte are used for security (SEC[1:0]). On devices which have a memory page window, the Flash options/security byte is also available at address 0xBF0F by selecting page 0x3F with the PPAGE register. The contents of this byte are copied into the Flash security register (FSEC) during a reset sequence. 7 6 5 4 3 2 1 0 0xFF0F KEYEN1 KEYEN0 NV5 NV4 NV3 NV2 SEC1 SEC0 Figure 7-1. Flash Options/Security Byte The meaning of the bits KEYEN[1:0] is shown in Table 7-3. Please refer to Section 7.1.5.1, “Unsecuring the MCU Using the Backdoor Key Access” for more information. Table 7-3. Backdoor Key Access Enable Bits KEYEN[1:0] 00 01 10 11 Backdoor Key Access Enabled 0 (disabled) 0 (disabled) 1 (enabled) 0 (disabled) The meaning of the security bits SEC[1:0] is shown in Table 7-4. For security reasons, the state of device security is controlled by two bits. To put the device in unsecured mode, these bits must be programmed to S12XS Family Reference Manual, Rev. 1.09 228 Freescale Semiconductor Security (S12XS9SECV2) SEC[1:0] = ‘10’. All other combinations put the device in a secured mode. The recommended value to put the device in secured state is the inverse of the unsecured state, i.e. SEC[1:0] = ‘01’. Table 7-4. Security Bits SEC[1:0] 00 01 10 11 Security State 1 (secured) 1 (secured) 0 (unsecured) 1 (secured) NOTE Please refer to the Flash block guide for actual security configuration (in section “Flash Module Security”). 7.1.4 Operation of the Secured Microcontroller By securing the device, unauthorized access to the EEPROM and Flash memory contents can be prevented. However, it must be understood that the security of the EEPROM and Flash memory contents also depends on the design of the application program. For example, if the application has the capability of downloading code through a serial port and then executing that code (e.g. an application containing bootloader code), then this capability could potentially be used to read the EEPROM and Flash memory contents even when the microcontroller is in the secure state. In this example, the security of the application could be enhanced by requiring a challenge/response authentication before any code can be downloaded. Secured operation has the following effects on the microcontroller: S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 229 Security (S12XS9SECV2) 7.1.4.1 • • • Normal Single Chip Mode (NS) Background debug module (BDM) operation is completely disabled. Execution of Flash and EEPROM commands is restricted. Please refer to the NVM block guide for details. Tracing code execution using the DBG module is disabled. 7.1.4.2 • • • • Special Single Chip Mode (SS) BDM firmware commands are disabled. BDM hardware commands are restricted to the register space. Execution of Flash and EEPROM commands is restricted. Please refer to the NVM block guide for details. Tracing code execution using the DBG module is disabled. Special single chip mode means BDM is active after reset. The availability of BDM firmware commands depends on the security state of the device. The BDM secure firmware first performs a blank check of both the Flash memory and the EEPROM. If the blank check succeeds, security will be temporarily turned off and the state of the security bits in the appropriate Flash memory location can be changed If the blank check fails, security will remain active, only the BDM hardware commands will be enabled, and the accessible memory space is restricted to the peripheral register area. This will allow the BDM to be used to erase the EEPROM and Flash memory without giving access to their contents. After erasing both Flash memory and EEPROM, another reset into special single chip mode will cause the blank check to succeed and the options/security byte can be programmed to “unsecured” state via BDM. While the BDM is executing the blank check, the BDM interface is completely blocked, which means that all BDM commands are temporarily blocked. S12XS Family Reference Manual, Rev. 1.09 230 Freescale Semiconductor Security (S12XS9SECV2) 7.1.5 Unsecuring the Microcontroller Unsecuring the microcontroller can be done by three different methods: 1. Backdoor key access 2. Reprogramming the security bits 3. Complete memory erase (special modes) 7.1.5.1 Unsecuring the MCU Using the Backdoor Key Access In normal modes (single chip and expanded), security can be temporarily disabled using the backdoor key access method. This method requires that: • The backdoor key at 0xFF00–0xFF07 (= global addresses 0x7F_FF00–0x7F_FF07) has been programmed to a valid value. • The KEYEN[1:0] bits within the Flash options/security byte select ‘enabled’. • In single chip mode, the application program programmed into the microcontroller must be designed to have the capability to write to the backdoor key locations. The backdoor key values themselves would not normally be stored within the application data, which means the application program would have to be designed to receive the backdoor key values from an external source (e.g. through a serial port). The backdoor key access method allows debugging of a secured microcontroller without having to erase the Flash. This is particularly useful for failure analysis. NOTE No word of the backdoor key is allowed to have the value 0x0000 or 0xFFFF. 7.1.6 Reprogramming the Security Bits In normal single chip mode (NS), security can also be disabled by erasing and reprogramming the security bits within Flash options/security byte to the unsecured value. Because the erase operation will erase the entire sector from 0xFE00–0xFFFF (0x7F_FE00–0x7F_FFFF), the backdoor key and the interrupt vectors will also be erased; this method is not recommended for normal single chip mode. The application software can only erase and program the Flash options/security byte if the Flash sector containing the Flash options/security byte is not protected (see Flash protection). Thus Flash protection is a useful means of preventing this method. The microcontroller will enter the unsecured state after the next reset following the programming of the security bits to the unsecured value. This method requires that: • The application software previously programmed into the microcontroller has been designed to have the capability to erase and program the Flash options/security byte, or security is first disabled using the backdoor key method, allowing BDM to be used to issue commands to erase and program the Flash options/security byte. • The Flash sector containing the Flash options/security byte is not protected. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 231 Security (S12XS9SECV2) 7.1.7 Complete Memory Erase (Special Modes) The microcontroller can be unsecured in special modes by erasing the entire EEPROM and Flash memory contents. When a secure microcontroller is reset into special single chip mode (SS), the BDM firmware verifies whether the EEPROM and Flash memory are erased. If any EEPROM or Flash memory address is not erased, only BDM hardware commands are enabled. BDM hardware commands can then be used to write to the EEPROM and Flash registers to mass erase the EEPROM and all Flash memory blocks. When next reset into special single chip mode, the BDM firmware will again verify whether all EEPROM and Flash memory are erased, and this being the case, will enable all BDM commands, allowing the Flash options/security byte to be programmed to the unsecured value. The security bits SEC[1:0] in the Flash security register will indicate the unsecure state following the next reset. S12XS Family Reference Manual, Rev. 1.09 232 Freescale Semiconductor Chapter 8 S12XE Clocks and Reset Generator (S12XECRGV1) Table 8-1. Revision History Revision Number V01.00 V01.01 V01.02 V01.03 V01.04 V01.05 Revision Date 26 Oct. 2005 02 Nov 2006 4 Mar. 2008 1 Sep. 2008 20 Nov. 2008 19. Sep 2009 8.4.1.1/8-250 8.4.1.4/8-253 8.4.3.3/8-257 Table 8-14 8.3.2.4/8-239 8.5.1/8-259 Sections Affected Initial release Table “Examples of IPLL Divider settings”: corrected $32 to $31 Corrected details added 100MHz example for PLL S12XECRG Flags Register: corrected address to Module Base + 0x0003 Modified Note below Table 8-17./8-259 Description of Changes 8.1 Introduction This specification describes the function of the Clocks and Reset Generator (S12XECRG). 8.1.1 Features The main features of this block are: • Phase Locked Loop (IPLL) frequency multiplier with internal filter — Reference divider — Post divider — Configurable internal filter (no external pin) — Optional frequency modulation for defined jitter and reduced emission — Automatic frequency lock detector — Interrupt request on entry or exit from locked condition — Self Clock Mode in absence of reference clock • System Clock Generator — Clock Quality Check — User selectable fast wake-up from Stop in Self-Clock Mode for power saving and immediate program execution — Clock switch for either Oscillator or PLL based system clocks • Computer Operating Properly (COP) watchdog timer with time-out clear window. • System Reset generation from the following possible sources: — Power on reset S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 233 S12XE Clocks and Reset Generator (S12XECRGV1) • — Low voltage reset — Illegal address reset — COP reset — Loss of clock reset — External pin reset Real-Time Interrupt (RTI) 8.1.2 Modes of Operation This subsection lists and briefly describes all operating modes supported by the S12XECRG. • Run Mode All functional parts of the S12XECRG are running during normal Run Mode. If RTI or COP functionality is required the individual bits of the associated rate select registers (COPCTL, RTICTL) have to be set to a non zero value. • Wait Mode In this mode the IPLL can be disabled automatically depending on the PLLWAI bit. • Stop Mode Depending on the setting of the PSTP bit Stop Mode can be differentiated between Full Stop Mode (PSTP = 0) and Pseudo Stop Mode (PSTP = 1). — Full Stop Mode The oscillator is disabled and thus all system and core clocks are stopped. The COP and the RTI remain frozen. — Pseudo Stop Mode The oscillator continues to run and most of the system and core clocks are stopped. If the respective enable bits are set the COP and RTI will continue to run, else they remain frozen. • Self Clock Mode Self Clock Mode will be entered if the Clock Monitor Enable Bit (CME) and the Self Clock Mode Enable Bit (SCME) are both asserted and the clock monitor in the oscillator block detects a loss of clock. As soon as Self Clock Mode is entered the S12XECRG starts to perform a clock quality check. Self Clock Mode remains active until the clock quality check indicates that the required quality of the incoming clock signal is met (frequency and amplitude). Self Clock Mode should be used for safety purposes only. It provides reduced functionality to the MCU in case a loss of clock is causing severe system conditions. 8.1.3 Block Diagram Figure 8-1 shows a block diagram of the S12XECRG. S12XS Family Reference Manual, Rev. 1.09 234 Freescale Semiconductor S12XE Clocks and Reset Generator (S12XECRGV1) Illegal Address Reset S12X_MMC Power on Reset Voltage Regulator Low Voltage Reset ICRG RESET Clock Monitor CM Fail COP Timeout Reset Generator System Reset XCLKS EXTAL OSCCLK Oscillator XTAL Clock Quality Checker Bus Clock Core Clock COP RTI Oscillator Clock Registers PLLCLK VDDPLL VSSPLL IPLL Clock and Reset Control Real Time Interrupt PLL Lock Interrupt Self Clock Mode Interrupt Figure 8-1. Block diagram of S12XECRG 8.2 Signal Description This section lists and describes the signals that connect off chip. 8.2.1 VDDPLL, VSSPLL These pins provides operating voltage (VDDPLL) and ground (VSSPLL) for the IPLL circuitry. This allows the supply voltage to the IPLL to be independently bypassed. Even if IPLL usage is not required VDDPLL and VSSPLL must be connected to properly. 8.2.2 RESET RESET is an active low bidirectional reset pin. As an input it initializes the MCU asynchronously to a known start-up state. As an open-drain output it indicates that an system reset (internal to MCU) has been triggered. S12XS Family Reference Manual Rev. 1.09 Freescale Semiconductor 235 S12XE Clocks and Reset Generator (S12XECRGV1) 8.3 Memory Map and Registers This section provides a detailed description of all registers accessible in the S12XECRG. 8.3.1 Module Memory Map Figure 8-2 gives an overview on all S12XECRG registers. Address 0x0000 0x0001 0x0002 0x0003 0x0004 0x0005 0x0006 0x0007 0x0008 0x0009 0x000A 0x000B Name SYNR REFDV POSTDIV CRGFLG CRGINT CLKSEL PLLCTL RTICTL COPCTL FORBYP2 CTCTL2 ARMCOP R W R W R W R W R W R W R W R W R W R W R W R W 0 Bit 7 0 Bit 6 0 Bit 5 0 Bit 4 0 Bit 3 0 Bit 2 0 Bit 1 0 Bit 0 0 0 0 0 0 0 0 0 RTIF RTIE PLLSEL CME RTDEC WCOP 0 PORF 0 LVRF 0 XCLKS LOCKIF LOCKIE 0 LOCK 0 Bit 7 6 5 4 3 2 1 Bit 0 VCOFRQ[1:0] REFFRQ[1:0] 0 0 0 SYNDIV[5:0] REFDIV[5:0] POSTDIV[4:0] ILAF 0 0 SCMIF SCMIE RTIWAI PCE RTR1 CR1 0 SCM 0 PSTP PLLON RTR6 RSBCK 0 PLLWAI FSTWKP RTR3 0 0 COPWAI SCME RTR0 CR0 0 FM1 RTR5 0 WRTMASK 0 FM0 RTR4 0 0 PRE RTR2 CR2 0 2. FORBYP and CTCTL are intended for factory test purposes only. = Unimplemented or Reserved Figure 8-2. CRG Register Summary NOTE Register Address = Base Address + Address Offset, where the Base Address is defined at the MCU level and the Address Offset is defined at the module level. S12XS Family Reference Manual, Rev. 1.09 236 Freescale Semiconductor S12XE Clocks and Reset Generator (S12XECRGV1) 8.3.2 Register Descriptions This section describes in address order all the S12XECRG registers and their individual bits. 8.3.2.1 S12XECRG Synthesizer Register (SYNR) The SYNR register controls the multiplication factor of the IPLL and selects the VCO frequency range. Module Base + 0x0000 7 6 5 4 3 2 1 0 R VCOFRQ[1:0] W Reset 0 0 0 0 0 0 0 0 SYNDIV[5:0] Figure 8-3. S12XECRG Synthesizer Register (SYNR) Read: Anytime Write: Anytime except if PLLSEL = 1 NOTE Write to this register initializes the lock detector bit. ( SYNDIV + 1 ) f VCO = 2 × f OSC × -----------------------------------( REFDIV + 1 ) f VCO f PLL = ----------------------------------2 × POSTDIV f PLL f BUS = -----------2 NOTE fVCO must be within the specified VCO frequency lock range. F.BUS (Bus Clock) must not exceed the specified maximum. If POSTDIV = $00 then fPLL is same as fVCO (divide by one). The VCOFRQ[1:0] bit are used to configure the VCO gain for optimal stability and lock time. For correct IPLL operation the VCOFRQ[1:0] bits have to be selected according to the actual target VCOCLK frequency as shown in Table 8-2. Setting the VCOFRQ[1:0] bits wrong can result in a non functional IPLL (no locking and/or insufficient stability). Table 8-2. VCO Clock Frequency Selection VCOCLK Frequency Ranges 32MHz 101 at command launch Set if command not available in current mode (see Table 18-28) ACCERR Set if an invalid global address [22:0] is supplied FSTAT FPVIOL MGSTAT1 MGSTAT0 Set if a misaligned word address is supplied (global address [0] != 0) Set if the requested group of words breaches the end of the D-Flash block Set if the selected area of the D-Flash memory is protected Set if any errors have been encountered during the verify operation Set if any non-correctable errors have been encountered during the verify operation 18.4.2.16 Erase D-Flash Sector Command The Erase D-Flash Sector operation will erase all addresses in a sector of the D-Flash block. Table 18-63. Erase D-Flash Sector Command FCCOB Requirements CCOBIX[2:0] 000 001 0x12 FCCOB Parameters Global address [22:16] to identify D-Flash block Global address [15:0] anywhere within the sector to be erased. See Section 18.1.2.2 for D-Flash sector size. Upon clearing CCIF to launch the Erase D-Flash Sector command, the Memory Controller will erase the selected Flash sector and verify that it is erased. The CCIF flag will set after the Erase D-Flash Sector operation has completed. S12XS Family Reference Manual, Rev. 1.09 550 Freescale Semiconductor 256 KByte Flash Module (S12XFTMR256K1V1) Table 18-64. Erase D-Flash Sector Command Error Handling Register Error Bit Error Condition Set if CCOBIX[2:0] != 001 at command launch Set if command not available in current mode (see Table 18-28) ACCERR Set if an invalid global address [22:0] is supplied FSTAT FPVIOL MGSTAT1 MGSTAT0 Set if a misaligned word address is supplied (global address [0] != 0) Set if the selected area of the D-Flash memory is protected Set if any errors have been encountered during the verify operation Set if any non-correctable errors have been encountered during the verify operation 18.4.3 Interrupts The Flash module can generate an interrupt when a Flash command operation has completed or when a Flash command operation has detected an ECC fault. Table 18-65. Flash Interrupt Sources Interrupt Source Flash Command Complete ECC Double Bit Fault on Flash Read ECC Single Bit Fault on Flash Read Interrupt Flag CCIF (FSTAT register) DFDIF (FERSTAT register) SFDIF (FERSTAT register) Local Enable CCIE (FCNFG register) DFDIE (FERCNFG register) SFDIE (FERCNFG register) Global (CCR) Mask I Bit I Bit I Bit NOTE Vector addresses and their relative interrupt priority are determined at the MCU level. 18.4.3.1 Description of Flash Interrupt Operation The Flash module uses the CCIF flag in combination with the CCIE interrupt enable bit to generate the Flash command interrupt request. The Flash module uses the DFDIF and SFDIF flags in combination with the DFDIE and SFDIE interrupt enable bits to generate the Flash error interrupt request. For a detailed description of the register bits involved, refer to Section 18.3.2.5, “Flash Configuration Register (FCNFG)”, Section 18.3.2.6, “Flash Error Configuration Register (FERCNFG)”, Section 18.3.2.7, “Flash Status Register (FSTAT)”, and Section 18.3.2.8, “Flash Error Status Register (FERSTAT)”. The logic used for generating the Flash module interrupts is shown in Figure 18-27. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 551 256 KByte Flash Module (S12XFTMR256K1V1) CCIE CCIF Flash Command Interrupt Request DFDIE DFDIF SFDIE SFDIF Flash Error Interrupt Request Figure 18-27. Flash Module Interrupts Implementation 18.4.4 Wait Mode The Flash module is not affected if the MCU enters wait mode. The Flash module can recover the MCU from wait via the CCIF interrupt (see Section 18.4.3, “Interrupts”). 18.4.5 Stop Mode If a Flash command is active (CCIF = 0) when the MCU requests stop mode, the current Flash operation will be completed before the CPU is allowed to enter stop mode. 18.5 Security The Flash module provides security information to the MCU. The Flash security state is defined by the SEC bits of the FSEC register (see Table 18-10). During reset, the Flash module initializes the FSEC register using data read from the security byte of the Flash configuration field at global address 0x7F_FF0F. The security state out of reset can be permanently changed by programming the security byte of the Flash configuration field. This assumes that you are starting from a mode where the necessary P-Flash erase and program commands are available and that the upper region of the P-Flash is unprotected. If the Flash security byte is successfully programmed, its new value will take affect after the next MCU reset. The following subsections describe these security-related subjects: • Unsecuring the MCU using Backdoor Key Access • Unsecuring the MCU in Special Single Chip Mode using BDM • Mode and Security Effects on Flash Command Availability 18.5.1 Unsecuring the MCU using Backdoor Key Access The MCU may be unsecured by using the backdoor key access feature which requires knowledge of the contents of the backdoor keys (four 16-bit words programmed at addresses 0x7F_FF00–0x7F_FF07). If the KEYEN[1:0] bits are in the enabled state (see Section 18.3.2.2), the Verify Backdoor Access Key command (see Section 18.4.2.11) allows the user to present four prospective keys for comparison to the S12XS Family Reference Manual, Rev. 1.09 552 Freescale Semiconductor 256 KByte Flash Module (S12XFTMR256K1V1) keys stored in the Flash memory via the Memory Controller. If the keys presented in the Verify Backdoor Access Key command match the backdoor keys stored in the Flash memory, the SEC bits in the FSEC register (see Table 18-10) will be changed to unsecure the MCU. Key values of 0x0000 and 0xFFFF are not permitted as backdoor keys. While the Verify Backdoor Access Key command is active, P-Flash block 0 will not be available for read access and will return invalid data. The user code stored in the P-Flash memory must have a method of receiving the backdoor keys from an external stimulus. This external stimulus would typically be through one of the on-chip serial ports. If the KEYEN[1:0] bits are in the enabled state (see Section 18.3.2.2), the MCU can be unsecured by the backdoor key access sequence described below: 1. Follow the command sequence for the Verify Backdoor Access Key command as explained in Section 18.4.2.11 2. If the Verify Backdoor Access Key command is successful, the MCU is unsecured and the SEC[1:0] bits in the FSEC register are forced to the unsecure state of 10 The Verify Backdoor Access Key command is monitored by the Memory Controller and an illegal key will prohibit future use of the Verify Backdoor Access Key command. A reset of the MCU is the only method to re-enable the Verify Backdoor Access Key command. After the backdoor keys have been correctly matched, the MCU will be unsecured. After the MCU is unsecured, the sector containing the Flash security byte can be erased and the Flash security byte can be reprogrammed to the unsecure state, if desired. In the unsecure state, the user has full control of the contents of the backdoor keys by programming addresses 0x7F_FF00–0x7F_FF07 in the Flash configuration field. The security as defined in the Flash security byte (0x7F_FF0F) is not changed by using the Verify Backdoor Access Key command sequence. The backdoor keys stored in addresses 0x7F_FF00–0x7F_FF07 are unaffected by the Verify Backdoor Access Key command sequence. After the next reset of the MCU, the security state of the Flash module is determined by the Flash security byte (0x7F_FF0F). The Verify Backdoor Access Key command sequence has no effect on the program and erase protections defined in the Flash protection register, FPROT. 18.5.2 Unsecuring the MCU in Special Single Chip Mode using BDM The MCU can be unsecured in special single chip mode by erasing the P-Flash and D-Flash memory by one of the following methods: • Reset the MCU into special single chip mode, delay while the erase test is performed by the BDM, send BDM commands to disable protection in the P-Flash and D-Flash memory, and execute the Erase All Blocks command write sequence to erase the P-Flash and D-Flash memory. • Reset the MCU into special expanded wide mode, disable protection in the P-Flash and D-Flash memory and run code from external memory to execute the Erase All Blocks command write sequence to erase the P-Flash and D-Flash memory. After the CCIF flag sets to indicate that the Erase All Blocks operation has completed, reset the MCU into special single chip mode. The BDM will execute the Erase Verify All Blocks command write sequence to verify that the P-Flash and D-Flash memory is erased. If the P-Flash and D-Flash memory are verified as S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 553 256 KByte Flash Module (S12XFTMR256K1V1) erased the MCU will be unsecured. All BDM commands will be enabled and the Flash security byte may be programmed to the unsecure state by the following method: • Send BDM commands to execute a ‘Program P-Flash’ command sequence to program the Flash security byte to the unsecured state and reset the MCU. 18.5.3 Mode and Security Effects on Flash Command Availability The availability of Flash module commands depends on the MCU operating mode and security state as shown in Table 18-28. 18.6 Initialization On each system reset the Flash module executes a reset sequence which establishes initial values for the Flash Block Configuration Parameters, the FPROT and DFPROT protection registers, and the FOPT and FSEC registers. The Flash module reverts to built-in default values that leave the module in a fully protected and secured state if errors are encountered during execution of the reset sequence. If a double bit fault is detected during the reset sequence, both MGSTAT bits in the FSTAT register will be set. CCIF remains clear throughout the reset sequence. The Flash module holds off all CPU access for the initial portion of the reset sequence. While Flash reads are possible when the hold is removed, writes to the FCCOBIX, FCCOBHI, and FCCOBLO registers are ignored to prevent command activity while the Memory Controller remains busy. Completion of the reset sequence is marked by setting CCIF high which enables writes to the FCCOBIX, FCCOBHI, and FCCOBLO registers to launch any available Flash command. If a reset occurs while any Flash command is in progress, that command will be immediately aborted. The state of the word being programmed or the sector/block being erased is not guaranteed. S12XS Family Reference Manual, Rev. 1.09 554 Freescale Semiconductor Chapter 19 128 KByte Flash Module (S12XFTMR128K1V1) Table 19-1. Revision History Revision Number V01.04 V01.05 Revision Date 03 Jan 2008 19 Dec 2008 19.1/19-555 19.4.2.4/19-590 19.4.2.6/19-592 19.4.2.11/19-59 5 19.4.2.11/19-59 5 19.4.2.11/19-59 5 Sections Affected - Cosmetic changes - Clarify single bit fault correction for P-Flash phrase - Add statement concerning code runaway when executing Read Once, Program Once, and Verify Backdoor Access Key commands from Flash block containing associated fields - Relate Key 0 to associated Backdoor Comparison Key address - Change “power down reset” to “reset” in Section 19.4.2.11 Description of Changes V01.06 25 Sep 2009 The following changes were made to clarify module behavior related to Flash register access during reset sequence and while Flash commands are active: 19.3.2/19-562 - Add caution concerning register writes while command is active 19.3.2.1/19-564 - Writes to FCLKDIV are allowed during reset sequence while CCIF is clear 19.4.1.2/19-584 - Add caution concerning register writes while command is active - Writes to FCCOBIX, FCCOBHI, FCCOBLO registers are ignored during 19.6/19-604 reset sequence 19.1 Introduction The FTMR128K1 module implements the following: • 128 Kbytes of P-Flash (Program Flash) memory • 8 Kbytes of D-Flash (Data Flash) memory The Flash memory is ideal for single-supply applications allowing for field reprogramming without requiring external high voltage sources for program or erase operations. The Flash module includes a memory controller that executes commands to modify Flash memory contents. The user interface to the memory controller consists of the indexed Flash Common Command Object (FCCOB) register which is written to with the command, global address, data, and any required command parameters. The memory controller must complete the execution of a command before the FCCOB register can be written to with a new command. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor Preliminary 555 CAUTION A Flash word or phrase must be in the erased state before being programmed. Cumulative programming of bits within a Flash word or phrase is not allowed. The Flash memory may be read as bytes, aligned words, or misaligned words. Read access time is one bus cycle for bytes and aligned words, and two bus cycles for misaligned words. For Flash memory, an erased bit reads 1 and a programmed bit reads 0. It is not possible to read from a Flash block while any command is executing on that specific Flash block. It is possible to read from a Flash block while a command is executing on a different Flash block. Both P-Flash and D-Flash memories are implemented with Error Correction Codes (ECC) that can resolve single bit faults and detect double bit faults. For P-Flash memory, the ECC implementation requires that programming be done on an aligned 8 byte basis (a Flash phrase). Since P-Flash memory is always read by phrase, only one single bit fault in the phrase containing the byte or word accessed will be corrected. 19.1.1 Glossary Command Write Sequence — An MCU instruction sequence to execute built-in algorithms (including program and erase) on the Flash memory. D-Flash Memory — The D-Flash memory constitutes the nonvolatile memory store for data. D-Flash Sector — The D-Flash sector is the smallest portion of the D-Flash memory that can be erased. The D-Flash sector consists of four 64 byte rows for a total of 256 bytes. NVM Command Mode — An NVM mode using the CPU to setup the FCCOB register to pass parameters required for Flash command execution. Phrase — An aligned group of four 16-bit words within the P-Flash memory. Each phrase includes eight ECC bits for single bit fault correction and double bit fault detection within the phrase. P-Flash Memory — The P-Flash memory constitutes the main nonvolatile memory store for applications. P-Flash Sector — The P-Flash sector is the smallest portion of the P-Flash memory that can be erased. Each P-Flash sector contains 1024 bytes. Program IFR — Nonvolatile information register located in the P-Flash block that contains the Device ID, Version ID, and the Program Once field. The Program IFR is visible in the global memory map by setting the PGMIFRON bit in the MMCCTL1 register. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor Preliminary 556 128 KByte Flash Module (S12XFTMR128K1V1) 19.1.2 19.1.2.1 • • • • • Features P-Flash Features 128 Kbytes of P-Flash memory composed of one 128 Kbyte Flash block divided into 128 sectors of 1024 bytes Single bit fault correction and double bit fault detection within a 64-bit phrase during read operations Automated program and erase algorithm with verify and generation of ECC parity bits Fast sector erase and phrase program operation Flexible protection scheme to prevent accidental program or erase of P-Flash memory 19.1.2.2 • • • • • • D-Flash Features 8 Kbytes of D-Flash memory composed of one 8 Kbyte Flash block divided into 32 sectors of 256 bytes Single bit fault correction and double bit fault detection within a word during read operations Automated program and erase algorithm with verify and generation of ECC parity bits Fast sector erase and word program operation Protection scheme to prevent accidental program or erase of D-Flash memory Ability to program up to four words in a burst sequence 19.1.2.3 • • • Other Flash Module Features No external high-voltage power supply required for Flash memory program and erase operations Interrupt generation on Flash command completion and Flash error detection Security mechanism to prevent unauthorized access to the Flash memory 19.1.3 Block Diagram The block diagram of the Flash module is shown in Figure 19-1. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 557 128 KByte Flash Module (S12XFTMR128K1V1) Flash Interface Command Interrupt Request Error Interrupt Request Registers 16bit internal bus P-Flash 16Kx72 sector 0 sector 1 sector 127 Protection Security Oscillator Clock (XTAL) Clock Divider FCLK Memory Controller D-Flash 4Kx22 sector 0 sector 1 sector 31 CPU Scratch RAM 384x16bits Figure 19-1. FTMR128K1 Block Diagram 19.2 External Signal Description The Flash module contains no signals that connect off-chip. 19.3 Memory Map and Registers This section describes the memory map and registers for the Flash module. Read data from unimplemented memory space in the Flash module is undefined. Write access to unimplemented or reserved memory space in the Flash module will be ignored by the Flash module. S12XS Family Reference Manual, Rev. 1.09 558 Freescale Semiconductor 128 KByte Flash Module (S12XFTMR128K1V1) 19.3.1 Module Memory Map The S12X architecture places the P-Flash memory between global addresses 0x7E_0000 and 0x7F_FFFF as shown in Table 19-2. The P-Flash memory map is shown in Figure 19-2. Table 19-2. P-Flash Memory Addressing Global Address Size (Bytes) 128 K Description P-Flash Block 0 Contains Flash Configuration Field (see Table 19-3) 0x7E_0000 – 0x7F_FFFF The FPROT register, described in Section 19.3.2.9, can be set to protect regions in the Flash memory from accidental program or erase. Three separate memory regions, one growing upward from global address 0x7F_8000 in the Flash memory (called the lower region), one growing downward from global address 0x7F_FFFF in the Flash memory (called the higher region), and the remaining addresses in the Flash memory, can be activated for protection. The Flash memory addresses covered by these protectable regions are shown in the P-Flash memory map. The higher address region is mainly targeted to hold the boot loader code since it covers the vector space. Default protection settings as well as security information that allows the MCU to restrict access to the Flash module are stored in the Flash configuration field as described in Table 19-3. Table 19-3. Flash Configuration Field1 Global Address Size (Bytes) 8 4 1 1 1 1 Description Backdoor Comparison Key Refer to Section 19.4.2.11, “Verify Backdoor Access Key Command,” and Section 19.5.1, “Unsecuring the MCU using Backdoor Key Access” Reserved P-Flash Protection byte. Refer to Section 19.3.2.9, “P-Flash Protection Register (FPROT)” D-Flash Protection byte. Refer to Section 19.3.2.10, “D-Flash Protection Register (DFPROT)” Flash Nonvolatile byte Refer to Section 19.3.2.15, “Flash Option Register (FOPT)” Flash Security byte Refer to Section 19.3.2.2, “Flash Security Register (FSEC)” 0x7F_FF00 – 0x7F_FF07 0x7F_FF08 – 0x7F_FF0B2 0x7F_FF0C2 0x7F_FF0D2 0x7F_FF0E2 0x7F_FF0F2 1 2 Older versions may have swapped protection byte addresses 0x7FF08 - 0x7F_FF0F form a Flash phrase and must be programmed in a single command write sequence. Each byte in the 0x7F_FF08 - 0x7F_FF0B reserved field should be programmed to 0xFF. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 559 128 KByte Flash Module (S12XFTMR128K1V1) P-Flash START = 0x7E_0000 Flash Protected/Unprotected Region 96 Kbytes 0x7F_8000 0x7F_8400 0x7F_8800 0x7F_9000 Flash Protected/Unprotected Lower Region 1, 2, 4, 8 Kbytes 0x7F_A000 Flash Protected/Unprotected Region 8 Kbytes (up to 29 Kbytes) 0x7F_C000 0x7F_E000 Flash Protected/Unprotected Higher Region 2, 4, 8, 16 Kbytes 0x7F_F000 0x7F_F800 P-Flash END = 0x7F_FFFF Flash Configuration Field 16 bytes (0x7F_FF00 - 0x7F_FF0F) Figure 19-2. P-Flash Memory Map S12XS Family Reference Manual, Rev. 1.09 560 Freescale Semiconductor 128 KByte Flash Module (S12XFTMR128K1V1) Table 19-4. Program IFR Fields Global Address (PGMIFRON) 0x40_0000 – 0x40_0007 0x40_0008 – 0x40_00E7 0x40_00E8 – 0x40_00E9 0x40_00EA – 0x40_00FF 0x40_0100 – 0x40_013F 0x40_0140 – 0x40_01FF Size (Bytes) 8 224 2 22 64 192 Device ID Reserved Version ID Reserved Program Once Field Refer to Section 19.4.2.6, “Program Once Command” Reserved Field Description Table 19-5. D-Flash and Memory Controller Resource Fields Global Address 0x10_0000 – 0x10_1FFF 0x10_2000 – 0x11_FFFF 0x12_0000 – 0x12_007F 0x12_0080 – 0x12_0FFF 0x12_1000 – 0x12_1FFF 0x12_2000 – 0x12_3CFF 0x12_3D00 – 0x12_3FFF 0x12_4000 – 0x12_E7FF 0x12_E800 – 0x12_FFFF 0x13_0000 – 0x13_FFFF 1 Size (Bytes) 8,192 122,880 128 3,968 4,096 7,242 768 43,008 6,144 65,536 D-Flash Memory Reserved Description D-Flash Nonvolatile Information Register (DFIFRON1 = 1) Reserved Reserved Reserved Memory Controller Scratch RAM (MGRAMON1 = 1) Reserved Reserved Reserved MMCCTL1 register bit S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 561 128 KByte Flash Module (S12XFTMR128K1V1) D-Flash START = 0x10_0000 D-Flash Memory 8 Kbytes D-Flash END = 0x10_1FFF 0x12_0000 0x12_1000 0x12_2000 0x12_4000 D-Flash Nonvolatile Information Register (DFIFRON) 128 bytes Memory Controller Scratch RAM (MGRAMON) 768 bytes 0x12_E800 0x12_FFFF Figure 19-3. D-Flash and Memory Controller Resource Memory Map 19.3.2 Register Descriptions The Flash module contains a set of 20 control and status registers located between Flash module base + 0x0000 and 0x0013. A summary of the Flash module registers is given in Figure 19-4 with detailed descriptions in the following subsections. CAUTION Writes to any Flash register must be avoided while a Flash command is active (CCIF=0) to prevent corruption of Flash register contents and Memory Controller behavior. Address & Name 0x0000 FCLKDIV 0x0001 FSEC R W R W KEYEN1 KEYEN0 RNV5 RNV4 RNV3 RNV2 SEC1 SEC0 7 FDIVLD FDIV6 FDIV5 FDIV4 FDIV3 FDIV2 FDIV1 FDIV0 6 5 4 3 2 1 0 Figure 19-4. FTMR128K1 Register Summary S12XS Family Reference Manual, Rev. 1.09 562 Freescale Semiconductor 128 KByte Flash Module (S12XFTMR128K1V1) Address & Name 0x0002 FCCOBIX 0x0003 FECCRIX 0x0004 FCNFG 0x0005 FERCNFG 0x0006 FSTAT 0x0007 FERSTAT 0x0008 FPROT 0x0009 DFPROT 0x000A FCCOBHI 0x000B FCCOBLO 0x000C FRSV0 0x000D FRSV1 0x000E FECCRHI 0x000F FECCRLO R W R W R 7 0 6 0 5 0 4 0 3 0 2 1 0 CCOBIX2 CCOBIX1 CCOBIX0 0 0 0 0 0 ECCRIX2 ECCRIX1 ECCRIX0 0 CCIE 0 IGNSF 0 0 FDFD FSFD W R W R CCIF W R W R FPOPEN W R DPOPEN W R CCOB15 W R CCOB7 W R W R W R W R W ECCR7 ECCR6 ECCR5 ECCR4 ECCR3 ECCR2 ECCR1 ECCR0 ECCR15 ECCR14 ECCR13 ECCR12 ECCR11 ECCR10 ECCR9 ECCR8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 CCOB6 CCOB5 CCOB4 CCOB3 CCOB2 CCOB1 CCOB0 CCOB14 CCOB13 CCOB12 CCOB11 CCOB10 CCOB9 CCOB8 0 0 DPS4 DPS3 DPS2 DPS1 DPS0 RNV6 FPHDIS FPHS1 FPHS0 FPLDIS FPLS1 FPLS0 0 0 0 0 0 0 DFDIF SFDIF 0 ACCERR FPVIOL MGBUSY RSVD MGSTAT1 MGSTAT0 0 DFDIE SFDIE Figure 19-4. FTMR128K1 Register Summary (continued) S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 563 128 KByte Flash Module (S12XFTMR128K1V1) Address & Name 0x0010 FOPT 0x0011 FRSV2 0x0012 FRSV3 0x0013 FRSV4 R W R W R W R W 7 NV7 6 NV6 5 NV5 4 NV4 3 NV3 2 NV2 1 NV1 0 NV0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = Unimplemented or Reserved Figure 19-4. FTMR128K1 Register Summary (continued) 19.3.2.1 Flash Clock Divider Register (FCLKDIV) The FCLKDIV register is used to control timed events in program and erase algorithms. Offset Module Base + 0x0000 7 6 5 4 3 2 1 0 R W Reset FDIVLD FDIV[6:0] 0 0 0 0 0 0 0 0 = Unimplemented or Reserved Figure 19-5. Flash Clock Divider Register (FCLKDIV) All bits in the FCLKDIV register are readable, bits 6–0 are write once and bit 7 is not writable. Table 19-6. FCLKDIV Field Descriptions Field 7 FDIVLD 6–0 FDIV[6:0] Description Clock Divider Loaded 0 FCLKDIV register has not been written 1 FCLKDIV register has been written since the last reset Clock Divider Bits — FDIV[6:0] must be set to effectively divide OSCCLK down to generate an internal Flash clock, FCLK, with a target frequency of 1 MHz for use by the Flash module to control timed events during program and erase algorithms. Table 19-7 shows recommended values for FDIV[6:0] based on OSCCLK frequency. Please refer to Section 19.4.1, “Flash Command Operations,” for more information. S12XS Family Reference Manual, Rev. 1.09 564 Freescale Semiconductor 128 KByte Flash Module (S12XFTMR128K1V1) CAUTION The FCLKDIV register should never be written while a Flash command is executing (CCIF=0). The FCLKDIV register is writable during the Flash reset sequence even though CCIF is clear. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 565 128 KByte Flash Module (S12XFTMR128K1V1) Table 19-7. FDIV vs OSCCLK Frequency OSCCLK Frequency (MHz) MIN1 1.60 2.40 3.20 4.20 5.25 6.30 7.35 8.40 9.45 10.50 11.55 12.60 13.65 14.70 15.75 16.80 17.85 18.90 19.95 21.00 22.05 23.10 24.15 25.20 26.25 27.30 28.35 29.40 30.45 31.50 32.55 1 2 FDIV[6:0] OSCCLK Frequency (MHz) MIN1 MAX 2 FDIV[6:0] MAX 2 2.10 3.15 4.20 5.25 6.30 7.35 8.40 9.45 10.50 11.55 12.60 13.65 14.70 15.75 16.80 17.85 18.90 19.95 21.00 22.05 23.10 24.15 25.20 26.25 27.30 28.35 29.40 30.45 31.50 32.55 33.60 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1A 0x1B 0x1C 0x1D 0x1E 0x1F 33.60 34.65 35.70 36.75 37.80 38.85 39.90 40.95 42.00 43.05 44.10 45.15 46.20 47.25 48.30 49.35 34.65 35.70 36.75 37.80 38.85 39.90 40.95 42.00 43.05 44.10 45.15 46.20 47.25 48.30 49.35 50.40 0x20 0x21 0x22 0x23 0x24 0x25 0x26 0x27 0x28 0x29 0x2A 0x2B 0x2C 0x2D 0x2E 0x2F FDIV shown generates an FCLK frequency of >0.8 MHz FDIV shown generates an FCLK frequency of 1.05 MHz S12XS Family Reference Manual, Rev. 1.09 566 Freescale Semiconductor 128 KByte Flash Module (S12XFTMR128K1V1) 19.3.2.2 Flash Security Register (FSEC) The FSEC register holds all bits associated with the security of the MCU and Flash module. Offset Module Base + 0x0001 7 6 5 4 3 2 1 0 R W Reset F KEYEN[1:0] RNV[5:2] SEC[1:0] F F F F F F F = Unimplemented or Reserved Figure 19-6. Flash Security Register (FSEC) All bits in the FSEC register are readable but not writable. During the reset sequence, the FSEC register is loaded with the contents of the Flash security byte in the Flash configuration field at global address 0x7F_FF0F located in P-Flash memory (see Table 19-3) as indicated by reset condition F in Figure 19-6. If a double bit fault is detected while reading the P-Flash phrase containing the Flash security byte during the reset sequence, all bits in the FSEC register will be set to leave the Flash module in a secured state with backdoor key access disabled. Table 19-8. FSEC Field Descriptions Field Description 7–6 Backdoor Key Security Enable Bits — The KEYEN[1:0] bits define the enabling of backdoor key access to the KEYEN[1:0] Flash module as shown in Table 19-9. 5–2 RNV[5:2} 1–0 SEC[1:0] Reserved Nonvolatile Bits — The RNV bits should remain in the erased state for future enhancements. Flash Security Bits — The SEC[1:0] bits define the security state of the MCU as shown in Table 19-10. If the Flash module is unsecured using backdoor key access, the SEC bits are forced to 10. Table 19-9. Flash KEYEN States KEYEN[1:0] 00 01 10 11 1 Status of Backdoor Key Access DISABLED DISABLED1 ENABLED DISABLED Preferred KEYEN state to disable backdoor key access. Table 19-10. Flash Security States SEC[1:0] 00 01 10 11 Status of Security SECURED SECURED1 UNSECURED SECURED S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 567 128 KByte Flash Module (S12XFTMR128K1V1) 1 Preferred SEC state to set MCU to secured state. The security function in the Flash module is described in Section 19.5. 19.3.2.3 Flash CCOB Index Register (FCCOBIX) The FCCOBIX register is used to index the FCCOB register for Flash memory operations. Offset Module Base + 0x0002 7 6 5 4 3 2 1 0 R W Reset 0 0 0 0 0 CCOBIX[2:0] 0 0 0 0 0 0 0 0 = Unimplemented or Reserved Figure 19-7. FCCOB Index Register (FCCOBIX) CCOBIX bits are readable and writable while remaining bits read 0 and are not writable. Table 19-11. FCCOBIX Field Descriptions Field 2–0 CCOBIX[1:0] Description Common Command Register Index— The CCOBIX bits are used to select which word of the FCCOB register array is being read or written to. See Section 19.3.2.11, “Flash Common Command Object Register (FCCOB),” for more details. 19.3.2.4 Flash ECCR Index Register (FECCRIX) The FECCRIX register is used to index the FECCR register for ECC fault reporting. Offset Module Base + 0x0003 7 6 5 4 3 2 1 0 R W Reset 0 0 0 0 0 ECCRIX[2:0] 0 0 0 0 0 0 0 0 = Unimplemented or Reserved Figure 19-8. FECCR Index Register (FECCRIX) ECCRIX bits are readable and writable while remaining bits read 0 and are not writable. Table 19-12. FECCRIX Field Descriptions Field Description 2-0 ECC Error Register Index— The ECCRIX bits are used to select which word of the FECCR register array is ECCRIX[2:0] being read. See Section 19.3.2.14, “Flash ECC Error Results Register (FECCR),” for more details. S12XS Family Reference Manual, Rev. 1.09 568 Freescale Semiconductor 128 KByte Flash Module (S12XFTMR128K1V1) 19.3.2.5 Flash Configuration Register (FCNFG) The FCNFG register enables the Flash command complete interrupt and forces ECC faults on Flash array read access from the CPU or XGATE. Offset Module Base + 0x0004 7 6 5 4 3 2 1 0 R CCIE W Reset 0 0 0 IGNSF 0 0 FDFD FSFD 0 0 0 0 0 0 0 = Unimplemented or Reserved Figure 19-9. Flash Configuration Register (FCNFG) CCIE, IGNSF, FDFD, and FSFD bits are readable and writable while remaining bits read 0 and are not writable. Table 19-13. FCNFG Field Descriptions Field 7 CCIE Description Command Complete Interrupt Enable — The CCIE bit controls interrupt generation when a Flash command has completed. 0 Command complete interrupt disabled 1 An interrupt will be requested whenever the CCIF flag in the FSTAT register is set (see Section 19.3.2.7) Ignore Single Bit Fault — The IGNSF controls single bit fault reporting in the FERSTAT register (see Section 19.3.2.8). 0 All single bit faults detected during array reads are reported 1 Single bit faults detected during array reads are not reported and the single bit fault interrupt will not be generated Force Double Bit Fault Detect — The FDFD bit allows the user to simulate a double bit fault during Flash array read operations and check the associated interrupt routine. The FDFD bit is cleared by writing a 0 to FDFD. The FECCR registers will not be updated during the Flash array read operation with FDFD set unless an actual double bit fault is detected. 0 Flash array read operations will set the DFDIF flag in the FERSTAT register only if a double bit fault is detected 1 Any Flash array read operation will force the DFDIF flag in the FERSTAT register to be set (see Section 19.3.2.7) and an interrupt will be generated as long as the DFDIE interrupt enable in the FERCNFG register is set (see Section 19.3.2.6) Force Single Bit Fault Detect — The FSFD bit allows the user to simulate a single bit fault during Flash array read operations and check the associated interrupt routine. The FSFD bit is cleared by writing a 0 to FSFD. The FECCR registers will not be updated during the Flash array read operation with FSFD set unless an actual single bit fault is detected. 0 Flash array read operations will set the SFDIF flag in the FERSTAT register only if a single bit fault is detected 1 Flash array read operation will force the SFDIF flag in the FERSTAT register to be set (see Section 19.3.2.7) and an interrupt will be generated as long as the SFDIE interrupt enable in the FERCNFG register is set (see Section 19.3.2.6) 4 IGNSF 1 FDFD 0 FSFD 19.3.2.6 Flash Error Configuration Register (FERCNFG) The FERCNFG register enables the Flash error interrupts for the FERSTAT flags. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 569 128 KByte Flash Module (S12XFTMR128K1V1) Offset Module Base + 0x0005 7 6 5 4 3 2 1 0 R W Reset 0 0 0 DFDIE 0 0 0 0 0 SFDIE 0 = Unimplemented or Reserved Figure 19-10. Flash Error Configuration Register (FERCNFG) All assigned bits in the FERCNFG register are readable and writable. Table 19-14. FERCNFG Field Descriptions Field 1 DFDIE Description Double Bit Fault Detect Interrupt Enable — The DFDIE bit controls interrupt generation when a double bit fault is detected during a Flash block read operation. 0 DFDIF interrupt disabled 1 An interrupt will be requested whenever the DFDIF flag is set (see Section 19.3.2.8) Single Bit Fault Detect Interrupt Enable — The SFDIE bit controls interrupt generation when a single bit fault is detected during a Flash block read operation. 0 SFDIF interrupt disabled whenever the SFDIF flag is set (see Section 19.3.2.8) 1 An interrupt will be requested whenever the SFDIF flag is set (see Section 19.3.2.8) 0 SFDIE 19.3.2.7 Flash Status Register (FSTAT) The FSTAT register reports the operational status of the Flash module. Offset Module Base + 0x0006 7 6 5 4 3 2 1 0 R CCIF W Reset 1 0 ACCERR 0 0 FPVIOL 0 MGBUSY RSVD MGSTAT[1:0] 0 0 01 01 = Unimplemented or Reserved Figure 19-11. Flash Status Register (FSTAT) 1 Reset value can deviate from the value shown if a double bit fault is detected during the reset sequence (see Section 19.6). CCIF, ACCERR, and FPVIOL bits are readable and writable, MGBUSY and MGSTAT bits are readable but not writable, while remaining bits read 0 and are not writable. S12XS Family Reference Manual, Rev. 1.09 570 Freescale Semiconductor 128 KByte Flash Module (S12XFTMR128K1V1) Table 19-15. FSTAT Field Descriptions Field 7 CCIF Description Command Complete Interrupt Flag — The CCIF flag indicates that a Flash command has completed. The CCIF flag is cleared by writing a 1 to CCIF to launch a command and CCIF will stay low until command completion or command violation. 0 Flash command in progress 1 Flash command has completed Flash Access Error Flag — The ACCERR bit indicates an illegal access has occurred to the Flash memory caused by either a violation of the command write sequence (see Section 19.4.1.2) or issuing an illegal Flash command. While ACCERR is set, the CCIF flag cannot be cleared to launch a command. The ACCERR bit is cleared by writing a 1 to ACCERR. Writing a 0 to the ACCERR bit has no effect on ACCERR. 0 No access error detected 1 Access error detected Flash Protection Violation Flag —The FPVIOL bit indicates an attempt was made to program or erase an address in a protected area of P-Flash or D-Flash memory during a command write sequence. The FPVIOL bit is cleared by writing a 1 to FPVIOL. Writing a 0 to the FPVIOL bit has no effect on FPVIOL. While FPVIOL is set, it is not possible to launch a command or start a command write sequence. 0 No protection violation detected 1 Protection violation detected Memory Controller Busy Flag — The MGBUSY flag reflects the active state of the Memory Controller. 0 Memory Controller is idle 1 Memory Controller is busy executing a Flash command (CCIF = 0) Reserved Bit — This bit is reserved and always reads 0. 5 ACCERR 4 FPVIOL 3 MGBUSY 2 RSVD 1–0 Memory Controller Command Completion Status Flag — One or more MGSTAT flag bits are set if an error MGSTAT[1:0] is detected during execution of a Flash command or during the Flash reset sequence. See Section 19.4.2, “Flash Command Description,” and Section 19.6, “Initialization” for details. 19.3.2.8 Flash Error Status Register (FERSTAT) The FERSTAT register reflects the error status of internal Flash operations. Offset Module Base + 0x0007 7 6 5 4 3 2 1 0 R W Reset 0 0 0 0 0 0 DFDIF SFDIF 0 0 0 0 0 0 0 0 = Unimplemented or Reserved Figure 19-12. Flash Error Status Register (FERSTAT) All flags in the FERSTAT register are readable and only writable to clear the flag. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 571 128 KByte Flash Module (S12XFTMR128K1V1) Table 19-16. FERSTAT Field Descriptions Field 1 DFDIF Description Double Bit Fault Detect Interrupt Flag — The setting of the DFDIF flag indicates that a double bit fault was detected in the stored parity and data bits during a Flash array read operation or that a Flash array read operation was attempted on a Flash block that was under a Flash command operation. The DFDIF flag is cleared by writing a 1 to DFDIF. Writing a 0 to DFDIF has no effect on DFDIF. 0 No double bit fault detected 1 Double bit fault detected or an invalid Flash array read operation attempted Single Bit Fault Detect Interrupt Flag — With the IGNSF bit in the FCNFG register clear, the SFDIF flag indicates that a single bit fault was detected in the stored parity and data bits during a Flash array read operation or that a Flash array read operation was attempted on a Flash block that was under a Flash command operation. The SFDIF flag is cleared by writing a 1 to SFDIF. Writing a 0 to SFDIF has no effect on SFDIF. 0 No single bit fault detected 1 Single bit fault detected and corrected or an invalid Flash array read operation attempted 0 SFDIF 19.3.2.9 P-Flash Protection Register (FPROT) The FPROT register defines which P-Flash sectors are protected against program and erase operations. Offset Module Base + 0x0008 7 6 5 4 3 2 1 0 R FPOPEN W Reset F RNV6 FPHDIS F F F FPHS[1:0] F FPLDIS F F FPLS[1:0] F = Unimplemented or Reserved Figure 19-13. Flash Protection Register (FPROT) The (unreserved) bits of the FPROT register are writable with the restriction that the size of the protected region can only be increased (see Section 19.3.2.9.1, “P-Flash Protection Restrictions,” and Table 19-21). During the reset sequence, the FPROT register is loaded with the contents of the P-Flash protection byte in the Flash configuration field at global address 0x7F_FF0C located in P-Flash memory (see Table 19-3) as indicated by reset condition ‘F’ in Figure 19-13. To change the P-Flash protection that will be loaded during the reset sequence, the upper sector of the P-Flash memory must be unprotected, then the P-Flash protection byte must be reprogrammed. If a double bit fault is detected while reading the P-Flash phrase containing the P-Flash protection byte during the reset sequence, the FPOPEN bit will be cleared and remaining bits in the FPROT register will be set to leave the P-Flash memory fully protected. Trying to alter data in any protected area in the P-Flash memory will result in a protection violation error and the FPVIOL bit will be set in the FSTAT register. The block erase of a P-Flash block is not possible if any of the P-Flash sectors contained in the same P-Flash block are protected. S12XS Family Reference Manual, Rev. 1.09 572 Freescale Semiconductor 128 KByte Flash Module (S12XFTMR128K1V1) Table 19-17. FPROT Field Descriptions Field 7 FPOPEN Description Flash Protection Operation Enable — The FPOPEN bit determines the protection function for program or erase operations as shown in Table 19-18 for the P-Flash block. 0 When FPOPEN is clear, the FPHDIS and FPLDIS bits define unprotected address ranges as specified by the corresponding FPHS and FPLS bits 1 When FPOPEN is set, the FPHDIS and FPLDIS bits enable protection for the address range specified by the corresponding FPHS and FPLS bits Reserved Nonvolatile Bit — The RNV bit should remain in the erased state for future enhancements. Flash Protection Higher Address Range Disable — The FPHDIS bit determines whether there is a protected/unprotected area in a specific region of the P-Flash memory ending with global address 0x7F_FFFF. 0 Protection/Unprotection enabled 1 Protection/Unprotection disabled Flash Protection Higher Address Size — The FPHS bits determine the size of the protected/unprotected area in P-Flash memory as shown inTable 19-19. The FPHS bits can only be written to while the FPHDIS bit is set. Flash Protection Lower Address Range Disable — The FPLDIS bit determines whether there is a protected/unprotected area in a specific region of the P-Flash memory beginning with global address 0x7F_8000. 0 Protection/Unprotection enabled 1 Protection/Unprotection disabled Flash Protection Lower Address Size — The FPLS bits determine the size of the protected/unprotected area in P-Flash memory as shown in Table 19-20. The FPLS bits can only be written to while the FPLDIS bit is set. 6 RNV[6] 5 FPHDIS 4–3 FPHS[1:0] 2 FPLDIS 1–0 FPLS[1:0] Table 19-18. P-Flash Protection Function FPOPEN 1 1 1 1 0 0 0 0 1 FPHDIS 1 1 0 0 1 1 0 0 FPLDIS 1 0 1 0 1 0 1 0 Function1 No P-Flash Protection Protected Low Range Protected High Range Protected High and Low Ranges Full P-Flash Memory Protected Unprotected Low Range Unprotected High Range Unprotected High and Low Ranges For range sizes, refer to Table 19-19 and Table 19-20. Table 19-19. P-Flash Protection Higher Address Range FPHS[1:0] 00 01 10 11 Global Address Range 0x7F_F800–0x7F_FFFF 0x7F_F000–0x7F_FFFF 0x7F_E000–0x7F_FFFF 0x7F_C000–0x7F_FFFF Protected Size 2 Kbytes 4 Kbytes 8 Kbytes 16 Kbytes S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 573 128 KByte Flash Module (S12XFTMR128K1V1) Table 19-20. P-Flash Protection Lower Address Range FPLS[1:0] 00 01 10 11 Global Address Range 0x7F_8000–0x7F_83FF 0x7F_8000–0x7F_87FF 0x7F_8000–0x7F_8FFF 0x7F_8000–0x7F_9FFF Protected Size 1 Kbyte 2 Kbytes 4 Kbytes 8 Kbytes All possible P-Flash protection scenarios are shown in Figure 19-14. Although the protection scheme is loaded from the Flash memory at global address 0x7F_FF0C during the reset sequence, it can be changed by the user. The P-Flash protection scheme can be used by applications requiring reprogramming in single chip mode while providing as much protection as possible if reprogramming is not required. S12XS Family Reference Manual, Rev. 1.09 574 Freescale Semiconductor 128 KByte Flash Module (S12XFTMR128K1V1) FPHDIS = 1 FPLDIS = 1 FLASH START FPHDIS = 1 FPLDIS = 0 6 FPHDIS = 0 FPLDIS = 1 5 FPHDIS = 0 FPLDIS = 0 4 Scenario 7 0x7F_8000 0x7F_FFFF Scenario FLASH START 3 2 1 0 FPHS[1:0] FPHS[1:0] FPLS[1:0] FPOPEN = 0 575 0x7F_8000 0x7F_FFFF Unprotected region Protected region not defined by FPLS, FPHS Protected region with size defined by FPLS Protected region with size defined by FPHS Figure 19-14. P-Flash Protection Scenarios S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor FPLS[1:0] FPOPEN = 1 128 KByte Flash Module (S12XFTMR128K1V1) 19.3.2.9.1 P-Flash Protection Restrictions The general guideline is that P-Flash protection can only be added and not removed. Table 19-21 specifies all valid transitions between P-Flash protection scenarios. Any attempt to write an invalid scenario to the FPROT register will be ignored. The contents of the FPROT register reflect the active protection scenario. See the FPHS and FPLS bit descriptions for additional restrictions. Table 19-21. P-Flash Protection Scenario Transitions From Protection Scenario 0 1 2 3 4 5 6 7 1 To Protection Scenario1 0 X 1 X X X 2 X 3 X X X X X X X X X X X X X X X X X X X X X X 4 5 6 7 Allowed transitions marked with X, see Figure 19-14 for a definition of the scenarios. 19.3.2.10 D-Flash Protection Register (DFPROT) The DFPROT register defines which D-Flash sectors are protected against program and erase operations. Offset Module Base + 0x0009 7 6 5 4 3 2 1 0 R DPOPEN W Reset F 0 0 DPS[4:0] 0 0 F F F F F = Unimplemented or Reserved Figure 19-15. D-Flash Protection Register (DFPROT) The (unreserved) bits of the DFPROT register are writable with the restriction that protection can be added but not removed. Writes must increase the DPS value and the DPOEN bit can only be written from 1 (protection disabled) to 0 (protection enabled). If the DPOPEN bit is set, the state of the DPS bits is irrelevant. During the reset sequence, the DFPROT register is loaded with the contents of the D-Flash protection byte in the Flash configuration field at global address 0x7F_FF0D located in P-Flash memory (see Table 19-3) as indicated by reset condition F in Figure 19-15. To change the D-Flash protection that will be loaded during the reset sequence, the P-Flash sector containing the D-Flash protection byte must be unprotected, then the D-Flash protection byte must be programmed. If a double bit fault is detected while reading the S12XS Family Reference Manual, Rev. 1.09 576 Freescale Semiconductor 128 KByte Flash Module (S12XFTMR128K1V1) P-Flash phrase containing the D-Flash protection byte during the reset sequence, the DPOPEN bit will be cleared and DPS bits will be set to leave the D-Flash memory fully protected. Trying to alter data in any protected area in the D-Flash memory will result in a protection violation error and the FPVIOL bit will be set in the FSTAT register. Block erase of the D-Flash memory is not possible if any of the D-Flash sectors are protected. Table 19-22. DFPROT Field Descriptions Field 7 DPOPEN Description D-Flash Protection Control 0 Enables D-Flash memory protection from program and erase with protected address range defined by DPS bits 1 Disables D-Flash memory protection from program and erase D-Flash Protection Size — The DPS[4:0] bits determine the size of the protected area in the D-Flash memory as shown in Table 19-23. 4–0 DPS[4:0] Table 19-23. D-Flash Protection Address Range DPS[4:0] 0_0000 0_0001 0_0010 0_0011 0_0100 0_0101 0_0110 0_0111 0_1000 0_1001 0_1010 0_1011 0_1100 0_1101 0_1110 0_1111 1_0000 1_0001 1_0010 1_0011 1_0100 1_0101 Global Address Range 0x10_0000 – 0x10_00FF 0x10_0000 – 0x10_01FF 0x10_0000 – 0x10_02FF 0x10_0000 – 0x10_03FF 0x10_0000 – 0x10_04FF 0x10_0000 – 0x10_05FF 0x10_0000 – 0x10_06FF 0x10_0000 – 0x10_07FF 0x10_0000 – 0x10_08FF 0x10_0000 – 0x10_09FF 0x10_0000 – 0x10_0AFF 0x10_0000 – 0x10_0BFF 0x10_0000 – 0x10_0CFF 0x10_0000 – 0x10_0DFF 0x10_0000 – 0x10_0EFF 0x10_0000 – 0x10_0FFF 0x10_0000 – 0x10_10FF 0x10_0000 – 0x10_11FF 0x10_0000 – 0x10_12FF 0x10_0000 – 0x10_13FF 0x10_0000 – 0x10_14FF 0x10_0000 – 0x10_15FF Protected Size 256 bytes 512 bytes 768 bytes 1024 bytes 1280 bytes 1536 bytes 1792 bytes 2048 bytes 2304 bytes 2560 bytes 2816 bytes 3072 bytes 3328 bytes 3584 bytes 3840 bytes 4096 bytes 4352 bytes 4608 bytes 4864 bytes 5120 bytes 5376 bytes 5632 bytes S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 577 128 KByte Flash Module (S12XFTMR128K1V1) Table 19-23. D-Flash Protection Address Range DPS[4:0] 1_0110 1_0111 1_1000 1_1001 1_1010 1_1011 1_1100 1_1101 1_1110 1_1111 Global Address Range 0x10_0000 – 0x10_16FF 0x10_0000 – 0x10_17FF 0x10_0000 – 0x10_18FF 0x10_0000 – 0x10_19FF 0x10_0000 – 0x10_1AFF 0x10_0000 – 0x10_1BFF 0x10_0000 – 0x10_1CFF 0x10_0000 – 0x10_1DFF 0x10_0000 – 0x10_1EFF 0x10_0000 – 0x10_1FFF Protected Size 5888 bytes 6144 bytes 6400 bytes 6656 bytes 6912 bytes 7168 bytes 7424 bytes 7680 bytes 7936 bytes 8192 bytes 19.3.2.11 Flash Common Command Object Register (FCCOB) The FCCOB is an array of six words addressed via the CCOBIX index found in the FCCOBIX register. Byte wide reads and writes are allowed to the FCCOB register. Offset Module Base + 0x000A 7 6 5 4 3 2 1 0 R CCOB[15:8] W Reset 0 0 0 0 0 0 0 0 Figure 19-16. Flash Common Command Object High Register (FCCOBHI) Offset Module Base + 0x000B 7 6 5 4 3 2 1 0 R CCOB[7:0] W Reset 0 0 0 0 0 0 0 0 Figure 19-17. Flash Common Command Object Low Register (FCCOBLO) 19.3.2.11.1 FCCOB - NVM Command Mode NVM command mode uses the indexed FCCOB register to provide a command code and its relevant parameters to the Memory Controller. The user first sets up all required FCCOB fields and then initiates the command’s execution by writing a 1 to the CCIF bit in the FSTAT register (a 1 written by the user clears the CCIF command completion flag to 0). When the user clears the CCIF bit in the FSTAT register all FCCOB parameter fields are locked and cannot be changed by the user until the command completes S12XS Family Reference Manual, Rev. 1.09 578 Freescale Semiconductor 128 KByte Flash Module (S12XFTMR128K1V1) (as evidenced by the Memory Controller returning CCIF to 1). Some commands return information to the FCCOB register array. The generic format for the FCCOB parameter fields in NVM command mode is shown in Table 19-24. The return values are available for reading after the CCIF flag in the FSTAT register has been returned to 1 by the Memory Controller. Writes to the unimplemented parameter fields (CCOBIX = 110 and CCOBIX = 111) are ignored with reads from these fields returning 0x0000. Table 19-24 shows the generic Flash command format. The high byte of the first word in the CCOB array contains the command code, followed by the parameters for this specific Flash command. For details on the FCCOB settings required by each command, see the Flash command descriptions in Section 19.4.2. Table 19-24. FCCOB - NVM Command Mode (Typical Usage) CCOBIX[2:0] 000 LO HI 001 LO HI 010 LO HI 011 LO HI 100 LO HI 101 LO Data 3 [7:0] Data 2 [7:0] Data 3 [15:8] Data 1 [7:0] Data 2 [15:8] Data 0 [7:0] Data 1 [15:8] Global address [7:0] Data 0 [15:8] 0, Global address [22:16] Global address [15:8] Byte HI FCCOB Parameter Fields (NVM Command Mode) FCMD[7:0] defining Flash command 19.3.2.12 Flash Reserved0 Register (FRSV0) This Flash register is reserved for factory testing. Offset Module Base + 0x000C 7 6 5 4 3 2 1 0 R W Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = Unimplemented or Reserved Figure 19-18. Flash Reserved0 Register (FRSV0) All bits in the FRSV0 register read 0 and are not writable. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 579 128 KByte Flash Module (S12XFTMR128K1V1) 19.3.2.13 Flash Reserved1 Register (FRSV1) This Flash register is reserved for factory testing. Offset Module Base + 0x000D 7 6 5 4 3 2 1 0 R W Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = Unimplemented or Reserved Figure 19-19. Flash Reserved1 Register (FRSV1) All bits in the FRSV1 register read 0 and are not writable. 19.3.2.14 Flash ECC Error Results Register (FECCR) The FECCR registers contain the result of a detected ECC fault for both single bit and double bit faults. The FECCR register provides access to several ECC related fields as defined by the ECCRIX index bits in the FECCRIX register (see Section 19.3.2.4). Once ECC fault information has been stored, no other fault information will be recorded until the specific ECC fault flag has been cleared. In the event of simultaneous ECC faults the priority for fault recording is double bit fault over single bit fault. Offset Module Base + 0x000E 7 6 5 4 3 2 1 0 R W Reset 0 0 0 0 ECCR[15:8] 0 0 0 0 = Unimplemented or Reserved Figure 19-20. Flash ECC Error Results High Register (FECCRHI) Offset Module Base + 0x000F 7 6 5 4 3 2 1 0 R W Reset 0 0 0 0 ECCR[7:0] 0 0 0 0 = Unimplemented or Reserved Figure 19-21. Flash ECC Error Results Low Register (FECCRLO) All FECCR bits are readable but not writable. S12XS Family Reference Manual, Rev. 1.09 580 Freescale Semiconductor 128 KByte Flash Module (S12XFTMR128K1V1) Table 19-25. FECCR Index Settings ECCRIX[2:0] Bits [15:8] 000 001 010 011 100 101 110 111 Parity bits read from Flash block FECCR Register Content Bit[7] 0 Global address [15:0] Data 0 [15:0] Data 1 [15:0] (P-Flash only) Data 2 [15:0] (P-Flash only) Data 3 [15:0] (P-Flash only) Not used, returns 0x0000 when read Not used, returns 0x0000 when read Bits[6:0] Global address [22:16] Table 19-26. FECCR Index=000 Bit Descriptions Field 15:8 PAR[7:0] Description ECC Parity Bits — Contains the 8 parity bits from the 72 bit wide P-Flash data word or the 6 parity bits, allocated to PAR[5:0], from the 22 bit wide D-Flash word with PAR[7:6]=00. 6–0 Global Address — The GADDR[22:16] field contains the upper seven bits of the global address having GADDR[22:16] caused the error. The P-Flash word addressed by ECCRIX = 001 contains the lower 16 bits of the global address. The following four words addressed by ECCRIX = 010 to 101 contain the 64-bit wide data phrase. The four data words and the parity byte are the uncorrected data read from the P-Flash block. The D-Flash word addressed by ECCRIX = 001 contains the lower 16 bits of the global address. The uncorrected 16-bit data word is addressed by ECCRIX = 010. 19.3.2.15 Flash Option Register (FOPT) The FOPT register is the Flash option register. Offset Module Base + 0x0010 7 6 5 4 3 2 1 0 R W Reset F F F F NV[7:0] F F F F = Unimplemented or Reserved Figure 19-22. Flash Option Register (FOPT) All bits in the FOPT register are readable but are not writable. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 581 128 KByte Flash Module (S12XFTMR128K1V1) During the reset sequence, the FOPT register is loaded from the Flash nonvolatile byte in the Flash configuration field at global address 0x7F_FF0E located in P-Flash memory (see Table 19-3) as indicated by reset condition F in Figure 19-22. If a double bit fault is detected while reading the P-Flash phrase containing the Flash nonvolatile byte during the reset sequence, all bits in the FOPT register will be set. Table 19-27. FOPT Field Descriptions Field 7–0 NV[7:0] Description Nonvolatile Bits — The NV[7:0] bits are available as nonvolatile bits. Refer to the device user guide for proper use of the NV bits. 19.3.2.16 Flash Reserved2 Register (FRSV2) This Flash register is reserved for factory testing. Offset Module Base + 0x0011 7 6 5 4 3 2 1 0 R W Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = Unimplemented or Reserved Figure 19-23. Flash Reserved2 Register (FRSV2) All bits in the FRSV2 register read 0 and are not writable. 19.3.2.17 Flash Reserved3 Register (FRSV3) This Flash register is reserved for factory testing. Offset Module Base + 0x0012 7 6 5 4 3 2 1 0 R W Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = Unimplemented or Reserved Figure 19-24. Flash Reserved3 Register (FRSV3) All bits in the FRSV3 register read 0 and are not writable. 19.3.2.18 Flash Reserved4 Register (FRSV4) This Flash register is reserved for factory testing. S12XS Family Reference Manual, Rev. 1.09 582 Freescale Semiconductor 128 KByte Flash Module (S12XFTMR128K1V1) Offset Module Base + 0x0013 7 6 5 4 3 2 1 0 R W Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = Unimplemented or Reserved Figure 19-25. Flash Reserved4 Register (FRSV4) All bits in the FRSV4 register read 0 and are not writable. 19.4 19.4.1 Functional Description Flash Command Operations Flash command operations are used to modify Flash memory contents. The next sections describe: • How to write the FCLKDIV register that is used to generate a time base (FCLK) derived from OSCCLK for Flash program and erase command operations • The command write sequence used to set Flash command parameters and launch execution • Valid Flash commands available for execution 19.4.1.1 Writing the FCLKDIV Register Prior to issuing any Flash program or erase command after a reset, the user is required to write the FCLKDIV register to divide OSCCLK down to a target FCLK of 1 MHz. Table 19-7 shows recommended values for the FDIV field based on OSCCLK frequency. NOTE Programming or erasing the Flash memory cannot be performed if the bus clock runs at less than 1 MHz. Setting FDIV too high can destroy the Flash memory due to overstress. Setting FDIV too low can result in incomplete programming or erasure of the Flash memory cells. When the FCLKDIV register is written, the FDIVLD bit is set automatically. If the FDIVLD bit is 0, the FCLKDIV register has not been written since the last reset. If the FCLKDIV register has not been written, any Flash program or erase command loaded during a command write sequence will not execute and the ACCERR bit in the FSTAT register will set. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 583 128 KByte Flash Module (S12XFTMR128K1V1) 19.4.1.2 Command Write Sequence The Memory Controller will launch all valid Flash commands entered using a command write sequence. Before launching a command, the ACCERR and FPVIOL bits in the FSTAT register must be clear (see Section 19.3.2.7) and the CCIF flag should be tested to determine the status of the current command write sequence. If CCIF is 0, the previous command write sequence is still active, a new command write sequence cannot be started, and all writes to the FCCOB register are ignored. CAUTION Writes to any Flash register must be avoided while a Flash command is active (CCIF=0) to prevent corruption of Flash register contents and Memory Controller behavior. 19.4.1.2.1 Define FCCOB Contents The FCCOB parameter fields must be loaded with all required parameters for the Flash command being executed. Access to the FCCOB parameter fields is controlled via the CCOBIX bits in the FCCOBIX register (see Section 19.3.2.3). The contents of the FCCOB parameter fields are transferred to the Memory Controller when the user clears the CCIF command completion flag in the FSTAT register (writing 1 clears the CCIF to 0). The CCIF flag will remain clear until the Flash command has completed. Upon completion, the Memory Controller will return CCIF to 1 and the FCCOB register will be used to communicate any results. The flow for a generic command write sequence is shown in Figure 19-26. S12XS Family Reference Manual, Rev. 1.09 584 Freescale Semiconductor 128 KByte Flash Module (S12XFTMR128K1V1) START Read: FCLKDIV register Clock Register Written Check FDIVLD Set? yes no Write: FCLKDIV register Read: FSTAT register Note: FCLKDIV must be set after each reset FCCOB Availability Check CCIF Set? yes no Results from previous Command yes Write: FSTAT register Clear ACCERR/FPVIOL 0x30 Access Error and Protection Violation Check ACCERR/ FPVIOL Set? no Write to FCCOBIX register to identify specific command parameter to load. Write to FCCOB register to load required command parameter. More Parameters? no yes Write: FSTAT register (to launch command) Clear CCIF 0x80 Read: FSTAT register Bit Polling for Command Completion Check CCIF Set? yes EXIT no Figure 19-26. Generic Flash Command Write Sequence Flowchart S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 585 128 KByte Flash Module (S12XFTMR128K1V1) 19.4.1.3 Valid Flash Module Commands Table 19-28. Flash Commands by Mode Unsecured FCMD 0x01 0x02 0x03 0x04 0x06 0x07 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x10 0x11 0x12 1 2 3 4 5 6 7 8 Secured ST4 ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ NS5 ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ NX6 ∗ ∗ SS7 ∗ ∗ ST8 ∗ ∗ Command Erase Verify All Blocks Erase Verify Block Erase Verify P-Flash Section Read Once Program P-Flash Program Once Erase All Blocks Erase Flash Block Erase P-Flash Sector Unsecure Flash Verify Backdoor Access Key Set User Margin Level Set Field Margin Level Erase Verify D-Flash Section Program D-Flash Erase D-Flash Sector NS1 ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ NX2 ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ SS3 ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ Unsecured Normal Single Chip mode. Unsecured Normal Expanded mode. Unsecured Special Single Chip mode. Unsecured Special Mode. Secured Normal Single Chip mode. Secured Normal Expanded mode. Secured Special Single Chip mode. Secured Special Mode. 19.4.1.4 P-Flash Commands Table 19-29 summarizes the valid P-Flash commands along with the effects of the commands on the P-Flash block and other resources within the Flash module. S12XS Family Reference Manual, Rev. 1.09 586 Freescale Semiconductor 128 KByte Flash Module (S12XFTMR128K1V1) Table 19-29. P-Flash Commands FCMD 0x01 0x02 0x03 0x04 0x06 0x07 Command Erase Verify All Blocks Erase Verify Block Erase Verify P-Flash Section Read Once Program P-Flash Program Once Function on P-Flash Memory Verify that all P-Flash (and D-Flash) blocks are erased. Verify that a P-Flash block is erased. Verify that a given number of words starting at the address provided are erased. Read a dedicated 64 byte field in the nonvolatile information register in P-Flash block 0 that was previously programmed using the Program Once command. Program a phrase in a P-Flash block. Program a dedicated 64 byte field in the nonvolatile information register in P-Flash block 0 that is allowed to be programmed only once. Erase all P-Flash (and D-Flash) blocks. An erase of all Flash blocks is only possible when the FPLDIS, FPHDIS, and FPOPEN bits in the FPROT register and the DPOPEN bit in the DFPROT register are set prior to launching the command. Erase a P-Flash (or D-Flash) block. An erase of the full P-Flash block is only possible when FPLDIS, FPHDIS and FPOPEN bits in the FPROT register are set prior to launching the command. Erase all bytes in a P-Flash sector. Supports a method of releasing MCU security by erasing all P-Flash (and D-Flash) blocks and verifying that all P-Flash (and D-Flash) blocks are erased. Supports a method of releasing MCU security by verifying a set of security keys. Specifies a user margin read level for all P-Flash blocks. Specifies a field margin read level for all P-Flash blocks (special modes only). 0x08 Erase All Blocks 0x09 Erase Flash Block Erase P-Flash Sector Unsecure Flash Verify Backdoor Access Key Set User Margin Level Set Field Margin Level 0x0A 0x0B 0x0C 0x0D 0x0E 19.4.1.5 D-Flash Commands Table 19-30 summarizes the valid D-Flash commands along with the effects of the commands on the D-Flash block. Table 19-30. D-Flash Commands FCMD 0x01 0x02 Command Erase Verify All Blocks Erase Verify Block Function on D-Flash Memory Verify that all D-Flash (and P-Flash) blocks are erased. Verify that the D-Flash block is erased. Erase all D-Flash (and P-Flash) blocks. An erase of all Flash blocks is only possible when the FPLDIS, FPHDIS, and FPOPEN bits in the FPROT register and the DPOPEN bit in the DFPROT register are set prior to launching the command. Erase a D-Flash (or P-Flash) block. An erase of the full D-Flash block is only possible when DPOPEN bit in the DFPROT register is set prior to launching the command. 0x08 Erase All Blocks 0x09 Erase Flash Block S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 587 128 KByte Flash Module (S12XFTMR128K1V1) Table 19-30. D-Flash Commands FCMD 0x0B 0x0D 0x0E 0x10 0x11 0x12 Command Unsecure Flash Set User Margin Level Set Field Margin Level Erase Verify D-Flash Section Program D-Flash Erase D-Flash Sector Function on D-Flash Memory Supports a method of releasing MCU security by erasing all D-Flash (and P-Flash) blocks and verifying that all D-Flash (and P-Flash) blocks are erased. Specifies a user margin read level for the D-Flash block. Specifies a field margin read level for the D-Flash block (special modes only). Verify that a given number of words starting at the address provided are erased. Program up to four words in the D-Flash block. Erase all bytes in a sector of the D-Flash block. 19.4.2 Flash Command Description This section provides details of all available Flash commands launched by a command write sequence. The ACCERR bit in the FSTAT register will be set during the command write sequence if any of the following illegal steps are performed, causing the command not to be processed by the Memory Controller: • Starting any command write sequence that programs or erases Flash memory before initializing the FCLKDIV register • Writing an invalid command as part of the command write sequence • For additional possible errors, refer to the error handling table provided for each command If a Flash block is read during execution of an algorithm (CCIF = 0) on that same block, the read operation will return invalid data. If the SFDIF or DFDIF flags were not previously set when the invalid read operation occurred, both the SFDIF and DFDIF flags will be set and the FECCR registers will be loaded with the global address used in the invalid read operation with the data and parity fields set to all 0. If the ACCERR or FPVIOL bits are set in the FSTAT register, the user must clear these bits before starting any command write sequence (see Section 19.3.2.7). CAUTION A Flash word or phrase must be in the erased state before being programmed. Cumulative programming of bits within a Flash word or phrase is not allowed. 19.4.2.1 Erase Verify All Blocks Command Table 19-31. Erase Verify All Blocks Command FCCOB Requirements CCOBIX[2:0] 000 0x01 FCCOB Parameters Not required The Erase Verify All Blocks command will verify that all P-Flash and D-Flash blocks have been erased. S12XS Family Reference Manual, Rev. 1.09 588 Freescale Semiconductor 128 KByte Flash Module (S12XFTMR128K1V1) Upon clearing CCIF to launch the Erase Verify All Blocks command, the Memory Controller will verify that the entire Flash memory space is erased. The CCIF flag will set after the Erase Verify All Blocks operation has completed. Table 19-32. Erase Verify All Blocks Command Error Handling Register Error Bit ACCERR FPVIOL FSTAT MGSTAT1 MGSTAT0 Error Condition Set if CCOBIX[2:0] != 000 at command launch None Set if any errors have been encountered during the read Set if any non-correctable errors have been encountered during the read 19.4.2.2 Erase Verify Block Command The Erase Verify Block command allows the user to verify that an entire P-Flash or D-Flash block has been erased. The FCCOB upper global address bits determine which block must be verified. Table 19-33. Erase Verify Block Command FCCOB Requirements CCOBIX[2:0] 000 0x02 FCCOB Parameters Global address [22:16] of the Flash block to be verified. Upon clearing CCIF to launch the Erase Verify Block command, the Memory Controller will verify that the selected P-Flash or D-Flash block is erased. The CCIF flag will set after the Erase Verify Block operation has completed. Table 19-34. Erase Verify Block Command Error Handling Register Error Bit ACCERR Set if an invalid global address [22:16] is supplied FSTAT FPVIOL MGSTAT1 MGSTAT0 None Set if any errors have been encountered during the read Set if any non-correctable errors have been encountered during the read Error Condition Set if CCOBIX[2:0] != 000 at command launch 19.4.2.3 Erase Verify P-Flash Section Command The Erase Verify P-Flash Section command will verify that a section of code in the P-Flash memory is erased. The Erase Verify P-Flash Section command defines the starting point of the code to be verified and the number of phrases. The section to be verified cannot cross a 128 Kbyte boundary in the P-Flash memory space. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 589 128 KByte Flash Module (S12XFTMR128K1V1) Table 19-35. Erase Verify P-Flash Section Command FCCOB Requirements CCOBIX[2:0] 000 001 010 0x03 FCCOB Parameters Global address [22:16] of a P-Flash block Global address [15:0] of the first phrase to be verified Number of phrases to be verified Upon clearing CCIF to launch the Erase Verify P-Flash Section command, the Memory Controller will verify the selected section of Flash memory is erased. The CCIF flag will set after the Erase Verify P-Flash Section operation has completed. Table 19-36. Erase Verify P-Flash Section Command Error Handling Register Error Bit Error Condition Set if CCOBIX[2:0] != 010 at command launch Set if command not available in current mode (see Table 19-28) ACCERR FSTAT Set if the requested section crosses a 128 Kbyte boundary FPVIOL MGSTAT1 MGSTAT0 None Set if any errors have been encountered during the read Set if any non-correctable errors have been encountered during the read Set if an invalid global address [22:0] is supplied Set if a misaligned phrase address is supplied (global address [2:0] != 000) 19.4.2.4 Read Once Command The Read Once command provides read access to a reserved 64 byte field (8 phrases) located in the nonvolatile information register of P-Flash block 0. The Read Once field is programmed using the Program Once command described in Section 19.4.2.6. The Read Once command must not be executed from the Flash block containing the Program Once reserved field to avoid code runaway. Table 19-37. Read Once Command FCCOB Requirements CCOBIX[2:0] 000 001 010 011 100 101 0x04 FCCOB Parameters Not Required Read Once phrase index (0x0000 - 0x0007) Read Once word 0 value Read Once word 1 value Read Once word 2 value Read Once word 3 value Upon clearing CCIF to launch the Read Once command, a Read Once phrase is fetched and stored in the FCCOB indexed register. The CCIF flag will set after the Read Once operation has completed. Valid S12XS Family Reference Manual, Rev. 1.09 590 Freescale Semiconductor 128 KByte Flash Module (S12XFTMR128K1V1) phrase index values for the Read Once command range from 0x0000 to 0x0007. During execution of the Read Once command, any attempt to read addresses within P-Flash block will return invalid data. Table 19-38. Read Once Command Error Handling Register Error Bit Error Condition Set if CCOBIX[2:0] != 001 at command launch ACCERR FSTAT FPVIOL MGSTAT1 MGSTAT0 None Set if any errors have been encountered during the read Set if any non-correctable errors have been encountered during the read Set if command not available in current mode (see Table 19-28) Set if an invalid phrase index is supplied 19.4.2.5 Program P-Flash Command The Program P-Flash operation will program a previously erased phrase in the P-Flash memory using an embedded algorithm. CAUTION A P-Flash phrase must be in the erased state before being programmed. Cumulative programming of bits within a Flash phrase is not allowed. Table 19-39. Program P-Flash Command FCCOB Requirements CCOBIX[2:0] 000 001 010 011 100 101 1 FCCOB Parameters 0x06 Global address [22:16] to identify P-Flash block Global address [15:0] of phrase location to be programmed1 Word 0 program value Word 1 program value Word 2 program value Word 3 program value Global address [2:0] must be 000 Upon clearing CCIF to launch the Program P-Flash command, the Memory Controller will program the data words to the supplied global address and will then proceed to verify the data words read back as expected. The CCIF flag will set after the Program P-Flash operation has completed. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 591 128 KByte Flash Module (S12XFTMR128K1V1) Table 19-40. Program P-Flash Command Error Handling Register Error Bit Error Condition Set if CCOBIX[2:0] != 101 at command launch Set if command not available in current mode (see Table 19-28) ACCERR Set if an invalid global address [22:0] is supplied FSTAT FPVIOL MGSTAT1 MGSTAT0 Set if a misaligned phrase address is supplied (global address [2:0] != 000) Set if the global address [22:0] points to a protected area Set if any errors have been encountered during the verify operation Set if any non-correctable errors have been encountered during the verify operation 19.4.2.6 Program Once Command The Program Once command restricts programming to a reserved 64 byte field (8 phrases) in the nonvolatile information register located in P-Flash block 0. The Program Once reserved field can be read using the Read Once command as described in Section 19.4.2.4. The Program Once command must only be issued once since the nonvolatile information register in P-Flash block 0 cannot be erased. The Program Once command must not be executed from the Flash block containing the Program Once reserved field to avoid code runaway. Table 19-41. Program Once Command FCCOB Requirements CCOBIX[2:0] 000 001 010 011 100 101 0x07 FCCOB Parameters Not Required Program Once phrase index (0x0000 - 0x0007) Program Once word 0 value Program Once word 1 value Program Once word 2 value Program Once word 3 value Upon clearing CCIF to launch the Program Once command, the Memory Controller first verifies that the selected phrase is erased. If erased, then the selected phrase will be programmed and then verified with read back. The CCIF flag will remain clear, setting only after the Program Once operation has completed. The reserved nonvolatile information register accessed by the Program Once command cannot be erased and any attempt to program one of these phrases a second time will not be allowed. Valid phrase index values for the Program Once command range from 0x0000 to 0x0007. During execution of the Program Once command, any attempt to read addresses within P-Flash block 0 will return invalid data. S12XS Family Reference Manual, Rev. 1.09 592 Freescale Semiconductor 128 KByte Flash Module (S12XFTMR128K1V1) R, Table 19-42. Program Once Command Error Handling Register Error Bit Error Condition Set if CCOBIX[2:0] != 101 at command launch Set if command not available in current mode (see Table 19-28) ACCERR Set if an invalid phrase index is supplied FSTAT FPVIOL MGSTAT1 MGSTAT0 1 Set if the requested phrase has already been programmed1 None Set if any errors have been encountered during the verify operation Set if any non-correctable errors have been encountered during the verify operation If a Program Once phrase is initially programmed to 0xFFFF_FFFF_FFFF_FFFF, the Program Once command will be allowed to execute again on that same phrase. 19.4.2.7 Erase All Blocks Command Table 19-43. Erase All Blocks Command FCCOB Requirements CCOBIX[2:0] 000 0x08 FCCOB Parameters Not required The Erase All Blocks operation will erase the entire P-Flash and D-Flash memory space. Upon clearing CCIF to launch the Erase All Blocks command, the Memory Controller will erase the entire Flash memory space and verify that it is erased. If the Memory Controller verifies that the entire Flash memory space was properly erased, security will be released. During the execution of this command (CCIF=0) the user must not write to any Flash module register. The CCIF flag will set after the Erase All Blocks operation has completed. Table 19-44. Erase All Blocks Command Error Handling Register Error Bit ACCERR Set if command not available in current mode (see Table 19-28) FSTAT FPVIOL MGSTAT1 MGSTAT0 Set if any area of the P-Flash or D-Flash memory is protected Set if any errors have been encountered during the verify operation Set if any non-correctable errors have been encountered during the verify operation Error Condition Set if CCOBIX[2:0] != 000 at command launch 19.4.2.8 Erase Flash Block Command The Erase Flash Block operation will erase all addresses in a P-Flash or D-Flash block. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 593 128 KByte Flash Module (S12XFTMR128K1V1) Table 19-45. Erase Flash Block Command FCCOB Requirements CCOBIX[2:0] 000 001 0x09 FCCOB Parameters Global address [22:16] to identify Flash block Global address [15:0] in Flash block to be erased Upon clearing CCIF to launch the Erase Flash Block command, the Memory Controller will erase the selected Flash block and verify that it is erased. The CCIF flag will set after the Erase Flash Block operation has completed. Table 19-46. Erase Flash Block Command Error Handling Register Error Bit Error Condition Set if CCOBIX[2:0] != 001 at command launch Set if command not available in current mode (see Table 19-28) ACCERR Set if an invalid global address [22:16] is supplied Set if the supplied P-Flash address is not phrase-aligned or if the D-Flash address is not word-aligned FPVIOL MGSTAT1 MGSTAT0 Set if an area of the selected Flash block is protected Set if any errors have been encountered during the verify operation Set if any non-correctable errors have been encountered during the verify operation FSTAT 19.4.2.9 Erase P-Flash Sector Command Table 19-47. Erase P-Flash Sector Command FCCOB Requirements CCOBIX[2:0] 000 001 0x0A FCCOB Parameters Global address [22:16] to identify P-Flash block to be erased The Erase P-Flash Sector operation will erase all addresses in a P-Flash sector. Global address [15:0] anywhere within the sector to be erased. Refer to Section 19.1.2.1 for the P-Flash sector size. Upon clearing CCIF to launch the Erase P-Flash Sector command, the Memory Controller will erase the selected Flash sector and then verify that it is erased. The CCIF flag will be set after the Erase P-Flash Sector operation has completed. S12XS Family Reference Manual, Rev. 1.09 594 Freescale Semiconductor 128 KByte Flash Module (S12XFTMR128K1V1) Table 19-48. Erase P-Flash Sector Command Error Handling Register Error Bit Error Condition Set if CCOBIX[2:0] != 001 at command launch Set if command not available in current mode (see Table 19-28) ACCERR Set if an invalid global address [22:16] is supplied FSTAT FPVIOL MGSTAT1 MGSTAT0 Set if a misaligned phrase address is supplied (global address [2:0] != 000) Set if the selected P-Flash sector is protected Set if any errors have been encountered during the verify operation Set if any non-correctable errors have been encountered during the verify operation 19.4.2.10 Unsecure Flash Command The Unsecure Flash command will erase the entire P-Flash and D-Flash memory space and, if the erase is successful, will release security. Table 19-49. Unsecure Flash Command FCCOB Requirements CCOBIX[2:0] 000 0x0B FCCOB Parameters Not required Upon clearing CCIF to launch the Unsecure Flash command, the Memory Controller will erase the entire P-Flash and D-Flash memory space and verify that it is erased. If the Memory Controller verifies that the entire Flash memory space was properly erased, security will be released. If the erase verify is not successful, the Unsecure Flash operation sets MGSTAT1 and terminates without changing the security state. During the execution of this command (CCIF=0) the user must not write to any Flash module register. The CCIF flag is set after the Unsecure Flash operation has completed. Table 19-50. Unsecure Flash Command Error Handling Register Error Bit ACCERR Set if command not available in current mode (see Table 19-28) FSTAT FPVIOL MGSTAT1 MGSTAT0 Set if any area of the P-Flash or D-Flash memory is protected Set if any errors have been encountered during the verify operation Set if any non-correctable errors have been encountered during the verify operation Error Condition Set if CCOBIX[2:0] != 000 at command launch 19.4.2.11 Verify Backdoor Access Key Command The Verify Backdoor Access Key command will only execute if it is enabled by the KEYEN bits in the FSEC register (see Table 19-9). The Verify Backdoor Access Key command releases security if user-supplied keys match those stored in the Flash security bytes of the Flash configuration field (see S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 595 128 KByte Flash Module (S12XFTMR128K1V1) Table 19-3). The Verify Backdoor Access Key command must not be executed from the Flash block containing the backdoor comparison key to avoid code runaway. Table 19-51. Verify Backdoor Access Key Command FCCOB Requirements CCOBIX[2:0] 000 001 010 011 100 0x0C Key 0 Key 1 Key 2 Key 3 FCCOB Parameters Not required Upon clearing CCIF to launch the Verify Backdoor Access Key command, the Memory Controller will check the FSEC KEYEN bits to verify that this command is enabled. If not enabled, the Memory Controller sets the ACCERR bit in the FSTAT register and terminates. If the command is enabled, the Memory Controller compares the key provided in FCCOB to the backdoor comparison key in the Flash configuration field with Key 0 compared to 0x7F_FF00, etc. If the backdoor keys match, security will be released. If the backdoor keys do not match, security is not released and all future attempts to execute the Verify Backdoor Access Key command are aborted (set ACCERR) until a reset occurs. The CCIF flag is set after the Verify Backdoor Access Key operation has completed. Table 19-52. Verify Backdoor Access Key Command Error Handling Register Error Bit Error Condition Set if CCOBIX[2:0] != 100 at command launch Set if an incorrect backdoor key is supplied ACCERR FSTAT FPVIOL MGSTAT1 MGSTAT0 Set if backdoor key access has not been enabled (KEYEN[1:0] != 10, see Section 19.3.2.2) Set if the backdoor key has mismatched since the last reset None None None 19.4.2.12 Set User Margin Level Command The Set User Margin Level command causes the Memory Controller to set the margin level for future read operations of a specific P-Flash or D-Flash block. Table 19-53. Set User Margin Level Command FCCOB Requirements CCOBIX[2:0] 000 001 0x0D FCCOB Parameters Global address [22:16] to identify the Flash block Margin level setting S12XS Family Reference Manual, Rev. 1.09 596 Freescale Semiconductor 128 KByte Flash Module (S12XFTMR128K1V1) Upon clearing CCIF to launch the Set User Margin Level command, the Memory Controller will set the user margin level for the targeted block and then set the CCIF flag. Valid margin level settings for the Set User Margin Level command are defined in Table 19-54. Table 19-54. Valid Set User Margin Level Settings CCOB (CCOBIX=001) 0x0000 0x0001 0x0002 1 2 Level Description Return to Normal Level User Margin-1 Level1 User Margin-0 Level2 Read margin to the erased state Read margin to the programmed state Table 19-55. Set User Margin Level Command Error Handling Register Error Bit Error Condition Set if CCOBIX[2:0] != 001 at command launch Set if command not available in current mode (see Table 19-28) ACCERR Set if an invalid global address [22:16] is supplied FSTAT FPVIOL MGSTAT1 MGSTAT0 Set if an invalid margin level setting is supplied None None None NOTE User margin levels can be used to check that Flash memory contents have adequate margin for normal level read operations. If unexpected results are encountered when checking Flash memory contents at user margin levels, a potential loss of information has been detected. 19.4.2.13 Set Field Margin Level Command The Set Field Margin Level command, valid in special modes only, causes the Memory Controller to set the margin level specified for future read operations of a specific P-Flash or D-Flash block. Table 19-56. Set Field Margin Level Command FCCOB Requirements CCOBIX[2:0] 000 001 0x0E FCCOB Parameters Global address [22:16] to identify the Flash block Margin level setting S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 597 128 KByte Flash Module (S12XFTMR128K1V1) Upon clearing CCIF to launch the Set Field Margin Level command, the Memory Controller will set the field margin level for the targeted block and then set the CCIF flag. Valid margin level settings for the Set Field Margin Level command are defined in Table 19-57. Table 19-57. Valid Set Field Margin Level Settings CCOB (CCOBIX=001) 0x0000 0x0001 0x0002 0x0003 0x0004 1 2 Level Description Return to Normal Level User Margin-1 Level1 User Margin-0 Level2 Field Margin-1 Level1 Field Margin-0 Level2 Read margin to the erased state Read margin to the programmed state Table 19-58. Set Field Margin Level Command Error Handling Register Error Bit Error Condition Set if CCOBIX[2:0] != 001 at command launch Set if command not available in current mode (see Table 19-28) ACCERR Set if an invalid global address [22:16] is supplied FSTAT FPVIOL MGSTAT1 MGSTAT0 Set if an invalid margin level setting is supplied None None None CAUTION Field margin levels must only be used during verify of the initial factory programming. NOTE Field margin levels can be used to check that Flash memory contents have adequate margin for data retention at the normal level setting. If unexpected results are encountered when checking Flash memory contents at field margin levels, the Flash memory contents should be erased and reprogrammed. 19.4.2.14 Erase Verify D-Flash Section Command The Erase Verify D-Flash Section command will verify that a section of code in the D-Flash is erased. The Erase Verify D-Flash Section command defines the starting point of the data to be verified and the number of words. S12XS Family Reference Manual, Rev. 1.09 598 Freescale Semiconductor 128 KByte Flash Module (S12XFTMR128K1V1) Table 19-59. Erase Verify D-Flash Section Command FCCOB Requirements CCOBIX[2:0] 000 001 010 0x10 FCCOB Parameters Global address [22:16] to identify the D-Flash block Global address [15:0] of the first word to be verified Number of words to be verified Upon clearing CCIF to launch the Erase Verify D-Flash Section command, the Memory Controller will verify the selected section of D-Flash memory is erased. The CCIF flag will set after the Erase Verify D-Flash Section operation has completed. Table 19-60. Erase Verify D-Flash Section Command Error Handling Register Error Bit Error Condition Set if CCOBIX[2:0] != 010 at command launch Set if command not available in current mode (see Table 19-28) ACCERR FSTAT Set if the requested section breaches the end of the D-Flash block FPVIOL MGSTAT1 MGSTAT0 None Set if any errors have been encountered during the read Set if any non-correctable errors have been encountered during the read Set if an invalid global address [22:0] is supplied Set if a misaligned word address is supplied (global address [0] != 0) 19.4.2.15 Program D-Flash Command The Program D-Flash operation programs one to four previously erased words in the D-Flash block. The Program D-Flash operation will confirm that the targeted location(s) were successfully programmed upon completion. CAUTION A Flash word must be in the erased state before being programmed. Cumulative programming of bits within a Flash word is not allowed. Table 19-61. Program D-Flash Command FCCOB Requirements CCOBIX[2:0] 000 001 010 011 100 0x11 FCCOB Parameters Global address [22:16] to identify the D-Flash block Global address [15:0] of word to be programmed Word 0 program value Word 1 program value, if desired Word 2 program value, if desired S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 599 128 KByte Flash Module (S12XFTMR128K1V1) Table 19-61. Program D-Flash Command FCCOB Requirements CCOBIX[2:0] 101 FCCOB Parameters Word 3 program value, if desired Upon clearing CCIF to launch the Program D-Flash command, the user-supplied words will be transferred to the Memory Controller and be programmed if the area is unprotected. The CCOBIX index value at Program D-Flash command launch determines how many words will be programmed in the D-Flash block. The CCIF flag is set when the operation has completed. Table 19-62. Program D-Flash Command Error Handling Register Error Bit Error Condition Set if CCOBIX[2:0] < 010 at command launch Set if CCOBIX[2:0] > 101 at command launch Set if command not available in current mode (see Table 19-28) ACCERR Set if an invalid global address [22:0] is supplied FSTAT FPVIOL MGSTAT1 MGSTAT0 Set if a misaligned word address is supplied (global address [0] != 0) Set if the requested group of words breaches the end of the D-Flash block Set if the selected area of the D-Flash memory is protected Set if any errors have been encountered during the verify operation Set if any non-correctable errors have been encountered during the verify operation 19.4.2.16 Erase D-Flash Sector Command The Erase D-Flash Sector operation will erase all addresses in a sector of the D-Flash block. Table 19-63. Erase D-Flash Sector Command FCCOB Requirements CCOBIX[2:0] 000 001 0x12 FCCOB Parameters Global address [22:16] to identify D-Flash block Global address [15:0] anywhere within the sector to be erased. See Section 19.1.2.2 for D-Flash sector size. Upon clearing CCIF to launch the Erase D-Flash Sector command, the Memory Controller will erase the selected Flash sector and verify that it is erased. The CCIF flag will set after the Erase D-Flash Sector operation has completed. S12XS Family Reference Manual, Rev. 1.09 600 Freescale Semiconductor 128 KByte Flash Module (S12XFTMR128K1V1) Table 19-64. Erase D-Flash Sector Command Error Handling Register Error Bit Error Condition Set if CCOBIX[2:0] != 001 at command launch Set if command not available in current mode (see Table 19-28) ACCERR Set if an invalid global address [22:0] is supplied FSTAT FPVIOL MGSTAT1 MGSTAT0 Set if a misaligned word address is supplied (global address [0] != 0) Set if the selected area of the D-Flash memory is protected Set if any errors have been encountered during the verify operation Set if any non-correctable errors have been encountered during the verify operation 19.4.3 Interrupts The Flash module can generate an interrupt when a Flash command operation has completed or when a Flash command operation has detected an ECC fault. Table 19-65. Flash Interrupt Sources Interrupt Source Flash Command Complete ECC Double Bit Fault on Flash Read ECC Single Bit Fault on Flash Read Interrupt Flag CCIF (FSTAT register) DFDIF (FERSTAT register) SFDIF (FERSTAT register) Local Enable CCIE (FCNFG register) DFDIE (FERCNFG register) SFDIE (FERCNFG register) Global (CCR) Mask I Bit I Bit I Bit NOTE Vector addresses and their relative interrupt priority are determined at the MCU level. 19.4.3.1 Description of Flash Interrupt Operation The Flash module uses the CCIF flag in combination with the CCIE interrupt enable bit to generate the Flash command interrupt request. The Flash module uses the DFDIF and SFDIF flags in combination with the DFDIE and SFDIE interrupt enable bits to generate the Flash error interrupt request. For a detailed description of the register bits involved, refer to Section 19.3.2.5, “Flash Configuration Register (FCNFG)”, Section 19.3.2.6, “Flash Error Configuration Register (FERCNFG)”, Section 19.3.2.7, “Flash Status Register (FSTAT)”, and Section 19.3.2.8, “Flash Error Status Register (FERSTAT)”. The logic used for generating the Flash module interrupts is shown in Figure 19-27. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 601 128 KByte Flash Module (S12XFTMR128K1V1) CCIE CCIF Flash Command Interrupt Request DFDIE DFDIF SFDIE SFDIF Flash Error Interrupt Request Figure 19-27. Flash Module Interrupts Implementation 19.4.4 Wait Mode The Flash module is not affected if the MCU enters wait mode. The Flash module can recover the MCU from wait via the CCIF interrupt (see Section 19.4.3, “Interrupts”). 19.4.5 Stop Mode If a Flash command is active (CCIF = 0) when the MCU requests stop mode, the current Flash operation will be completed before the CPU is allowed to enter stop mode. 19.5 Security The Flash module provides security information to the MCU. The Flash security state is defined by the SEC bits of the FSEC register (see Table 19-10). During reset, the Flash module initializes the FSEC register using data read from the security byte of the Flash configuration field at global address 0x7F_FF0F. The security state out of reset can be permanently changed by programming the security byte of the Flash configuration field. This assumes that you are starting from a mode where the necessary P-Flash erase and program commands are available and that the upper region of the P-Flash is unprotected. If the Flash security byte is successfully programmed, its new value will take affect after the next MCU reset. The following subsections describe these security-related subjects: • Unsecuring the MCU using Backdoor Key Access • Unsecuring the MCU in Special Single Chip Mode using BDM • Mode and Security Effects on Flash Command Availability 19.5.1 Unsecuring the MCU using Backdoor Key Access The MCU may be unsecured by using the backdoor key access feature which requires knowledge of the contents of the backdoor keys (four 16-bit words programmed at addresses 0x7F_FF00–0x7F_FF07). If the KEYEN[1:0] bits are in the enabled state (see Section 19.3.2.2), the Verify Backdoor Access Key command (see Section 19.4.2.11) allows the user to present four prospective keys for comparison to the S12XS Family Reference Manual, Rev. 1.09 602 Freescale Semiconductor 128 KByte Flash Module (S12XFTMR128K1V1) keys stored in the Flash memory via the Memory Controller. If the keys presented in the Verify Backdoor Access Key command match the backdoor keys stored in the Flash memory, the SEC bits in the FSEC register (see Table 19-10) will be changed to unsecure the MCU. Key values of 0x0000 and 0xFFFF are not permitted as backdoor keys. While the Verify Backdoor Access Key command is active, P-Flash block 0 will not be available for read access and will return invalid data. The user code stored in the P-Flash memory must have a method of receiving the backdoor keys from an external stimulus. This external stimulus would typically be through one of the on-chip serial ports. If the KEYEN[1:0] bits are in the enabled state (see Section 19.3.2.2), the MCU can be unsecured by the backdoor key access sequence described below: 1. Follow the command sequence for the Verify Backdoor Access Key command as explained in Section 19.4.2.11 2. If the Verify Backdoor Access Key command is successful, the MCU is unsecured and the SEC[1:0] bits in the FSEC register are forced to the unsecure state of 10 The Verify Backdoor Access Key command is monitored by the Memory Controller and an illegal key will prohibit future use of the Verify Backdoor Access Key command. A reset of the MCU is the only method to re-enable the Verify Backdoor Access Key command. After the backdoor keys have been correctly matched, the MCU will be unsecured. After the MCU is unsecured, the sector containing the Flash security byte can be erased and the Flash security byte can be reprogrammed to the unsecure state, if desired. In the unsecure state, the user has full control of the contents of the backdoor keys by programming addresses 0x7F_FF00–0x7F_FF07 in the Flash configuration field. The security as defined in the Flash security byte (0x7F_FF0F) is not changed by using the Verify Backdoor Access Key command sequence. The backdoor keys stored in addresses 0x7F_FF00–0x7F_FF07 are unaffected by the Verify Backdoor Access Key command sequence. After the next reset of the MCU, the security state of the Flash module is determined by the Flash security byte (0x7F_FF0F). The Verify Backdoor Access Key command sequence has no effect on the program and erase protections defined in the Flash protection register, FPROT. 19.5.2 Unsecuring the MCU in Special Single Chip Mode using BDM The MCU can be unsecured in special single chip mode by erasing the P-Flash and D-Flash memory by one of the following methods: • Reset the MCU into special single chip mode, delay while the erase test is performed by the BDM, send BDM commands to disable protection in the P-Flash and D-Flash memory, and execute the Erase All Blocks command write sequence to erase the P-Flash and D-Flash memory. • Reset the MCU into special expanded wide mode, disable protection in the P-Flash and D-Flash memory and run code from external memory to execute the Erase All Blocks command write sequence to erase the P-Flash and D-Flash memory. After the CCIF flag sets to indicate that the Erase All Blocks operation has completed, reset the MCU into special single chip mode. The BDM will execute the Erase Verify All Blocks command write sequence to verify that the P-Flash and D-Flash memory is erased. If the P-Flash and D-Flash memory are verified as S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 603 128 KByte Flash Module (S12XFTMR128K1V1) erased the MCU will be unsecured. All BDM commands will be enabled and the Flash security byte may be programmed to the unsecure state by the following method: • Send BDM commands to execute a ‘Program P-Flash’ command sequence to program the Flash security byte to the unsecured state and reset the MCU. 19.5.3 Mode and Security Effects on Flash Command Availability The availability of Flash module commands depends on the MCU operating mode and security state as shown in Table 19-28. 19.6 Initialization On each system reset the Flash module executes a reset sequence which establishes initial values for the Flash Block Configuration Parameters, the FPROT and DFPROT protection registers, and the FOPT and FSEC registers. The Flash module reverts to built-in default values that leave the module in a fully protected and secured state if errors are encountered during execution of the reset sequence. If a double bit fault is detected during the reset sequence, both MGSTAT bits in the FSTAT register will be set. CCIF remains clear throughout the reset sequence. The Flash module holds off all CPU access for the initial portion of the reset sequence. While Flash reads are possible when the hold is removed, writes to the FCCOBIX, FCCOBHI, and FCCOBLO registers are ignored to prevent command activity while the Memory Controller remains busy. Completion of the reset sequence is marked by setting CCIF high which enables writes to the FCCOBIX, FCCOBHI, and FCCOBLO registers to launch any available Flash command. If a reset occurs while any Flash command is in progress, that command will be immediately aborted. The state of the word being programmed or the sector/block being erased is not guaranteed. S12XS Family Reference Manual, Rev. 1.09 604 Freescale Semiconductor Chapter 20 64 KByte Flash Module (S12XFTMR64K1V1) Table 20-1. Revision History Revision Number V01.04 V01.05 Revision Date 03 Jan 2008 19 Dec 2008 20.1/20-605 20.4.2.4/20-640 20.4.2.6/20-642 20.4.2.11/20-64 6 20.4.2.11/20-64 6 20.4.2.11/20-64 6 Sections Affected - Cosmetic changes - Clarify single bit fault correction for P-Flash phrase - Add statement concerning code runaway when executing Read Once, Program Once, and Verify Backdoor Access Key commands from Flash block containing associated fields - Relate Key 0 to associated Backdoor Comparison Key address - Change “power down reset” to “reset” in Section 20.4.2.11 Description of Changes V01.06 25 Sep 2009 The following changes were made to clarify module behavior related to Flash register access during reset sequence and while Flash commands are active: 20.3.2/20-613 - Add caution concerning register writes while command is active 20.3.2.1/20-615 - Writes to FCLKDIV are allowed during reset sequence while CCIF is clear 20.4.1.2/20-634 - Add caution concerning register writes while command is active - Writes to FCCOBIX, FCCOBHI, FCCOBLO registers are ignored during 20.6/20-654 reset sequence 20.1 Introduction The FTMR64K1 module implements the following: • 64 Kbytes of P-Flash (Program Flash) memory • 4 Kbytes of D-Flash (Data Flash) memory The Flash memory is ideal for single-supply applications allowing for field reprogramming without requiring external high voltage sources for program or erase operations. The Flash module includes a memory controller that executes commands to modify Flash memory contents. The user interface to the memory controller consists of the indexed Flash Common Command Object (FCCOB) register which is written to with the command, global address, data, and any required command parameters. The memory controller must complete the execution of a command before the FCCOB register can be written to with a new command. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor Preliminary 605 CAUTION A Flash word or phrase must be in the erased state before being programmed. Cumulative programming of bits within a Flash word or phrase is not allowed. The Flash memory may be read as bytes, aligned words, or misaligned words. Read access time is one bus cycle for bytes and aligned words, and two bus cycles for misaligned words. For Flash memory, an erased bit reads 1 and a programmed bit reads 0. It is not possible to read from a Flash block while any command is executing on that specific Flash block. It is possible to read from a Flash block while a command is executing on a different Flash block. Both P-Flash and D-Flash memories are implemented with Error Correction Codes (ECC) that can resolve single bit faults and detect double bit faults. For P-Flash memory, the ECC implementation requires that programming be done on an aligned 8 byte basis (a Flash phrase). Since P-Flash memory is always read by phrase, only one single bit fault in the phrase containing the byte or word accessed will be corrected. 20.1.1 Glossary Command Write Sequence — An MCU instruction sequence to execute built-in algorithms (including program and erase) on the Flash memory. D-Flash Memory — The D-Flash memory constitutes the nonvolatile memory store for data. D-Flash Sector — The D-Flash sector is the smallest portion of the D-Flash memory that can be erased. The D-Flash sector consists of four 64 byte rows for a total of 256 bytes. NVM Command Mode — An NVM mode using the CPU to setup the FCCOB register to pass parameters required for Flash command execution. Phrase — An aligned group of four 16-bit words within the P-Flash memory. Each phrase includes eight ECC bits for single bit fault correction and double bit fault detection within the phrase. P-Flash Memory — The P-Flash memory constitutes the main nonvolatile memory store for applications. P-Flash Sector — The P-Flash sector is the smallest portion of the P-Flash memory that can be erased. Each P-Flash sector contains 1024 bytes. Program IFR — Nonvolatile information register located in the P-Flash block that contains the Device ID, Version ID, and the Program Once field. The Program IFR is visible in the global memory map by setting the PGMIFRON bit in the MMCCTL1 register. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor Preliminary 606 64 KByte Flash Module (S12XFTMR64K1V1) 20.1.2 20.1.2.1 • • • • • Features P-Flash Features 64 Kbytes of P-Flash memory composed of one 64 Kbyte Flash block divided into 64 sectors of 1024 bytes Single bit fault correction and double bit fault detection within a 64-bit phrase during read operations Automated program and erase algorithm with verify and generation of ECC parity bits Fast sector erase and phrase program operation Flexible protection scheme to prevent accidental program or erase of P-Flash memory 20.1.2.2 • • • • • • D-Flash Features 4 Kbytes of D-Flash memory composed of one 4 Kbyte Flash block divided into 16 sectors of 256 bytes Single bit fault correction and double bit fault detection within a word during read operations Automated program and erase algorithm with verify and generation of ECC parity bits Fast sector erase and word program operation Protection scheme to prevent accidental program or erase of D-Flash memory Ability to program up to four words in a burst sequence 20.1.2.3 • • • Other Flash Module Features No external high-voltage power supply required for Flash memory program and erase operations Interrupt generation on Flash command completion and Flash error detection Security mechanism to prevent unauthorized access to the Flash memory S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 607 64 KByte Flash Module (S12XFTMR64K1V1) 20.1.3 Block Diagram Figure 20-1. FTMR64K1 Block Diagram The block diagram of the Flash module is shown in Figure 20-1. Flash Interface Command Interrupt Request Error Interrupt Request Registers 16bit internal bus P-Flash 8Kx72 sector 0 sector 1 sector 63 Protection Security Oscillator Clock (XTAL) Clock Divider FCLK Memory Controller D-Flash 2Kx22 sector 0 sector 1 sector 15 CPU Scratch RAM 384x16bits 20.2 External Signal Description The Flash module contains no signals that connect off-chip. S12XS Family Reference Manual, Rev. 1.09 608 Freescale Semiconductor 64 KByte Flash Module (S12XFTMR64K1V1) 20.3 Memory Map and Registers This section describes the memory map and registers for the Flash module. Read data from unimplemented memory space in the Flash module is undefined. Write access to unimplemented or reserved memory space in the Flash module will be ignored by the Flash module. 20.3.1 Module Memory Map The S12X architecture places the P-Flash memory between global addresses 0x7F_0000 and 0x7F_FFFF as shown in Table 20-2. The P-Flash memory map is shown in Figure 20-2. Table 20-2. P-Flash Memory Addressing Global Address Size (Bytes) 64 K Description P-Flash Block 0 Contains Flash Configuration Field (see Table 20-3) 0x7F_0000 – 0x7F_FFFF The FPROT register, described in Section 20.3.2.9, can be set to protect regions in the Flash memory from accidental program or erase. Three separate memory regions, one growing upward from global address 0x7F_8000 in the Flash memory (called the lower region), one growing downward from global address 0x7F_FFFF in the Flash memory (called the higher region), and the remaining addresses in the Flash memory, can be activated for protection. The Flash memory addresses covered by these protectable regions are shown in the P-Flash memory map. The higher address region is mainly targeted to hold the boot loader code since it covers the vector space. Default protection settings as well as security information that allows the MCU to restrict access to the Flash module are stored in the Flash configuration field as described in Table 20-3. Table 20-3. Flash Configuration Field1 Global Address Size (Bytes) 8 4 1 1 1 1 Description Backdoor Comparison Key Refer to Section 20.4.2.11, “Verify Backdoor Access Key Command,” and Section 20.5.1, “Unsecuring the MCU using Backdoor Key Access” Reserved P-Flash Protection byte. Refer to Section 20.3.2.9, “P-Flash Protection Register (FPROT)” D-Flash Protection byte. Refer to Section 20.3.2.10, “D-Flash Protection Register (DFPROT)” Flash Nonvolatile byte Refer to Section 20.3.2.15, “Flash Option Register (FOPT)” Flash Security byte Refer to Section 20.3.2.2, “Flash Security Register (FSEC)” 0x7F_FF00 – 0x7F_FF07 0x7F_FF08 – 0x7F_FF0B2 0x7F_FF0C2 0x7F_FF0D2 0x7F_FF0E2 0x7F_FF0F2 1 Older versions may have swapped protection byte addresses S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 609 64 KByte Flash Module (S12XFTMR64K1V1) 2 0x7FF08 - 0x7F_FF0F form a Flash phrase and must be programmed in a single command write sequence. Each byte in the 0x7F_FF08 - 0x7F_FF0B reserved field should be programmed to 0xFF. S12XS Family Reference Manual, Rev. 1.09 610 Freescale Semiconductor 64 KByte Flash Module (S12XFTMR64K1V1) P-Flash START = 0x7F_0000 Flash Protected/Unprotected Region 32 Kbytes 0x7F_8000 0x7F_8400 0x7F_8800 0x7F_9000 Flash Protected/Unprotected Lower Region 1, 2, 4, 8 Kbytes 0x7F_A000 Flash Protected/Unprotected Region 8 Kbytes (up to 29 Kbytes) 0x7F_C000 0x7F_E000 Flash Protected/Unprotected Higher Region 2, 4, 8, 16 Kbytes 0x7F_F000 0x7F_F800 P-Flash END = 0x7F_FFFF Flash Configuration Field 16 bytes (0x7F_FF00 - 0x7F_FF0F) Figure 20-2. P-Flash Memory Map S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 611 64 KByte Flash Module (S12XFTMR64K1V1) Table 20-4. Program IFR Fields Global Address (PGMIFRON) 0x40_0000 – 0x40_0007 0x40_0008 – 0x40_00E7 0x40_00E8 – 0x40_00E9 0x40_00EA – 0x40_00FF 0x40_0100 – 0x40_013F 0x40_0140 – 0x40_01FF Size (Bytes) 8 224 2 22 64 192 Device ID Reserved Version ID Reserved Program Once Field Refer to Section 20.4.2.6, “Program Once Command” Reserved Field Description Table 20-5. D-Flash and Memory Controller Resource Fields Global Address 0x10_0000 – 0x10_0FFF 0x10_1000 – 0x11_FFFF 0x12_0000 – 0x12_007F 0x12_0080 – 0x12_0FFF 0x12_1000 – 0x12_1FFF 0x12_2000 – 0x12_3CFF 0x12_3D00 – 0x12_3FFF 0x12_4000 – 0x12_E7FF 0x12_E800 – 0x12_FFFF 0x13_0000 – 0x13_FFFF 1 Size (Bytes) 4,096 126,976 128 3,968 4,096 7,242 768 43,008 6,144 65,536 D-Flash Memory Reserved Description D-Flash Nonvolatile Information Register (DFIFRON1 = 1) Reserved Reserved Reserved Memory Controller Scratch RAM (MGRAMON1 = 1) Reserved Reserved Reserved MMCCTL1 register bit S12XS Family Reference Manual, Rev. 1.09 612 Freescale Semiconductor 64 KByte Flash Module (S12XFTMR64K1V1) D-Flash START = 0x10_0000 D-Flash Memory 4 Kbytes D-Flash END = 0x10_0FFF 0x12_0000 0x12_1000 0x12_2000 0x12_4000 D-Flash Nonvolatile Information Register (DFIFRON) 128 bytes Memory Controller Scratch RAM (MGRAMON) 768 bytes 0x12_E800 0x12_FFFF Figure 20-3. D-Flash and Memory Controller Resource Memory Map 20.3.2 Register Descriptions The Flash module contains a set of 20 control and status registers located between Flash module base + 0x0000 and 0x0013. A summary of the Flash module registers is given in Figure 20-4 with detailed descriptions in the following subsections. CAUTION Writes to any Flash register must be avoided while a Flash command is active (CCIF=0) to prevent corruption of Flash register contents and Memory Controller behavior. Address & Name 0x0000 FCLKDIV 0x0001 FSEC R W R W KEYEN1 KEYEN0 RNV5 RNV4 RNV3 RNV2 SEC1 SEC0 7 FDIVLD FDIV6 FDIV5 FDIV4 FDIV3 FDIV2 FDIV1 FDIV0 6 5 4 3 2 1 0 Figure 20-4. FTMR64K1 Register Summary S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 613 64 KByte Flash Module (S12XFTMR64K1V1) Address & Name 0x0002 FCCOBIX 0x0003 FECCRIX 0x0004 FCNFG 0x0005 FERCNFG 0x0006 FSTAT 0x0007 FERSTAT 0x0008 FPROT 0x0009 DFPROT 0x000A FCCOBHI 0x000B FCCOBLO 0x000C FRSV0 0x000D FRSV1 0x000E FECCRHI 0x000F FECCRLO R W R W R 7 0 6 0 5 0 4 0 3 0 2 1 0 CCOBIX2 CCOBIX1 CCOBIX0 0 0 0 0 0 ECCRIX2 ECCRIX1 ECCRIX0 0 CCIE 0 IGNSF 0 0 FDFD FSFD W R W R CCIF W R W R FPOPEN W R DPOPEN W R CCOB15 W R CCOB7 W R W R W R W R W ECCR7 ECCR6 ECCR5 ECCR4 ECCR3 ECCR2 ECCR1 ECCR0 ECCR15 ECCR14 ECCR13 ECCR12 ECCR11 ECCR10 ECCR9 ECCR8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 CCOB6 CCOB5 CCOB4 CCOB3 CCOB2 CCOB1 CCOB0 CCOB14 CCOB13 CCOB12 CCOB11 CCOB10 CCOB9 CCOB8 0 0 DPS4 DPS3 DPS2 DPS1 DPS0 RNV6 FPHDIS FPHS1 FPHS0 FPLDIS FPLS1 FPLS0 0 0 0 0 0 0 DFDIF SFDIF 0 ACCERR FPVIOL MGBUSY RSVD MGSTAT1 MGSTAT0 0 DFDIE SFDIE Figure 20-4. FTMR64K1 Register Summary (continued) S12XS Family Reference Manual, Rev. 1.09 614 Freescale Semiconductor 64 KByte Flash Module (S12XFTMR64K1V1) Address & Name 0x0010 FOPT 0x0011 FRSV2 0x0012 FRSV3 0x0013 FRSV4 R W R W R W R W 7 NV7 6 NV6 5 NV5 4 NV4 3 NV3 2 NV2 1 NV1 0 NV0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = Unimplemented or Reserved Figure 20-4. FTMR64K1 Register Summary (continued) 20.3.2.1 Flash Clock Divider Register (FCLKDIV) The FCLKDIV register is used to control timed events in program and erase algorithms. Offset Module Base + 0x0000 7 6 5 4 3 2 1 0 R W Reset FDIVLD FDIV[6:0] 0 0 0 0 0 0 0 0 = Unimplemented or Reserved Figure 20-5. Flash Clock Divider Register (FCLKDIV) All bits in the FCLKDIV register are readable, bits 6–0 are write once and bit 7 is not writable. Table 20-6. FCLKDIV Field Descriptions Field 7 FDIVLD 6–0 FDIV[6:0] Description Clock Divider Loaded 0 FCLKDIV register has not been written 1 FCLKDIV register has been written since the last reset Clock Divider Bits — FDIV[6:0] must be set to effectively divide OSCCLK down to generate an internal Flash clock, FCLK, with a target frequency of 1 MHz for use by the Flash module to control timed events during program and erase algorithms. Table 20-7 shows recommended values for FDIV[6:0] based on OSCCLK frequency. Please refer to Section 20.4.1, “Flash Command Operations,” for more information. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 615 64 KByte Flash Module (S12XFTMR64K1V1) CAUTION The FCLKDIV register should never be written while a Flash command is executing (CCIF=0). The FCLKDIV register is writable during the Flash reset sequence even though CCIF is clear. S12XS Family Reference Manual, Rev. 1.09 616 Freescale Semiconductor 64 KByte Flash Module (S12XFTMR64K1V1) Table 20-7. FDIV vs OSCCLK Frequency OSCCLK Frequency (MHz) MIN1 1.60 2.40 3.20 4.20 5.25 6.30 7.35 8.40 9.45 10.50 11.55 12.60 13.65 14.70 15.75 16.80 17.85 18.90 19.95 21.00 22.05 23.10 24.15 25.20 26.25 27.30 28.35 29.40 30.45 31.50 32.55 1 2 FDIV[6:0] OSCCLK Frequency (MHz) MIN1 MAX 2 FDIV[6:0] MAX 2 2.10 3.15 4.20 5.25 6.30 7.35 8.40 9.45 10.50 11.55 12.60 13.65 14.70 15.75 16.80 17.85 18.90 19.95 21.00 22.05 23.10 24.15 25.20 26.25 27.30 28.35 29.40 30.45 31.50 32.55 33.60 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1A 0x1B 0x1C 0x1D 0x1E 0x1F 33.60 34.65 35.70 36.75 37.80 38.85 39.90 40.95 42.00 43.05 44.10 45.15 46.20 47.25 48.30 49.35 34.65 35.70 36.75 37.80 38.85 39.90 40.95 42.00 43.05 44.10 45.15 46.20 47.25 48.30 49.35 50.40 0x20 0x21 0x22 0x23 0x24 0x25 0x26 0x27 0x28 0x29 0x2A 0x2B 0x2C 0x2D 0x2E 0x2F FDIV shown generates an FCLK frequency of >0.8 MHz FDIV shown generates an FCLK frequency of 1.05 MHz S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 617 64 KByte Flash Module (S12XFTMR64K1V1) 20.3.2.2 Flash Security Register (FSEC) The FSEC register holds all bits associated with the security of the MCU and Flash module. Offset Module Base + 0x0001 7 6 5 4 3 2 1 0 R W Reset F KEYEN[1:0] RNV[5:2] SEC[1:0] F F F F F F F = Unimplemented or Reserved Figure 20-6. Flash Security Register (FSEC) All bits in the FSEC register are readable but not writable. During the reset sequence, the FSEC register is loaded with the contents of the Flash security byte in the Flash configuration field at global address 0x7F_FF0F located in P-Flash memory (see Table 20-3) as indicated by reset condition F in Figure 20-6. If a double bit fault is detected while reading the P-Flash phrase containing the Flash security byte during the reset sequence, all bits in the FSEC register will be set to leave the Flash module in a secured state with backdoor key access disabled. Table 20-8. FSEC Field Descriptions Field Description 7–6 Backdoor Key Security Enable Bits — The KEYEN[1:0] bits define the enabling of backdoor key access to the KEYEN[1:0] Flash module as shown in Table 20-9. 5–2 RNV[5:2} 1–0 SEC[1:0] Reserved Nonvolatile Bits — The RNV bits should remain in the erased state for future enhancements. Flash Security Bits — The SEC[1:0] bits define the security state of the MCU as shown in Table 20-10. If the Flash module is unsecured using backdoor key access, the SEC bits are forced to 10. Table 20-9. Flash KEYEN States KEYEN[1:0] 00 01 10 11 1 Status of Backdoor Key Access DISABLED DISABLED1 ENABLED DISABLED Preferred KEYEN state to disable backdoor key access. Table 20-10. Flash Security States SEC[1:0] 00 01 10 11 Status of Security SECURED SECURED1 UNSECURED SECURED S12XS Family Reference Manual, Rev. 1.09 618 Freescale Semiconductor 64 KByte Flash Module (S12XFTMR64K1V1) 1 Preferred SEC state to set MCU to secured state. The security function in the Flash module is described in Section 20.5. 20.3.2.3 Flash CCOB Index Register (FCCOBIX) The FCCOBIX register is used to index the FCCOB register for Flash memory operations. Offset Module Base + 0x0002 7 6 5 4 3 2 1 0 R W Reset 0 0 0 0 0 CCOBIX[2:0] 0 0 0 0 0 0 0 0 = Unimplemented or Reserved Figure 20-7. FCCOB Index Register (FCCOBIX) CCOBIX bits are readable and writable while remaining bits read 0 and are not writable. Table 20-11. FCCOBIX Field Descriptions Field 2–0 CCOBIX[1:0] Description Common Command Register Index— The CCOBIX bits are used to select which word of the FCCOB register array is being read or written to. See Section 20.3.2.11, “Flash Common Command Object Register (FCCOB),” for more details. 20.3.2.4 Flash ECCR Index Register (FECCRIX) The FECCRIX register is used to index the FECCR register for ECC fault reporting. Offset Module Base + 0x0003 7 6 5 4 3 2 1 0 R W Reset 0 0 0 0 0 ECCRIX[2:0] 0 0 0 0 0 0 0 0 = Unimplemented or Reserved Figure 20-8. FECCR Index Register (FECCRIX) ECCRIX bits are readable and writable while remaining bits read 0 and are not writable. Table 20-12. FECCRIX Field Descriptions Field Description 2-0 ECC Error Register Index— The ECCRIX bits are used to select which word of the FECCR register array is ECCRIX[2:0] being read. See Section 20.3.2.14, “Flash ECC Error Results Register (FECCR),” for more details. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 619 64 KByte Flash Module (S12XFTMR64K1V1) 20.3.2.5 Flash Configuration Register (FCNFG) The FCNFG register enables the Flash command complete interrupt and forces ECC faults on Flash array read access from the CPU or XGATE. Offset Module Base + 0x0004 7 6 5 4 3 2 1 0 R CCIE W Reset 0 0 0 IGNSF 0 0 FDFD FSFD 0 0 0 0 0 0 0 = Unimplemented or Reserved Figure 20-9. Flash Configuration Register (FCNFG) CCIE, IGNSF, FDFD, and FSFD bits are readable and writable while remaining bits read 0 and are not writable. Table 20-13. FCNFG Field Descriptions Field 7 CCIE Description Command Complete Interrupt Enable — The CCIE bit controls interrupt generation when a Flash command has completed. 0 Command complete interrupt disabled 1 An interrupt will be requested whenever the CCIF flag in the FSTAT register is set (see Section 20.3.2.7) Ignore Single Bit Fault — The IGNSF controls single bit fault reporting in the FERSTAT register (see Section 20.3.2.8). 0 All single bit faults detected during array reads are reported 1 Single bit faults detected during array reads are not reported and the single bit fault interrupt will not be generated Force Double Bit Fault Detect — The FDFD bit allows the user to simulate a double bit fault during Flash array read operations and check the associated interrupt routine. The FDFD bit is cleared by writing a 0 to FDFD. The FECCR registers will not be updated during the Flash array read operation with FDFD set unless an actual double bit fault is detected. 0 Flash array read operations will set the DFDIF flag in the FERSTAT register only if a double bit fault is detected 1 Any Flash array read operation will force the DFDIF flag in the FERSTAT register to be set (see Section 20.3.2.7) and an interrupt will be generated as long as the DFDIE interrupt enable in the FERCNFG register is set (see Section 20.3.2.6) Force Single Bit Fault Detect — The FSFD bit allows the user to simulate a single bit fault during Flash array read operations and check the associated interrupt routine. The FSFD bit is cleared by writing a 0 to FSFD. The FECCR registers will not be updated during the Flash array read operation with FSFD set unless an actual single bit fault is detected. 0 Flash array read operations will set the SFDIF flag in the FERSTAT register only if a single bit fault is detected 1 Flash array read operation will force the SFDIF flag in the FERSTAT register to be set (see Section 20.3.2.7) and an interrupt will be generated as long as the SFDIE interrupt enable in the FERCNFG register is set (see Section 20.3.2.6) 4 IGNSF 1 FDFD 0 FSFD 20.3.2.6 Flash Error Configuration Register (FERCNFG) The FERCNFG register enables the Flash error interrupts for the FERSTAT flags. S12XS Family Reference Manual, Rev. 1.09 620 Freescale Semiconductor 64 KByte Flash Module (S12XFTMR64K1V1) Offset Module Base + 0x0005 7 6 5 4 3 2 1 0 R W Reset 0 0 0 DFDIE 0 0 0 0 0 SFDIE 0 = Unimplemented or Reserved Figure 20-10. Flash Error Configuration Register (FERCNFG) All assigned bits in the FERCNFG register are readable and writable. Table 20-14. FERCNFG Field Descriptions Field 1 DFDIE Description Double Bit Fault Detect Interrupt Enable — The DFDIE bit controls interrupt generation when a double bit fault is detected during a Flash block read operation. 0 DFDIF interrupt disabled 1 An interrupt will be requested whenever the DFDIF flag is set (see Section 20.3.2.8) Single Bit Fault Detect Interrupt Enable — The SFDIE bit controls interrupt generation when a single bit fault is detected during a Flash block read operation. 0 SFDIF interrupt disabled whenever the SFDIF flag is set (see Section 20.3.2.8) 1 An interrupt will be requested whenever the SFDIF flag is set (see Section 20.3.2.8) 0 SFDIE 20.3.2.7 Flash Status Register (FSTAT) The FSTAT register reports the operational status of the Flash module. Offset Module Base + 0x0006 7 6 5 4 3 2 1 0 R CCIF W Reset 1 0 ACCERR 0 0 FPVIOL 0 MGBUSY RSVD MGSTAT[1:0] 0 0 01 01 = Unimplemented or Reserved Figure 20-11. Flash Status Register (FSTAT) 1 Reset value can deviate from the value shown if a double bit fault is detected during the reset sequence (see Section 20.6). CCIF, ACCERR, and FPVIOL bits are readable and writable, MGBUSY and MGSTAT bits are readable but not writable, while remaining bits read 0 and are not writable. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 621 64 KByte Flash Module (S12XFTMR64K1V1) Table 20-15. FSTAT Field Descriptions Field 7 CCIF Description Command Complete Interrupt Flag — The CCIF flag indicates that a Flash command has completed. The CCIF flag is cleared by writing a 1 to CCIF to launch a command and CCIF will stay low until command completion or command violation. 0 Flash command in progress 1 Flash command has completed Flash Access Error Flag — The ACCERR bit indicates an illegal access has occurred to the Flash memory caused by either a violation of the command write sequence (see Section 20.4.1.2) or issuing an illegal Flash command. While ACCERR is set, the CCIF flag cannot be cleared to launch a command. The ACCERR bit is cleared by writing a 1 to ACCERR. Writing a 0 to the ACCERR bit has no effect on ACCERR. 0 No access error detected 1 Access error detected Flash Protection Violation Flag —The FPVIOL bit indicates an attempt was made to program or erase an address in a protected area of P-Flash or D-Flash memory during a command write sequence. The FPVIOL bit is cleared by writing a 1 to FPVIOL. Writing a 0 to the FPVIOL bit has no effect on FPVIOL. While FPVIOL is set, it is not possible to launch a command or start a command write sequence. 0 No protection violation detected 1 Protection violation detected Memory Controller Busy Flag — The MGBUSY flag reflects the active state of the Memory Controller. 0 Memory Controller is idle 1 Memory Controller is busy executing a Flash command (CCIF = 0) Reserved Bit — This bit is reserved and always reads 0. 5 ACCERR 4 FPVIOL 3 MGBUSY 2 RSVD 1–0 Memory Controller Command Completion Status Flag — One or more MGSTAT flag bits are set if an error MGSTAT[1:0] is detected during execution of a Flash command or during the Flash reset sequence. See Section 20.4.2, “Flash Command Description,” and Section 20.6, “Initialization” for details. 20.3.2.8 Flash Error Status Register (FERSTAT) The FERSTAT register reflects the error status of internal Flash operations. Offset Module Base + 0x0007 7 6 5 4 3 2 1 0 R W Reset 0 0 0 0 0 0 DFDIF SFDIF 0 0 0 0 0 0 0 0 = Unimplemented or Reserved Figure 20-12. Flash Error Status Register (FERSTAT) All flags in the FERSTAT register are readable and only writable to clear the flag. S12XS Family Reference Manual, Rev. 1.09 622 Freescale Semiconductor 64 KByte Flash Module (S12XFTMR64K1V1) Table 20-16. FERSTAT Field Descriptions Field 1 DFDIF Description Double Bit Fault Detect Interrupt Flag — The setting of the DFDIF flag indicates that a double bit fault was detected in the stored parity and data bits during a Flash array read operation or that a Flash array read operation was attempted on a Flash block that was under a Flash command operation. The DFDIF flag is cleared by writing a 1 to DFDIF. Writing a 0 to DFDIF has no effect on DFDIF. 0 No double bit fault detected 1 Double bit fault detected or an invalid Flash array read operation attempted Single Bit Fault Detect Interrupt Flag — With the IGNSF bit in the FCNFG register clear, the SFDIF flag indicates that a single bit fault was detected in the stored parity and data bits during a Flash array read operation or that a Flash array read operation was attempted on a Flash block that was under a Flash command operation. The SFDIF flag is cleared by writing a 1 to SFDIF. Writing a 0 to SFDIF has no effect on SFDIF. 0 No single bit fault detected 1 Single bit fault detected and corrected or an invalid Flash array read operation attempted 0 SFDIF 20.3.2.9 P-Flash Protection Register (FPROT) The FPROT register defines which P-Flash sectors are protected against program and erase operations. Offset Module Base + 0x0008 7 6 5 4 3 2 1 0 R FPOPEN W Reset F RNV6 FPHDIS F F F FPHS[1:0] F FPLDIS F F FPLS[1:0] F = Unimplemented or Reserved Figure 20-13. Flash Protection Register (FPROT) The (unreserved) bits of the FPROT register are writable with the restriction that the size of the protected region can only be increased (see Section 20.3.2.9.1, “P-Flash Protection Restrictions,” and Table 20-21). During the reset sequence, the FPROT register is loaded with the contents of the P-Flash protection byte in the Flash configuration field at global address 0x7F_FF0C located in P-Flash memory (see Table 20-3) as indicated by reset condition ‘F’ in Figure 20-13. To change the P-Flash protection that will be loaded during the reset sequence, the upper sector of the P-Flash memory must be unprotected, then the P-Flash protection byte must be reprogrammed. If a double bit fault is detected while reading the P-Flash phrase containing the P-Flash protection byte during the reset sequence, the FPOPEN bit will be cleared and remaining bits in the FPROT register will be set to leave the P-Flash memory fully protected. Trying to alter data in any protected area in the P-Flash memory will result in a protection violation error and the FPVIOL bit will be set in the FSTAT register. The block erase of a P-Flash block is not possible if any of the P-Flash sectors contained in the same P-Flash block are protected. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 623 64 KByte Flash Module (S12XFTMR64K1V1) Table 20-17. FPROT Field Descriptions Field 7 FPOPEN Description Flash Protection Operation Enable — The FPOPEN bit determines the protection function for program or erase operations as shown in Table 20-18 for the P-Flash block. 0 When FPOPEN is clear, the FPHDIS and FPLDIS bits define unprotected address ranges as specified by the corresponding FPHS and FPLS bits 1 When FPOPEN is set, the FPHDIS and FPLDIS bits enable protection for the address range specified by the corresponding FPHS and FPLS bits Reserved Nonvolatile Bit — The RNV bit should remain in the erased state for future enhancements. Flash Protection Higher Address Range Disable — The FPHDIS bit determines whether there is a protected/unprotected area in a specific region of the P-Flash memory ending with global address 0x7F_FFFF. 0 Protection/Unprotection enabled 1 Protection/Unprotection disabled Flash Protection Higher Address Size — The FPHS bits determine the size of the protected/unprotected area in P-Flash memory as shown inTable 20-19. The FPHS bits can only be written to while the FPHDIS bit is set. Flash Protection Lower Address Range Disable — The FPLDIS bit determines whether there is a protected/unprotected area in a specific region of the P-Flash memory beginning with global address 0x7F_8000. 0 Protection/Unprotection enabled 1 Protection/Unprotection disabled Flash Protection Lower Address Size — The FPLS bits determine the size of the protected/unprotected area in P-Flash memory as shown in Table 20-20. The FPLS bits can only be written to while the FPLDIS bit is set. 6 RNV[6] 5 FPHDIS 4–3 FPHS[1:0] 2 FPLDIS 1–0 FPLS[1:0] Table 20-18. P-Flash Protection Function FPOPEN 1 1 1 1 0 0 0 0 1 FPHDIS 1 1 0 0 1 1 0 0 FPLDIS 1 0 1 0 1 0 1 0 Function1 No P-Flash Protection Protected Low Range Protected High Range Protected High and Low Ranges Full P-Flash Memory Protected Unprotected Low Range Unprotected High Range Unprotected High and Low Ranges For range sizes, refer to Table 20-19 and Table 20-20. Table 20-19. P-Flash Protection Higher Address Range FPHS[1:0] 00 01 10 11 Global Address Range 0x7F_F800–0x7F_FFFF 0x7F_F000–0x7F_FFFF 0x7F_E000–0x7F_FFFF 0x7F_C000–0x7F_FFFF Protected Size 2 Kbytes 4 Kbytes 8 Kbytes 16 Kbytes S12XS Family Reference Manual, Rev. 1.09 624 Freescale Semiconductor 64 KByte Flash Module (S12XFTMR64K1V1) Table 20-20. P-Flash Protection Lower Address Range FPLS[1:0] 00 01 10 11 Global Address Range 0x7F_8000–0x7F_83FF 0x7F_8000–0x7F_87FF 0x7F_8000–0x7F_8FFF 0x7F_8000–0x7F_9FFF Protected Size 1 Kbyte 2 Kbytes 4 Kbytes 8 Kbytes All possible P-Flash protection scenarios are shown in Figure 20-14. Although the protection scheme is loaded from the Flash memory at global address 0x7F_FF0C during the reset sequence, it can be changed by the user. The P-Flash protection scheme can be used by applications requiring reprogramming in single chip mode while providing as much protection as possible if reprogramming is not required. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 625 64 KByte Flash Module (S12XFTMR64K1V1) FPHDIS = 1 FPLDIS = 1 FLASH START FPHDIS = 1 FPLDIS = 0 6 FPHDIS = 0 FPLDIS = 1 5 FPHDIS = 0 FPLDIS = 0 4 Scenario 7 0x7F_8000 0x7F_FFFF Scenario FLASH START 3 2 1 0 FPHS[1:0] Freescale Semiconductor FPLS[1:0] Unprotected region Protected region not defined by FPLS, FPHS Protected region with size defined by FPLS Protected region with size defined by FPHS Figure 20-14. P-Flash Protection Scenarios S12XS Family Reference Manual, Rev. 1.09 0x7F_8000 0x7F_FFFF 626 FPHS[1:0] FPLS[1:0] FPOPEN = 0 FPOPEN = 1 64 KByte Flash Module (S12XFTMR64K1V1) 20.3.2.9.1 P-Flash Protection Restrictions The general guideline is that P-Flash protection can only be added and not removed. Table 20-21 specifies all valid transitions between P-Flash protection scenarios. Any attempt to write an invalid scenario to the FPROT register will be ignored. The contents of the FPROT register reflect the active protection scenario. See the FPHS and FPLS bit descriptions for additional restrictions. Table 20-21. P-Flash Protection Scenario Transitions From Protection Scenario 0 1 2 3 4 5 6 7 1 To Protection Scenario1 0 X 1 X X X 2 X 3 X X X X X X X X X X X X X X X X X X X X X X 4 5 6 7 Allowed transitions marked with X, see Figure 20-14 for a definition of the scenarios. 20.3.2.10 D-Flash Protection Register (DFPROT) The DFPROT register defines which D-Flash sectors are protected against program and erase operations. Offset Module Base + 0x0009 7 6 5 4 3 2 1 0 R DPOPEN W Reset F 0 0 DPS[4:0] 0 0 F F F F F = Unimplemented or Reserved Figure 20-15. D-Flash Protection Register (DFPROT) The (unreserved) bits of the DFPROT register are writable with the restriction that protection can be added but not removed. Writes must increase the DPS value and the DPOEN bit can only be written from 1 (protection disabled) to 0 (protection enabled). If the DPOPEN bit is set, the state of the DPS bits is irrelevant. During the reset sequence, the DFPROT register is loaded with the contents of the D-Flash protection byte in the Flash configuration field at global address 0x7F_FF0D located in P-Flash memory (see Table 20-3) as indicated by reset condition F in Figure 20-15. To change the D-Flash protection that will be loaded during the reset sequence, the P-Flash sector containing the D-Flash protection byte must be unprotected, then the D-Flash protection byte must be programmed. If a double bit fault is detected while reading the S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 627 64 KByte Flash Module (S12XFTMR64K1V1) P-Flash phrase containing the D-Flash protection byte during the reset sequence, the DPOPEN bit will be cleared and DPS bits will be set to leave the D-Flash memory fully protected. Trying to alter data in any protected area in the D-Flash memory will result in a protection violation error and the FPVIOL bit will be set in the FSTAT register. Block erase of the D-Flash memory is not possible if any of the D-Flash sectors are protected. Table 20-22. DFPROT Field Descriptions Field 7 DPOPEN Description D-Flash Protection Control 0 Enables D-Flash memory protection from program and erase with protected address range defined by DPS bits 1 Disables D-Flash memory protection from program and erase D-Flash Protection Size — The DPS[4:0] bits determine the size of the protected area in the D-Flash memory as shown in Table 20-23. 4–0 DPS[4:0] Table 20-23. D-Flash Protection Address Range DPS[4:0] 0_0000 0_0001 0_0010 0_0011 0_0100 0_0101 0_0110 0_0111 0_1000 0_1001 0_1010 0_1011 0_1100 0_1101 0_1110 0_1111 Global Address Range 0x10_0000 – 0x10_00FF 0x10_0000 – 0x10_01FF 0x10_0000 – 0x10_02FF 0x10_0000 – 0x10_03FF 0x10_0000 – 0x10_04FF 0x10_0000 – 0x10_05FF 0x10_0000 – 0x10_06FF 0x10_0000 – 0x10_07FF 0x10_0000 – 0x10_08FF 0x10_0000 – 0x10_09FF 0x10_0000 – 0x10_0AFF 0x10_0000 – 0x10_0BFF 0x10_0000 – 0x10_0CFF 0x10_0000 – 0x10_0DFF 0x10_0000 – 0x10_0EFF 0x10_0000 – 0x10_0FFF Protected Size 256 bytes 512 bytes 768 bytes 1024 bytes 1280 bytes 1536 bytes 1792 bytes 2048 bytes 2304 bytes 2560 bytes 2816 bytes 3072 bytes 3328 bytes 3584 bytes 3840 bytes 4096 bytes 20.3.2.11 Flash Common Command Object Register (FCCOB) The FCCOB is an array of six words addressed via the CCOBIX index found in the FCCOBIX register. Byte wide reads and writes are allowed to the FCCOB register. S12XS Family Reference Manual, Rev. 1.09 628 Freescale Semiconductor 64 KByte Flash Module (S12XFTMR64K1V1) Offset Module Base + 0x000A 7 6 5 4 3 2 1 0 R CCOB[15:8] W Reset 0 0 0 0 0 0 0 0 Figure 20-16. Flash Common Command Object High Register (FCCOBHI) Offset Module Base + 0x000B 7 6 5 4 3 2 1 0 R CCOB[7:0] W Reset 0 0 0 0 0 0 0 0 Figure 20-17. Flash Common Command Object Low Register (FCCOBLO) 20.3.2.11.1 FCCOB - NVM Command Mode NVM command mode uses the indexed FCCOB register to provide a command code and its relevant parameters to the Memory Controller. The user first sets up all required FCCOB fields and then initiates the command’s execution by writing a 1 to the CCIF bit in the FSTAT register (a 1 written by the user clears the CCIF command completion flag to 0). When the user clears the CCIF bit in the FSTAT register all FCCOB parameter fields are locked and cannot be changed by the user until the command completes (as evidenced by the Memory Controller returning CCIF to 1). Some commands return information to the FCCOB register array. The generic format for the FCCOB parameter fields in NVM command mode is shown in Table 20-24. The return values are available for reading after the CCIF flag in the FSTAT register has been returned to 1 by the Memory Controller. Writes to the unimplemented parameter fields (CCOBIX = 110 and CCOBIX = 111) are ignored with reads from these fields returning 0x0000. Table 20-24 shows the generic Flash command format. The high byte of the first word in the CCOB array contains the command code, followed by the parameters for this specific Flash command. For details on the FCCOB settings required by each command, see the Flash command descriptions in Section 20.4.2. Table 20-24. FCCOB - NVM Command Mode (Typical Usage) CCOBIX[2:0] 000 LO HI 001 LO HI 010 LO Data 0 [7:0] Global address [7:0] Data 0 [15:8] 0, Global address [22:16] Global address [15:8] Byte HI FCCOB Parameter Fields (NVM Command Mode) FCMD[7:0] defining Flash command S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 629 64 KByte Flash Module (S12XFTMR64K1V1) Table 20-24. FCCOB - NVM Command Mode (Typical Usage) CCOBIX[2:0] 011 LO HI 100 LO HI 101 LO Data 3 [7:0] Data 2 [7:0] Data 3 [15:8] Data 1 [7:0] Data 2 [15:8] Byte HI FCCOB Parameter Fields (NVM Command Mode) Data 1 [15:8] 20.3.2.12 Flash Reserved0 Register (FRSV0) This Flash register is reserved for factory testing. Offset Module Base + 0x000C 7 6 5 4 3 2 1 0 R W Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = Unimplemented or Reserved Figure 20-18. Flash Reserved0 Register (FRSV0) All bits in the FRSV0 register read 0 and are not writable. 20.3.2.13 Flash Reserved1 Register (FRSV1) This Flash register is reserved for factory testing. Offset Module Base + 0x000D 7 6 5 4 3 2 1 0 R W Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = Unimplemented or Reserved Figure 20-19. Flash Reserved1 Register (FRSV1) All bits in the FRSV1 register read 0 and are not writable. 20.3.2.14 Flash ECC Error Results Register (FECCR) The FECCR registers contain the result of a detected ECC fault for both single bit and double bit faults. The FECCR register provides access to several ECC related fields as defined by the ECCRIX index bits in the FECCRIX register (see Section 20.3.2.4). Once ECC fault information has been stored, no other S12XS Family Reference Manual, Rev. 1.09 630 Freescale Semiconductor 64 KByte Flash Module (S12XFTMR64K1V1) fault information will be recorded until the specific ECC fault flag has been cleared. In the event of simultaneous ECC faults the priority for fault recording is double bit fault over single bit fault. Offset Module Base + 0x000E 7 6 5 4 3 2 1 0 R W Reset 0 0 0 0 ECCR[15:8] 0 0 0 0 = Unimplemented or Reserved Figure 20-20. Flash ECC Error Results High Register (FECCRHI) Offset Module Base + 0x000F 7 6 5 4 3 2 1 0 R W Reset 0 0 0 0 ECCR[7:0] 0 0 0 0 = Unimplemented or Reserved Figure 20-21. Flash ECC Error Results Low Register (FECCRLO) All FECCR bits are readable but not writable. Table 20-25. FECCR Index Settings ECCRIX[2:0] Bits [15:8] 000 001 010 011 100 101 110 111 Parity bits read from Flash block FECCR Register Content Bit[7] 0 Global address [15:0] Data 0 [15:0] Data 1 [15:0] (P-Flash only) Data 2 [15:0] (P-Flash only) Data 3 [15:0] (P-Flash only) Not used, returns 0x0000 when read Not used, returns 0x0000 when read Bits[6:0] Global address [22:16] Table 20-26. FECCR Index=000 Bit Descriptions Field 15:8 PAR[7:0] Description ECC Parity Bits — Contains the 8 parity bits from the 72 bit wide P-Flash data word or the 6 parity bits, allocated to PAR[5:0], from the 22 bit wide D-Flash word with PAR[7:6]=00. 6–0 Global Address — The GADDR[22:16] field contains the upper seven bits of the global address having GADDR[22:16] caused the error. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 631 64 KByte Flash Module (S12XFTMR64K1V1) The P-Flash word addressed by ECCRIX = 001 contains the lower 16 bits of the global address. The following four words addressed by ECCRIX = 010 to 101 contain the 64-bit wide data phrase. The four data words and the parity byte are the uncorrected data read from the P-Flash block. The D-Flash word addressed by ECCRIX = 001 contains the lower 16 bits of the global address. The uncorrected 16-bit data word is addressed by ECCRIX = 010. 20.3.2.15 Flash Option Register (FOPT) The FOPT register is the Flash option register. Offset Module Base + 0x0010 7 6 5 4 3 2 1 0 R W Reset F F F F NV[7:0] F F F F = Unimplemented or Reserved Figure 20-22. Flash Option Register (FOPT) All bits in the FOPT register are readable but are not writable. During the reset sequence, the FOPT register is loaded from the Flash nonvolatile byte in the Flash configuration field at global address 0x7F_FF0E located in P-Flash memory (see Table 20-3) as indicated by reset condition F in Figure 20-22. If a double bit fault is detected while reading the P-Flash phrase containing the Flash nonvolatile byte during the reset sequence, all bits in the FOPT register will be set. Table 20-27. FOPT Field Descriptions Field 7–0 NV[7:0] Description Nonvolatile Bits — The NV[7:0] bits are available as nonvolatile bits. Refer to the device user guide for proper use of the NV bits. 20.3.2.16 Flash Reserved2 Register (FRSV2) This Flash register is reserved for factory testing. Offset Module Base + 0x0011 7 6 5 4 3 2 1 0 R W Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = Unimplemented or Reserved Figure 20-23. Flash Reserved2 Register (FRSV2) All bits in the FRSV2 register read 0 and are not writable. S12XS Family Reference Manual, Rev. 1.09 632 Freescale Semiconductor 64 KByte Flash Module (S12XFTMR64K1V1) 20.3.2.17 Flash Reserved3 Register (FRSV3) This Flash register is reserved for factory testing. Offset Module Base + 0x0012 7 6 5 4 3 2 1 0 R W Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = Unimplemented or Reserved Figure 20-24. Flash Reserved3 Register (FRSV3) All bits in the FRSV3 register read 0 and are not writable. 20.3.2.18 Flash Reserved4 Register (FRSV4) This Flash register is reserved for factory testing. Offset Module Base + 0x0013 7 6 5 4 3 2 1 0 R W Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = Unimplemented or Reserved Figure 20-25. Flash Reserved4 Register (FRSV4) All bits in the FRSV4 register read 0 and are not writable. 20.4 20.4.1 Functional Description Flash Command Operations Flash command operations are used to modify Flash memory contents. The next sections describe: • How to write the FCLKDIV register that is used to generate a time base (FCLK) derived from OSCCLK for Flash program and erase command operations • The command write sequence used to set Flash command parameters and launch execution • Valid Flash commands available for execution S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 633 64 KByte Flash Module (S12XFTMR64K1V1) 20.4.1.1 Writing the FCLKDIV Register Prior to issuing any Flash program or erase command after a reset, the user is required to write the FCLKDIV register to divide OSCCLK down to a target FCLK of 1 MHz. Table 20-7 shows recommended values for the FDIV field based on OSCCLK frequency. NOTE Programming or erasing the Flash memory cannot be performed if the bus clock runs at less than 1 MHz. Setting FDIV too high can destroy the Flash memory due to overstress. Setting FDIV too low can result in incomplete programming or erasure of the Flash memory cells. When the FCLKDIV register is written, the FDIVLD bit is set automatically. If the FDIVLD bit is 0, the FCLKDIV register has not been written since the last reset. If the FCLKDIV register has not been written, any Flash program or erase command loaded during a command write sequence will not execute and the ACCERR bit in the FSTAT register will set. 20.4.1.2 Command Write Sequence The Memory Controller will launch all valid Flash commands entered using a command write sequence. Before launching a command, the ACCERR and FPVIOL bits in the FSTAT register must be clear (see Section 20.3.2.7) and the CCIF flag should be tested to determine the status of the current command write sequence. If CCIF is 0, the previous command write sequence is still active, a new command write sequence cannot be started, and all writes to the FCCOB register are ignored. CAUTION Writes to any Flash register must be avoided while a Flash command is active (CCIF=0) to prevent corruption of Flash register contents and Memory Controller behavior. 20.4.1.2.1 Define FCCOB Contents The FCCOB parameter fields must be loaded with all required parameters for the Flash command being executed. Access to the FCCOB parameter fields is controlled via the CCOBIX bits in the FCCOBIX register (see Section 20.3.2.3). The contents of the FCCOB parameter fields are transferred to the Memory Controller when the user clears the CCIF command completion flag in the FSTAT register (writing 1 clears the CCIF to 0). The CCIF flag will remain clear until the Flash command has completed. Upon completion, the Memory Controller will return CCIF to 1 and the FCCOB register will be used to communicate any results. The flow for a generic command write sequence is shown in Figure 20-26. S12XS Family Reference Manual, Rev. 1.09 634 Freescale Semiconductor 64 KByte Flash Module (S12XFTMR64K1V1) START Read: FCLKDIV register Clock Register Written Check FDIVLD Set? yes no Write: FCLKDIV register Read: FSTAT register Note: FCLKDIV must be set after each reset FCCOB Availability Check CCIF Set? yes no Results from previous Command yes Write: FSTAT register Clear ACCERR/FPVIOL 0x30 Access Error and Protection Violation Check ACCERR/ FPVIOL Set? no Write to FCCOBIX register to identify specific command parameter to load. Write to FCCOB register to load required command parameter. More Parameters? no yes Write: FSTAT register (to launch command) Clear CCIF 0x80 Read: FSTAT register Bit Polling for Command Completion Check CCIF Set? yes EXIT no Figure 20-26. Generic Flash Command Write Sequence Flowchart S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 635 64 KByte Flash Module (S12XFTMR64K1V1) 20.4.1.3 Valid Flash Module Commands Table 20-28. Flash Commands by Mode Unsecured FCMD 0x01 0x02 0x03 0x04 0x06 0x07 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x10 0x11 0x12 1 2 3 4 5 6 7 8 Secured ST4 ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ NS5 ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ NX6 ∗ ∗ SS7 ∗ ∗ ST8 ∗ ∗ Command Erase Verify All Blocks Erase Verify Block Erase Verify P-Flash Section Read Once Program P-Flash Program Once Erase All Blocks Erase Flash Block Erase P-Flash Sector Unsecure Flash Verify Backdoor Access Key Set User Margin Level Set Field Margin Level Erase Verify D-Flash Section Program D-Flash Erase D-Flash Sector NS1 ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ NX2 ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ SS3 ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ Unsecured Normal Single Chip mode. Unsecured Normal Expanded mode. Unsecured Special Single Chip mode. Unsecured Special Mode. Secured Normal Single Chip mode. Secured Normal Expanded mode. Secured Special Single Chip mode. Secured Special Mode. 20.4.1.4 P-Flash Commands Table 20-29 summarizes the valid P-Flash commands along with the effects of the commands on the P-Flash block and other resources within the Flash module. S12XS Family Reference Manual, Rev. 1.09 636 Freescale Semiconductor 64 KByte Flash Module (S12XFTMR64K1V1) Table 20-29. P-Flash Commands FCMD 0x01 0x02 0x03 0x04 0x06 0x07 Command Erase Verify All Blocks Erase Verify Block Erase Verify P-Flash Section Read Once Program P-Flash Program Once Function on P-Flash Memory Verify that all P-Flash (and D-Flash) blocks are erased. Verify that a P-Flash block is erased. Verify that a given number of words starting at the address provided are erased. Read a dedicated 64 byte field in the nonvolatile information register in P-Flash block 0 that was previously programmed using the Program Once command. Program a phrase in a P-Flash block. Program a dedicated 64 byte field in the nonvolatile information register in P-Flash block 0 that is allowed to be programmed only once. Erase all P-Flash (and D-Flash) blocks. An erase of all Flash blocks is only possible when the FPLDIS, FPHDIS, and FPOPEN bits in the FPROT register and the DPOPEN bit in the DFPROT register are set prior to launching the command. Erase a P-Flash (or D-Flash) block. An erase of the full P-Flash block is only possible when FPLDIS, FPHDIS and FPOPEN bits in the FPROT register are set prior to launching the command. Erase all bytes in a P-Flash sector. Supports a method of releasing MCU security by erasing all P-Flash (and D-Flash) blocks and verifying that all P-Flash (and D-Flash) blocks are erased. Supports a method of releasing MCU security by verifying a set of security keys. Specifies a user margin read level for all P-Flash blocks. Specifies a field margin read level for all P-Flash blocks (special modes only). 0x08 Erase All Blocks 0x09 Erase Flash Block Erase P-Flash Sector Unsecure Flash Verify Backdoor Access Key Set User Margin Level Set Field Margin Level 0x0A 0x0B 0x0C 0x0D 0x0E 20.4.1.5 D-Flash Commands Table 20-30 summarizes the valid D-Flash commands along with the effects of the commands on the D-Flash block. Table 20-30. D-Flash Commands FCMD 0x01 0x02 Command Erase Verify All Blocks Erase Verify Block Function on D-Flash Memory Verify that all D-Flash (and P-Flash) blocks are erased. Verify that the D-Flash block is erased. Erase all D-Flash (and P-Flash) blocks. An erase of all Flash blocks is only possible when the FPLDIS, FPHDIS, and FPOPEN bits in the FPROT register and the DPOPEN bit in the DFPROT register are set prior to launching the command. Erase a D-Flash (or P-Flash) block. An erase of the full D-Flash block is only possible when DPOPEN bit in the DFPROT register is set prior to launching the command. 0x08 Erase All Blocks 0x09 Erase Flash Block S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 637 64 KByte Flash Module (S12XFTMR64K1V1) Table 20-30. D-Flash Commands FCMD 0x0B 0x0D 0x0E 0x10 0x11 0x12 Command Unsecure Flash Set User Margin Level Set Field Margin Level Erase Verify D-Flash Section Program D-Flash Erase D-Flash Sector Function on D-Flash Memory Supports a method of releasing MCU security by erasing all D-Flash (and P-Flash) blocks and verifying that all D-Flash (and P-Flash) blocks are erased. Specifies a user margin read level for the D-Flash block. Specifies a field margin read level for the D-Flash block (special modes only). Verify that a given number of words starting at the address provided are erased. Program up to four words in the D-Flash block. Erase all bytes in a sector of the D-Flash block. 20.4.2 Flash Command Description This section provides details of all available Flash commands launched by a command write sequence. The ACCERR bit in the FSTAT register will be set during the command write sequence if any of the following illegal steps are performed, causing the command not to be processed by the Memory Controller: • Starting any command write sequence that programs or erases Flash memory before initializing the FCLKDIV register • Writing an invalid command as part of the command write sequence • For additional possible errors, refer to the error handling table provided for each command If a Flash block is read during execution of an algorithm (CCIF = 0) on that same block, the read operation will return invalid data. If the SFDIF or DFDIF flags were not previously set when the invalid read operation occurred, both the SFDIF and DFDIF flags will be set and the FECCR registers will be loaded with the global address used in the invalid read operation with the data and parity fields set to all 0. If the ACCERR or FPVIOL bits are set in the FSTAT register, the user must clear these bits before starting any command write sequence (see Section 20.3.2.7). CAUTION A Flash word or phrase must be in the erased state before being programmed. Cumulative programming of bits within a Flash word or phrase is not allowed. 20.4.2.1 Erase Verify All Blocks Command Table 20-31. Erase Verify All Blocks Command FCCOB Requirements CCOBIX[2:0] 000 0x01 FCCOB Parameters Not required The Erase Verify All Blocks command will verify that all P-Flash and D-Flash blocks have been erased. S12XS Family Reference Manual, Rev. 1.09 638 Freescale Semiconductor 64 KByte Flash Module (S12XFTMR64K1V1) Upon clearing CCIF to launch the Erase Verify All Blocks command, the Memory Controller will verify that the entire Flash memory space is erased. The CCIF flag will set after the Erase Verify All Blocks operation has completed. Table 20-32. Erase Verify All Blocks Command Error Handling Register Error Bit ACCERR FPVIOL FSTAT MGSTAT1 MGSTAT0 1 Error Condition Set if CCOBIX[2:0] != 000 at command launch None Set if any errors have been encountered during the read1 Set if any non-correctable errors have been encountered during the read1 As found in the memory map for FTMR128K1. 20.4.2.2 Erase Verify Block Command The Erase Verify Block command allows the user to verify that an entire P-Flash or D-Flash block has been erased. The FCCOB upper global address bits determine which block must be verified. Table 20-33. Erase Verify Block Command FCCOB Requirements CCOBIX[2:0] 000 0x02 FCCOB Parameters Global address [22:16] of the Flash block to be verified. Upon clearing CCIF to launch the Erase Verify Block command, the Memory Controller will verify that the selected P-Flash or D-Flash block is erased. The CCIF flag will set after the Erase Verify Block operation has completed. Table 20-34. Erase Verify Block Command Error Handling Register Error Bit ACCERR FSTAT FPVIOL MGSTAT1 MGSTAT0 1 2 Error Condition Set if CCOBIX[2:0] != 000 at command launch Set if an invalid global address [22:16] is supplied1 None Set if any errors have been encountered during the read2 Set if any non-correctable errors have been encountered during the read2 As defined by the memory map for FTMR128K1. As found in the memory map for FTMR128K1. 20.4.2.3 Erase Verify P-Flash Section Command The Erase Verify P-Flash Section command will verify that a section of code in the P-Flash memory is erased. The Erase Verify P-Flash Section command defines the starting point of the code to be verified and the number of phrases. The section to be verified cannot cross a 128 Kbyte boundary in the P-Flash memory space. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 639 64 KByte Flash Module (S12XFTMR64K1V1) Table 20-35. Erase Verify P-Flash Section Command FCCOB Requirements CCOBIX[2:0] 000 001 010 0x03 FCCOB Parameters Global address [22:16] of a P-Flash block Global address [15:0] of the first phrase to be verified Number of phrases to be verified Upon clearing CCIF to launch the Erase Verify P-Flash Section command, the Memory Controller will verify the selected section of Flash memory is erased. The CCIF flag will set after the Erase Verify P-Flash Section operation has completed. Table 20-36. Erase Verify P-Flash Section Command Error Handling Register Error Bit Error Condition Set if CCOBIX[2:0] != 010 at command launch Set if command not available in current mode (see Table 20-28) ACCERR FSTAT Set if the requested section crosses a 128 Kbyte boundary FPVIOL MGSTAT1 MGSTAT0 1 2 Set if an invalid global address [22:0] is supplied1 Set if a misaligned phrase address is supplied (global address [2:0] != 000) None Set if any errors have been encountered during the read2 Set if any non-correctable errors have been encountered during the read2 As defined by the memory map for FTMR128K1. As found in the memory map for FTMR128K1. 20.4.2.4 Read Once Command The Read Once command provides read access to a reserved 64 byte field (8 phrases) located in the nonvolatile information register of P-Flash block 0. The Read Once field is programmed using the Program Once command described in Section 20.4.2.6. The Read Once command must not be executed from the Flash block containing the Program Once reserved field to avoid code runaway. Table 20-37. Read Once Command FCCOB Requirements CCOBIX[2:0] 000 001 010 011 100 101 0x04 FCCOB Parameters Not Required Read Once phrase index (0x0000 - 0x0007) Read Once word 0 value Read Once word 1 value Read Once word 2 value Read Once word 3 value S12XS Family Reference Manual, Rev. 1.09 640 Freescale Semiconductor 64 KByte Flash Module (S12XFTMR64K1V1) Upon clearing CCIF to launch the Read Once command, a Read Once phrase is fetched and stored in the FCCOB indexed register. The CCIF flag will set after the Read Once operation has completed. Valid phrase index values for the Read Once command range from 0x0000 to 0x0007. During execution of the Read Once command, any attempt to read addresses within P-Flash block will return invalid data. Table 20-38. Read Once Command Error Handling Register Error Bit Error Condition Set if CCOBIX[2:0] != 001 at command launch ACCERR FSTAT FPVIOL MGSTAT1 MGSTAT0 None Set if any errors have been encountered during the read Set if any non-correctable errors have been encountered during the read Set if command not available in current mode (see Table 20-28) Set if an invalid phrase index is supplied 20.4.2.5 Program P-Flash Command The Program P-Flash operation will program a previously erased phrase in the P-Flash memory using an embedded algorithm. CAUTION A P-Flash phrase must be in the erased state before being programmed. Cumulative programming of bits within a Flash phrase is not allowed. Table 20-39. Program P-Flash Command FCCOB Requirements CCOBIX[2:0] 000 001 010 011 100 101 1 FCCOB Parameters 0x06 Global address [22:16] to identify P-Flash block Global address [15:0] of phrase location to be programmed1 Word 0 program value Word 1 program value Word 2 program value Word 3 program value Global address [2:0] must be 000 Upon clearing CCIF to launch the Program P-Flash command, the Memory Controller will program the data words to the supplied global address and will then proceed to verify the data words read back as expected. The CCIF flag will set after the Program P-Flash operation has completed. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 641 64 KByte Flash Module (S12XFTMR64K1V1) Table 20-40. Program P-Flash Command Error Handling Register Error Bit Error Condition Set if CCOBIX[2:0] != 101 at command launch Set if command not available in current mode (see Table 20-28) ACCERR Set if an invalid global address [22:0] is supplied1 Set if a misaligned phrase address is supplied (global address [2:0] != 000) FPVIOL MGSTAT1 MGSTAT0 1 FSTAT Set if the global address [22:0] points to a protected area Set if any errors have been encountered during the verify operation Set if any non-correctable errors have been encountered during the verify operation As defined by the memory map for FTMR128K1. 20.4.2.6 Program Once Command The Program Once command restricts programming to a reserved 64 byte field (8 phrases) in the nonvolatile information register located in P-Flash block 0. The Program Once reserved field can be read using the Read Once command as described in Section 20.4.2.4. The Program Once command must only be issued once since the nonvolatile information register in P-Flash block 0 cannot be erased. The Program Once command must not be executed from the Flash block containing the Program Once reserved field to avoid code runaway. Table 20-41. Program Once Command FCCOB Requirements CCOBIX[2:0] 000 001 010 011 100 101 0x07 FCCOB Parameters Not Required Program Once phrase index (0x0000 - 0x0007) Program Once word 0 value Program Once word 1 value Program Once word 2 value Program Once word 3 value Upon clearing CCIF to launch the Program Once command, the Memory Controller first verifies that the selected phrase is erased. If erased, then the selected phrase will be programmed and then verified with read back. The CCIF flag will remain clear, setting only after the Program Once operation has completed. The reserved nonvolatile information register accessed by the Program Once command cannot be erased and any attempt to program one of these phrases a second time will not be allowed. Valid phrase index values for the Program Once command range from 0x0000 to 0x0007. During execution of the Program Once command, any attempt to read addresses within P-Flash block 0 will return invalid data. S12XS Family Reference Manual, Rev. 1.09 642 Freescale Semiconductor 64 KByte Flash Module (S12XFTMR64K1V1) R, Table 20-42. Program Once Command Error Handling Register Error Bit Error Condition Set if CCOBIX[2:0] != 101 at command launch Set if command not available in current mode (see Table 20-28) ACCERR Set if an invalid phrase index is supplied FSTAT FPVIOL MGSTAT1 MGSTAT0 1 Set if the requested phrase has already been programmed1 None Set if any errors have been encountered during the verify operation Set if any non-correctable errors have been encountered during the verify operation If a Program Once phrase is initially programmed to 0xFFFF_FFFF_FFFF_FFFF, the Program Once command will be allowed to execute again on that same phrase. 20.4.2.7 Erase All Blocks Command Table 20-43. Erase All Blocks Command FCCOB Requirements CCOBIX[2:0] 000 0x08 FCCOB Parameters Not required The Erase All Blocks operation will erase the entire P-Flash and D-Flash memory space. Upon clearing CCIF to launch the Erase All Blocks command, the Memory Controller will erase the entire Flash memory space and verify that it is erased. If the Memory Controller verifies that the entire Flash memory space was properly erased, security will be released. During the execution of this command (CCIF=0) the user must not write to any Flash module register. The CCIF flag will set after the Erase All Blocks operation has completed. Table 20-44. Erase All Blocks Command Error Handling Register Error Bit ACCERR Set if command not available in current mode (see Table 20-28) FSTAT FPVIOL MGSTAT1 MGSTAT0 1 Error Condition Set if CCOBIX[2:0] != 000 at command launch Set if any area of the P-Flash or D-Flash memory is protected Set if any errors have been encountered during the verify operation1 Set if any non-correctable errors have been encountered during the verify operation1 As found in the memory map for FTMR128K1. 20.4.2.8 Erase Flash Block Command The Erase Flash Block operation will erase all addresses in a P-Flash or D-Flash block. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 643 64 KByte Flash Module (S12XFTMR64K1V1) Table 20-45. Erase Flash Block Command FCCOB Requirements CCOBIX[2:0] 000 001 0x09 FCCOB Parameters Global address [22:16] to identify Flash block Global address [15:0] in Flash block to be erased Upon clearing CCIF to launch the Erase Flash Block command, the Memory Controller will erase the selected Flash block and verify that it is erased. The CCIF flag will set after the Erase Flash Block operation has completed. Table 20-46. Erase Flash Block Command Error Handling Register Error Bit Error Condition Set if CCOBIX[2:0] != 001 at command launch Set if command not available in current mode (see Table 20-28) ACCERR Set if an invalid global address [22:16] is supplied1 Set if the supplied P-Flash address is not phrase-aligned or if the D-Flash address is not word-aligned FPVIOL MGSTAT1 MGSTAT0 1 2 FSTAT Set if an area of the selected Flash block is protected Set if any errors have been encountered during the verify operation2 Set if any non-correctable errors have been encountered during the verify operation2 As defined by the memory map for FTMR128K1. As found in the memory map for FTMR128K1. 20.4.2.9 Erase P-Flash Sector Command Table 20-47. Erase P-Flash Sector Command FCCOB Requirements CCOBIX[2:0] 000 001 0x0A FCCOB Parameters Global address [22:16] to identify P-Flash block to be erased The Erase P-Flash Sector operation will erase all addresses in a P-Flash sector. Global address [15:0] anywhere within the sector to be erased. Refer to Section 20.1.2.1 for the P-Flash sector size. Upon clearing CCIF to launch the Erase P-Flash Sector command, the Memory Controller will erase the selected Flash sector and then verify that it is erased. The CCIF flag will be set after the Erase P-Flash Sector operation has completed. S12XS Family Reference Manual, Rev. 1.09 644 Freescale Semiconductor 64 KByte Flash Module (S12XFTMR64K1V1) Table 20-48. Erase P-Flash Sector Command Error Handling Register Error Bit Error Condition Set if CCOBIX[2:0] != 001 at command launch Set if command not available in current mode (see Table 20-28) ACCERR Set if an invalid global address [22:16] is supplied1 Set if a misaligned phrase address is supplied (global address [2:0] != 000) FPVIOL MGSTAT1 MGSTAT0 1 FSTAT Set if the selected P-Flash sector is protected Set if any errors have been encountered during the verify operation Set if any non-correctable errors have been encountered during the verify operation As defined by the memory map for FTMR128K1. 20.4.2.10 Unsecure Flash Command The Unsecure Flash command will erase the entire P-Flash and D-Flash memory space and, if the erase is successful, will release security. Table 20-49. Unsecure Flash Command FCCOB Requirements CCOBIX[2:0] 000 0x0B FCCOB Parameters Not required Upon clearing CCIF to launch the Unsecure Flash command, the Memory Controller will erase the entire P-Flash and D-Flash memory space and verify that it is erased. If the Memory Controller verifies that the entire Flash memory space was properly erased, security will be released. If the erase verify is not successful, the Unsecure Flash operation sets MGSTAT1 and terminates without changing the security state. During the execution of this command (CCIF=0) the user must not write to any Flash module register. The CCIF flag is set after the Unsecure Flash operation has completed. Table 20-50. Unsecure Flash Command Error Handling Register Error Bit ACCERR Set if command not available in current mode (see Table 20-28) FSTAT FPVIOL MGSTAT1 MGSTAT0 1 Error Condition Set if CCOBIX[2:0] != 000 at command launch Set if any area of the P-Flash or D-Flash memory is protected Set if any errors have been encountered during the verify operation1 Set if any non-correctable errors have been encountered during the verify operation1 As found in the memory map for FTMR128K1. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 645 64 KByte Flash Module (S12XFTMR64K1V1) 20.4.2.11 Verify Backdoor Access Key Command The Verify Backdoor Access Key command will only execute if it is enabled by the KEYEN bits in the FSEC register (see Table 20-9). The Verify Backdoor Access Key command releases security if user-supplied keys match those stored in the Flash security bytes of the Flash configuration field (see Table 20-3). The Verify Backdoor Access Key command must not be executed from the Flash block containing the backdoor comparison key to avoid code runaway. Table 20-51. Verify Backdoor Access Key Command FCCOB Requirements CCOBIX[2:0] 000 001 010 011 100 0x0C Key 0 Key 1 Key 2 Key 3 FCCOB Parameters Not required Upon clearing CCIF to launch the Verify Backdoor Access Key command, the Memory Controller will check the FSEC KEYEN bits to verify that this command is enabled. If not enabled, the Memory Controller sets the ACCERR bit in the FSTAT register and terminates. If the command is enabled, the Memory Controller compares the key provided in FCCOB to the backdoor comparison key in the Flash configuration field with Key 0 compared to 0x7F_FF00, etc. If the backdoor keys match, security will be released. If the backdoor keys do not match, security is not released and all future attempts to execute the Verify Backdoor Access Key command are aborted (set ACCERR) until a reset occurs. The CCIF flag is set after the Verify Backdoor Access Key operation has completed. Table 20-52. Verify Backdoor Access Key Command Error Handling Register Error Bit Error Condition Set if CCOBIX[2:0] != 100 at command launch Set if an incorrect backdoor key is supplied ACCERR FSTAT FPVIOL MGSTAT1 MGSTAT0 Set if backdoor key access has not been enabled (KEYEN[1:0] != 10, see Section 20.3.2.2) Set if the backdoor key has mismatched since the last reset None None None 20.4.2.12 Set User Margin Level Command The Set User Margin Level command causes the Memory Controller to set the margin level for future read operations of a specific P-Flash or D-Flash block. S12XS Family Reference Manual, Rev. 1.09 646 Freescale Semiconductor 64 KByte Flash Module (S12XFTMR64K1V1) Table 20-53. Set User Margin Level Command FCCOB Requirements CCOBIX[2:0] 000 001 0x0D FCCOB Parameters Global address [22:16] to identify the Flash block Margin level setting Upon clearing CCIF to launch the Set User Margin Level command, the Memory Controller will set the user margin level for the targeted block and then set the CCIF flag. Valid margin level settings for the Set User Margin Level command are defined in Table 20-54. Table 20-54. Valid Set User Margin Level Settings CCOB (CCOBIX=001) 0x0000 0x0001 0x0002 1 2 Level Description Return to Normal Level User Margin-1 Level1 User Margin-0 Level2 Read margin to the erased state Read margin to the programmed state Table 20-55. Set User Margin Level Command Error Handling Register Error Bit Error Condition Set if CCOBIX[2:0] != 001 at command launch Set if command not available in current mode (see Table 20-28) ACCERR FSTAT FPVIOL MGSTAT1 MGSTAT0 1 Set if an invalid global address [22:16] is supplied1 Set if an invalid margin level setting is supplied None None None As defined by the memory map for FTMR128K1. NOTE User margin levels can be used to check that Flash memory contents have adequate margin for normal level read operations. If unexpected results are encountered when checking Flash memory contents at user margin levels, a potential loss of information has been detected. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 647 64 KByte Flash Module (S12XFTMR64K1V1) 20.4.2.13 Set Field Margin Level Command The Set Field Margin Level command, valid in special modes only, causes the Memory Controller to set the margin level specified for future read operations of a specific P-Flash or D-Flash block. Table 20-56. Set Field Margin Level Command FCCOB Requirements CCOBIX[2:0] 000 001 0x0E FCCOB Parameters Global address [22:16] to identify the Flash block Margin level setting Upon clearing CCIF to launch the Set Field Margin Level command, the Memory Controller will set the field margin level for the targeted block and then set the CCIF flag. Valid margin level settings for the Set Field Margin Level command are defined in Table 20-57. Table 20-57. Valid Set Field Margin Level Settings CCOB (CCOBIX=001) 0x0000 0x0001 0x0002 0x0003 0x0004 1 2 Level Description Return to Normal Level User Margin-1 Level1 User Margin-0 Level2 Field Margin-1 Level1 Field Margin-0 Level2 Read margin to the erased state Read margin to the programmed state Table 20-58. Set Field Margin Level Command Error Handling Register Error Bit Error Condition Set if CCOBIX[2:0] != 001 at command launch Set if command not available in current mode (see Table 20-28) ACCERR FSTAT FPVIOL MGSTAT1 MGSTAT0 1 Set if an invalid global address [22:16] is supplied1 Set if an invalid margin level setting is supplied None None None As defined by the memory map for FTMR128K1. CAUTION Field margin levels must only be used during verify of the initial factory programming. S12XS Family Reference Manual, Rev. 1.09 648 Freescale Semiconductor 64 KByte Flash Module (S12XFTMR64K1V1) NOTE Field margin levels can be used to check that Flash memory contents have adequate margin for data retention at the normal level setting. If unexpected results are encountered when checking Flash memory contents at field margin levels, the Flash memory contents should be erased and reprogrammed. 20.4.2.14 Erase Verify D-Flash Section Command The Erase Verify D-Flash Section command will verify that a section of code in the D-Flash is erased. The Erase Verify D-Flash Section command defines the starting point of the data to be verified and the number of words. Table 20-59. Erase Verify D-Flash Section Command FCCOB Requirements CCOBIX[2:0] 000 001 010 0x10 FCCOB Parameters Global address [22:16] to identify the D-Flash block Global address [15:0] of the first word to be verified Number of words to be verified Upon clearing CCIF to launch the Erase Verify D-Flash Section command, the Memory Controller will verify the selected section of D-Flash memory is erased. The CCIF flag will set after the Erase Verify D-Flash Section operation has completed. Table 20-60. Erase Verify D-Flash Section Command Error Handling Register Error Bit Error Condition Set if CCOBIX[2:0] != 010 at command launch Set if command not available in current mode (see Table 20-28) ACCERR FSTAT Set if the requested section breaches the end of the D-Flash block FPVIOL MGSTAT1 MGSTAT0 None Set if any errors have been encountered during the read Set if any non-correctable errors have been encountered during the read Set if an invalid global address [22:0] is supplied Set if a misaligned word address is supplied (global address [0] != 0) 20.4.2.15 Program D-Flash Command The Program D-Flash operation programs one to four previously erased words in the D-Flash block. The Program D-Flash operation will confirm that the targeted location(s) were successfully programmed upon completion. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 649 64 KByte Flash Module (S12XFTMR64K1V1) CAUTION A Flash word must be in the erased state before being programmed. Cumulative programming of bits within a Flash word is not allowed. Table 20-61. Program D-Flash Command FCCOB Requirements CCOBIX[2:0] 000 001 010 011 100 101 0x11 FCCOB Parameters Global address [22:16] to identify the D-Flash block Global address [15:0] of word to be programmed Word 0 program value Word 1 program value, if desired Word 2 program value, if desired Word 3 program value, if desired Upon clearing CCIF to launch the Program D-Flash command, the user-supplied words will be transferred to the Memory Controller and be programmed if the area is unprotected. The CCOBIX index value at Program D-Flash command launch determines how many words will be programmed in the D-Flash block. The CCIF flag is set when the operation has completed. Table 20-62. Program D-Flash Command Error Handling Register Error Bit Error Condition Set if CCOBIX[2:0] < 010 at command launch Set if CCOBIX[2:0] > 101 at command launch Set if command not available in current mode (see Table 20-28) ACCERR Set if an invalid global address [22:0] is supplied FSTAT FPVIOL MGSTAT1 MGSTAT0 Set if a misaligned word address is supplied (global address [0] != 0) Set if the requested group of words breaches the end of the D-Flash block Set if the selected area of the D-Flash memory is protected Set if any errors have been encountered during the verify operation Set if any non-correctable errors have been encountered during the verify operation 20.4.2.16 Erase D-Flash Sector Command The Erase D-Flash Sector operation will erase all addresses in a sector of the D-Flash block. Table 20-63. Erase D-Flash Sector Command FCCOB Requirements CCOBIX[2:0] 000 0x12 FCCOB Parameters Global address [22:16] to identify D-Flash block S12XS Family Reference Manual, Rev. 1.09 650 Freescale Semiconductor 64 KByte Flash Module (S12XFTMR64K1V1) Table 20-63. Erase D-Flash Sector Command FCCOB Requirements CCOBIX[2:0] 001 FCCOB Parameters Global address [15:0] anywhere within the sector to be erased. See Section 20.1.2.2 for D-Flash sector size. Upon clearing CCIF to launch the Erase D-Flash Sector command, the Memory Controller will erase the selected Flash sector and verify that it is erased. The CCIF flag will set after the Erase D-Flash Sector operation has completed. Table 20-64. Erase D-Flash Sector Command Error Handling Register Error Bit Error Condition Set if CCOBIX[2:0] != 001 at command launch Set if command not available in current mode (see Table 20-28) ACCERR Set if an invalid global address [22:0] is supplied FSTAT FPVIOL MGSTAT1 MGSTAT0 Set if a misaligned word address is supplied (global address [0] != 0) Set if the selected area of the D-Flash memory is protected Set if any errors have been encountered during the verify operation Set if any non-correctable errors have been encountered during the verify operation 20.4.3 Interrupts The Flash module can generate an interrupt when a Flash command operation has completed or when a Flash command operation has detected an ECC fault. Table 20-65. Flash Interrupt Sources Interrupt Source Flash Command Complete ECC Double Bit Fault on Flash Read ECC Single Bit Fault on Flash Read Interrupt Flag CCIF (FSTAT register) DFDIF (FERSTAT register) SFDIF (FERSTAT register) Local Enable CCIE (FCNFG register) DFDIE (FERCNFG register) SFDIE (FERCNFG register) Global (CCR) Mask I Bit I Bit I Bit NOTE Vector addresses and their relative interrupt priority are determined at the MCU level. 20.4.3.1 Description of Flash Interrupt Operation The Flash module uses the CCIF flag in combination with the CCIE interrupt enable bit to generate the Flash command interrupt request. The Flash module uses the DFDIF and SFDIF flags in combination with S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 651 64 KByte Flash Module (S12XFTMR64K1V1) the DFDIE and SFDIE interrupt enable bits to generate the Flash error interrupt request. For a detailed description of the register bits involved, refer to Section 20.3.2.5, “Flash Configuration Register (FCNFG)”, Section 20.3.2.6, “Flash Error Configuration Register (FERCNFG)”, Section 20.3.2.7, “Flash Status Register (FSTAT)”, and Section 20.3.2.8, “Flash Error Status Register (FERSTAT)”. The logic used for generating the Flash module interrupts is shown in Figure 20-27. CCIE CCIF Flash Command Interrupt Request DFDIE DFDIF SFDIE SFDIF Flash Error Interrupt Request Figure 20-27. Flash Module Interrupts Implementation 20.4.4 Wait Mode The Flash module is not affected if the MCU enters wait mode. The Flash module can recover the MCU from wait via the CCIF interrupt (see Section 20.4.3, “Interrupts”). 20.4.5 Stop Mode If a Flash command is active (CCIF = 0) when the MCU requests stop mode, the current Flash operation will be completed before the CPU is allowed to enter stop mode. 20.5 Security The Flash module provides security information to the MCU. The Flash security state is defined by the SEC bits of the FSEC register (see Table 20-10). During reset, the Flash module initializes the FSEC register using data read from the security byte of the Flash configuration field at global address 0x7F_FF0F. The security state out of reset can be permanently changed by programming the security byte of the Flash configuration field. This assumes that you are starting from a mode where the necessary P-Flash erase and program commands are available and that the upper region of the P-Flash is unprotected. If the Flash security byte is successfully programmed, its new value will take affect after the next MCU reset. The following subsections describe these security-related subjects: • Unsecuring the MCU using Backdoor Key Access • Unsecuring the MCU in Special Single Chip Mode using BDM • Mode and Security Effects on Flash Command Availability S12XS Family Reference Manual, Rev. 1.09 652 Freescale Semiconductor 64 KByte Flash Module (S12XFTMR64K1V1) 20.5.1 Unsecuring the MCU using Backdoor Key Access The MCU may be unsecured by using the backdoor key access feature which requires knowledge of the contents of the backdoor keys (four 16-bit words programmed at addresses 0x7F_FF00–0x7F_FF07). If the KEYEN[1:0] bits are in the enabled state (see Section 20.3.2.2), the Verify Backdoor Access Key command (see Section 20.4.2.11) allows the user to present four prospective keys for comparison to the keys stored in the Flash memory via the Memory Controller. If the keys presented in the Verify Backdoor Access Key command match the backdoor keys stored in the Flash memory, the SEC bits in the FSEC register (see Table 20-10) will be changed to unsecure the MCU. Key values of 0x0000 and 0xFFFF are not permitted as backdoor keys. While the Verify Backdoor Access Key command is active, P-Flash block 0 will not be available for read access and will return invalid data. The user code stored in the P-Flash memory must have a method of receiving the backdoor keys from an external stimulus. This external stimulus would typically be through one of the on-chip serial ports. If the KEYEN[1:0] bits are in the enabled state (see Section 20.3.2.2), the MCU can be unsecured by the backdoor key access sequence described below: 1. Follow the command sequence for the Verify Backdoor Access Key command as explained in Section 20.4.2.11 2. If the Verify Backdoor Access Key command is successful, the MCU is unsecured and the SEC[1:0] bits in the FSEC register are forced to the unsecure state of 10 The Verify Backdoor Access Key command is monitored by the Memory Controller and an illegal key will prohibit future use of the Verify Backdoor Access Key command. A reset of the MCU is the only method to re-enable the Verify Backdoor Access Key command. After the backdoor keys have been correctly matched, the MCU will be unsecured. After the MCU is unsecured, the sector containing the Flash security byte can be erased and the Flash security byte can be reprogrammed to the unsecure state, if desired. In the unsecure state, the user has full control of the contents of the backdoor keys by programming addresses 0x7F_FF00–0x7F_FF07 in the Flash configuration field. The security as defined in the Flash security byte (0x7F_FF0F) is not changed by using the Verify Backdoor Access Key command sequence. The backdoor keys stored in addresses 0x7F_FF00–0x7F_FF07 are unaffected by the Verify Backdoor Access Key command sequence. After the next reset of the MCU, the security state of the Flash module is determined by the Flash security byte (0x7F_FF0F). The Verify Backdoor Access Key command sequence has no effect on the program and erase protections defined in the Flash protection register, FPROT. 20.5.2 Unsecuring the MCU in Special Single Chip Mode using BDM The MCU can be unsecured in special single chip mode by erasing the P-Flash and D-Flash memory by one of the following methods: • Reset the MCU into special single chip mode, delay while the erase test is performed by the BDM, send BDM commands to disable protection in the P-Flash and D-Flash memory, and execute the Erase All Blocks command write sequence to erase the P-Flash and D-Flash memory. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 653 64 KByte Flash Module (S12XFTMR64K1V1) • Reset the MCU into special expanded wide mode, disable protection in the P-Flash and D-Flash memory and run code from external memory to execute the Erase All Blocks command write sequence to erase the P-Flash and D-Flash memory. After the CCIF flag sets to indicate that the Erase All Blocks operation has completed, reset the MCU into special single chip mode. The BDM will execute the Erase Verify All Blocks command write sequence to verify that the P-Flash and D-Flash memory is erased. If the P-Flash and D-Flash memory are verified as erased the MCU will be unsecured. All BDM commands will be enabled and the Flash security byte may be programmed to the unsecure state by the following method: • Send BDM commands to execute a ‘Program P-Flash’ command sequence to program the Flash security byte to the unsecured state and reset the MCU. 20.5.3 Mode and Security Effects on Flash Command Availability The availability of Flash module commands depends on the MCU operating mode and security state as shown in Table 20-28. 20.6 Initialization On each system reset the Flash module executes a reset sequence which establishes initial values for the Flash Block Configuration Parameters, the FPROT and DFPROT protection registers, and the FOPT and FSEC registers. The Flash module reverts to built-in default values that leave the module in a fully protected and secured state if errors are encountered during execution of the reset sequence. If a double bit fault is detected during the reset sequence, both MGSTAT bits in the FSTAT register will be set. CCIF remains clear throughout the reset sequence. The Flash module holds off all CPU access for the initial portion of the reset sequence. While Flash reads are possible when the hold is removed, writes to the FCCOBIX, FCCOBHI, and FCCOBLO registers are ignored to prevent command activity while the Memory Controller remains busy. Completion of the reset sequence is marked by setting CCIF high which enables writes to the FCCOBIX, FCCOBHI, and FCCOBLO registers to launch any available Flash command. If a reset occurs while any Flash command is in progress, that command will be immediately aborted. The state of the word being programmed or the sector/block being erased is not guaranteed. S12XS Family Reference Manual, Rev. 1.09 654 Freescale Semiconductor Appendix A Electrical Characteristics A.1 General NOTE The electrical characteristics given in this section should be used as a guide only. Values cannot be guaranteed by Freescale and are subject to change without notice. Data are currently based on characterization data of 9S12XS128 material only unless marked differently. This supplement contains the most accurate electrical information for the S12XS family microcontroller available at the time of publication. This introduction is intended to give an overview on several common topics like power supply, current injection etc. A.1.1 Parameter Classification The electrical parameters shown in this supplement are guaranteed by various methods. To give the customer a better understanding the following classification is used and the parameters are tagged accordingly in the tables where appropriate. NOTE This classification is shown in the column labeled “C” in the parameter tables where appropriate. P: C: T: Those parameters are guaranteed during production testing on each individual device. Those parameters are achieved by the design characterization by measuring a statistically relevant sample size across process variations. Those parameters are achieved by design characterization on a small sample size from typical devices under typical conditions unless otherwise noted. All values shown in the typical column are within this category. Those parameters are derived mainly from simulations. D: A.1.2 Power Supply The S12XS family utilizes several pins to supply power to the I/O ports, A/D converter, oscillator, and PLL as well as the digital core. The VDDA, VSSA pin pairs supply the A/D converter and parts of the internal voltage regulator. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 655 Electrical Characteristics The VDDX, VSSX pin pairs [2:1] supply the I/O pins. VDDR supplies the internal voltage regulator. VDDPLL, VSSPLL pin pair supply the oscillator and the PLL. VSS1, VSS2 and VSS3 are internally connected by metal. All VDDX pins are internally connected by metal. All VSSX pins are internally connected by metal. VDDA is connected to all VDDX pins by diodes for ESD protection such that VDDX must not exceed VDDA by more than a diode voltage drop. VDDA can exceed VDDX by more than a diode drop in order to support applications with a 5V A/D converter range and 3.3V I/O pin range. VSSA and VSSX are connected by anti-parallel diodes for ESD protection. NOTE In the following context VDD35 is used for either VDDA, VDDR, and VDDX; VSS35 is used for either VSSA and VSSX unless otherwise noted. IDD35 denotes the sum of the currents flowing into the VDDA and VDDR pins. The Run mode current in the VDDX domain is external load dependent. VDD is used for VDD, VSS is used for VSS1, VSS2 and VSS3. VDDPLL is used for VDDPLL, VSSPLL is used for VSSPLL IDD is used for the sum of the currents flowing into VDD, VDDF and VDDPLL. A.1.3 Pins There are four groups of functional pins. A.1.3.1 I/O Pins The I/O pins have a level in the range of 3.13V to 5.5V. This class of pins is comprised of all port I/O pins, the analog inputs, BKGD and the RESET pins. Some functionality may be disabled. For example the BKGD pin pull up is always enabled. A.1.3.2 Analog Reference This group is made up by the VRH and VRL pins. A.1.3.3 Oscillator The pins EXTAL, XTAL dedicated to the oscillator have a nominal 1.8V level. They are supplied by VDDPLL. S12XS Family Reference Manual, Rev. 1.09 656 Freescale Semiconductor Electrical Characteristics A.1.3.4 TEST This pin is used for production testing only. The TEST pin must be tied to VSS in all applications. A.1.4 Current Injection Power supply must maintain regulation within operating VDD35 or VDD range during instantaneous and operating maximum current conditions. If positive injection current (Vin > VDD35) is greater than IDD35, the injection current may flow out of VDD35 and could result in external power supply going out of regulation. Ensure external VDD35 load will shunt current greater than maximum injection current. This will be the greatest risk when the MCU is not consuming power; e.g., if no system clock is present, or if clock rate is very low which would reduce overall power consumption. A.1.5 Absolute Maximum Ratings Absolute maximum ratings are stress ratings only. A functional operation under or outside those maxima is not guaranteed. Stress beyond those limits may affect the reliability or cause permanent damage of the device. This device contains circuitry protecting against damage due to high static voltage or electrical fields; however, it is advised that normal precautions be taken to avoid application of any voltages higher than maximum-rated voltages to this high-impedance circuit. Reliability of operation is enhanced if unused inputs are tied to an appropriate logic voltage level (e.g., either VSS35 or VDD35). S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 657 Electrical Characteristics Table A-1. Absolute Maximum Ratings1 Num Rating I/O, regulator and analog supply voltage Digital logic supply voltage2 PLL supply voltage2 NVM supply voltage2 Voltage difference VDDX to VDDA Voltage difference VSSX to VSSA Digital I/O input voltage Analog reference EXTAL, XTAL Instantaneous maximum current Single pin limit for all digital I/O pins3 Instantaneous maximum current Single pin limit for EXTAL, XTAL4 Maximum current Single pin limit for power supply pins Storage temperature range Symbol VDD35 VDD VDDPLL VDDF ∆VDDX ∆VSSX VIN VRH, VRL VILV I I D Min –0.3 –0.3 –0.3 –0.3 –6.0 –0.3 –0.3 –0.3 –0.3 –25 –25 –100 –65 Max 6.0 2.16 2.16 3.6 0.3 0.3 6.0 6.0 2.16 +25 +25 +100 155 Unit V V V V V V V V V mA mA mA °C 1 2 3 4 5 6 7 8 9 11 12 14 15 1 2 DL IDV Tstg Beyond absolute maximum ratings device might be damaged. The device contains an internal voltage regulator to generate the logic and PLL supply out of the I/O supply. The absolute maximum ratings apply when the device is powered from an external source. 3 All digital I/O pins are internally clamped to VSSX and VDDX, or VSSA and VDDA. 4 Those pins are internally clamped to VSSPLL and VDDPLL. A.1.6 ESD Protection and Latch-up Immunity All ESD testing is in conformity with CDF-AEC-Q100 stress test qualification for automotive grade integrated circuits. During the device qualification ESD stresses were performed for the Human Body Model (HBM) and the Charge Device Model. A device will be defined as a failure if after exposure to ESD pulses the device no longer meets the device specification. Complete DC parametric and functional testing is performed per the applicable device specification at room temperature followed by hot temperature, unless specified otherwise in the device specification. S12XS Family Reference Manual, Rev. 1.09 658 Freescale Semiconductor Electrical Characteristics Table A-2. ESD and Latch-up Test Conditions Model Human Body Series resistance Storage capacitance Number of pulse per pin Positive Negative Charged Device Number of pulse per pin Positive Negative Latch-up Minimum input voltage limit Maximum input voltage limit Description Symbol R1 C — — — — — — Value 1500 100 1 1 3 3 –2.5 7.5 V V Unit Ohm pF Table A-3. ESD and Latch-Up Protection Characteristics Num 1 2 3 C C C C Rating Human Body Model (HBM) Charge Device Model (CDM) corner pins Charge Device Model (CDM) edge pins Latch-up current at TA = 125°C Positive Negative Latch-up current at TA = 27°C Positive Negative Symbol VHBM VCDM ILAT +100 –100 ILAT +200 –200 — — — — mA Min 2000 750 500 Max — — — Unit V V mA 4 C A.1.7 Operating Conditions This section describes the operating conditions of the device. Unless otherwise noted those conditions apply to all the following data. NOTE Please refer to the temperature rating of the device (C, V, M) with regards to the ambient temperature TA and the junction temperature TJ. For power dissipation calculations refer to Section A.1.8, “Power Dissipation and Thermal Characteristics”. Table A-4. Operating Conditions Rating I/O, regulator and analog supply voltage NVM logic supply voltage 1 Symbol VDD35 VDDF ∆VDDX Min 3.13 2.7 Typ 5 2.8 Max 5.5 2.9 Unit V V Voltage difference VDDX to VDDA refer to Table A-14 S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 659 Electrical Characteristics Table A-4. Operating Conditions Voltage difference VDDR to VDDX Voltage difference VSSX to VSSA Voltage difference VSS1 , VSS2 , VSS3 , VSSPLL to VSSX Digital logic supply voltage1 PLL supply voltage Oscillator (Loop Controlled Pierce) (Full Swing Pierce) Bus frequency3 Temperature Option C Operating junction temperature range Operating ambient temperature range4 Temperature Option V Operating junction temperature range Operating ambient temperature range4 2 ∆VDDR ∆VSSX ∆VSS VDD VDDPLL fosc fbus TJ TA TJ TA -0.1 0 0.1 V refer to Table A-14 -0.1 1.72 1.72 4 2 0.5 –40 –40 –40 –40 0 1.8 1.8 — — — — 27 — 27 0.1 1.98 1.98 16 40 40 110 85 °C 130 105 V V V MHz MHz °C Temperature Option M °C Operating junction temperature range TJ –40 — 150 Operating ambient temperature range4 TA –40 27 125 The device contains an internal voltage regulator to generate the logic and PLL supply out of the I/O supply. 1 2 This refers to the oscillator base frequency. Typical crystal & resonator tolerances are supported. 3 Please refer to Table A-24 for maximum bus frequency limits with frequency modulation enabled 4 Please refer to Section A.1.8, “Power Dissipation and Thermal Characteristics” for more details about the relation between ambient temperature TA and device junction temperature TJ. NOTE Using the internal voltage regulator, operation is guaranteed in a power down until a low voltage reset assertion. A.1.8 Power Dissipation and Thermal Characteristics Power dissipation and thermal characteristics are closely related. The user must assure that the maximum operating junction temperature is not exceeded. The average chip-junction temperature (TJ) in °C can be obtained from: T T T J A D = Junction Temperature, [ ° C ] = Ambient Temperature, [ ° C ] = Total Chip Power Dissipation, [W] = Package Thermal Resistance, [ ° C/W] J = T + (P • Θ ) A D JA P Θ JA S12XS Family Reference Manual, Rev. 1.09 660 Freescale Semiconductor Electrical Characteristics The total power dissipation can be calculated from: P P D =P INT +P IO INT = Chip Internal Power Dissipation, [W] 2 P = R ⋅I IO DSON IO i i ∑ PIO is the sum of all output currents on I/O ports associated with VDDX, whereby R V OL = ----------- ;for outputs driven low DSON I OL R V –V DD 35 OH = -------------------------------------- ;for outputs driven high DSON I OH Two cases with internal voltage regulator enabled and disabled must be considered: 1. Internal voltage regulator disabled P INT =I DD ⋅V DD +I DDPLL ⋅V DDPLL +I DDA ⋅V DDA 2. Internal voltage regulator enabled P INT =I DDR ⋅V DDR +I DDA ⋅V DDA S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 661 Electrical Characteristics Table A-5. Thermal Package Characteristics (9S12XS256)1 Num C Rating LQFP 112 1 2 3 4 5 D D D D D Thermal resistance LQFP 112, single sided PCB2 Thermal resistance LQFP 112, double sided PCB with 2 internal planes3 Junction to Board LQFP 112 Junction to Case LQFP 1124 Junction to Package Top LQFP 1125 QFP 80 6 7 8 9 10 D D D D D Thermal resistance QFP 80, single sided PCB 2 Symbol Min Typ Max Unit θJA θJA θJB θJC ΨJT θJA θJA θJB θJC — — — — — — — — — — 62 51 39 16 3 °C/W °C/W °C/W °C/W °C/W °C/W °C/W °C/W °C/W °C/W °C/W °C/W °C/W °C/W — — — — — — — — — — 57 45 29 20 5 Thermal resistance QFP 80, double sided PCB with 2 internal planes3 Junction to Board QFP 80 Junction to Case QFP 804 Junction to Package Top QFP 80 5 ΨJT LQFP 64 θJA θJA θJB θJC 5 11 12 13 14 D D D D Thermal resistance LQFP 64, single sided PCB2 Thermal resistance LQFP 64, double sided PCB with 2 internal planes3 Junction to Board LQFP 64 Junction to Case LQFP 64 4 — — — — — — — — 68 50 32 15 1 2 3 4 5 ΨJT — — 3 °C/W 15 D Junction to Package Top LQFP 64 The values for thermal resistance are achieved by package simulations Junction to ambient thermal resistance, θJA was simulated to be equivalent to the JEDEC specification JESD51-2 in a horizontal configuration in natural convection. Junction to ambient thermal resistance, θJA was simulated to be equivalent to the JEDEC specification JESD51-7 in a horizontal configuration in natural convection. Junction to case thermal resistance was simulated to be equivalent to the measured values using the cold plate technique with the cold plate temperature used as the “case” temperature. This basic cold plate measurement technique is described by MILSTD 883D, Method 1012.1. This is the correct thermal metric to use to calculate thermal performance when the package is being used with a heat sink. Thermal characterization parameter ΨJT is the “resistance” from junction to reference point thermocouple on top center of the case as defined in JESD51-2. ΨJT is a useful value to use to estimate junction temperature in a steady state customer enviroment. S12XS Family Reference Manual, Rev. 1.09 662 Freescale Semiconductor Electrical Characteristics Table A-6. Thermal Package Characteristics (9S12XS128)1 Num C Rating LQFP 112 1 2 3 4 5 D D D D D Thermal resistance LQFP 112, single sided PCB2 Thermal resistance LQFP 112, double sided PCB with 2 internal planes3 Junction to Board LQFP 112 Junction to Case LQFP 112 4 5 Symbol Min Typ Max Unit θJA θJA θJB θJC ΨJT — — — — — — — — — — 58 48 36 14 2 °C/W °C/W °C/W °C/W °C/W °C/W °C/W °C/W °C/W °C/W °C/W °C/W °C/W °C/W Junction to Package Top LQFP 112 QFP 80 6 7 8 9 10 D D D D D Thermal resistance QFP 80, single sided PCB2 Thermal resistance QFP 80, double sided PCB with 2 internal planes3 Junction to Board QFP 80 Junction to Case QFP 80 4 θJA θJA θJB θJC ΨJT — — — — — — — — — — 56 43 28 19 5 Junction to Package Top QFP 805 LQFP 64 11 12 13 14 D D D D Thermal resistance LQFP 64, single sided PCB2 Thermal resistance LQFP 64, double sided PCB with 2 internal planes3 Junction to Board LQFP 64 Junction to Case LQFP 644 θJA θJA θJB θJC — — — — — — — — 64 46 28 13 1 2 3 4 5 ΨJT — — 2 °C/W 15 D Junction to Package Top LQFP 645 The values for thermal resistance are achieved by package simulations Junction to ambient thermal resistance, θJA was simulated to be equivalent to the JEDEC specification JESD51-2 in a horizontal configuration in natural convection. Junction to ambient thermal resistance, θJA was simulated to be equivalent to the JEDEC specification JESD51-7 in a horizontal configuration in natural convection. Junction to case thermal resistance was simulated to be equivalent to the measured values using the cold plate technique with the cold plate temperature used as the “case” temperature. This basic cold plate measurement technique is described by MILSTD 883D, Method 1012.1. This is the correct thermal metric to use to calculate thermal performance when the package is being used with a heat sink. Thermal characterization parameter ΨJT is the “resistance” from junction to reference point thermocouple on top center of the case as defined in JESD51-2. ΨJT is a useful value to use to estimate junction temperature in a steady state customer enviroment. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 663 Electrical Characteristics A.1.9 I/O Characteristics Table A-7. 3.3-V I/O Characteristics This section describes the characteristics of all I/O pins except EXTAL, XTAL, TEST and supply pins. Conditions are 3.13 V < VDD35 < 3.6 V junction temperature from –40°C to +150°C, unless otherwise noted I/O Characteristics for all I/O pins except EXTAL, XTAL,TEST and supply pins. Num C 1 P Input high voltage T Input high voltage 2 P Input low voltage T Input low voltage 3 4a T Input hysteresis P Input leakage current (pins in high impedance input mode)1 Vin = VDD35 or VSS35 M Temperature range -40°C to 150°C V Temperature range -40°C to 130°C C Temperature range -40°C to 110°C C Input leakage current (pins in high impedance input mode) Vin = VDD35 or VSS35 −40°C 27°C 70°C 85°C 100°C 105°C 110°C 120°C 125°C 130°C 150°C C Output high voltage (pins in output mode) Partial drive IOH = –0.75 mA P Output high voltage (pins in output mode) Full drive IOH = –4 mA C Output low voltage (pins in output mode) Partial Drive IOL = +0.9 mA P Output low voltage (pins in output mode) Full Drive IOL = +4.75 mA P Internal pull up resistance VIH min > input voltage > VIL max P Internal pull down resistance VIH min > input voltage > VIL max D Input capacitance T Injection current Single pin limit Total device limit, sum of all injected currents 2 Rating Symbol VIH VIH VIL VIL VHYS I in Min 0.65*VDD35 — — VSS35 – 0.3 — Typ — — — — 250 Max — VDD35 + 0.3 0.35*VDD35 — — Unit V V V V mV –1 –0.75 –0.5 I in — — — — — ±1 ±1 ±8 ±14 ±26 ±32 ±40 ±60 ±74 ±92 ±240 — — — — — — 6 — 1 0.75 0.5 — µA 4b — nA 5 6 7 8 9 10 11 12 V OH VDD35 – 0.4 VDD35 – 0.4 — — 25 25 — –2.5 –25 — — 0.4 0.4 50 50 — 2.5 25 V V V V KΩ KΩ pF mA VOH VOL V OL RPUL RPDH Cin IICS IICP S12XS Family Reference Manual, Rev. 1.09 664 Freescale Semiconductor Electrical Characteristics Table A-7. 3.3-V I/O Characteristics Conditions are 3.13 V < VDD35 < 3.6 V junction temperature from –40°C to +150°C, unless otherwise noted I/O Characteristics for all I/O pins except EXTAL, XTAL,TEST and supply pins. 13 14 15 16 17 P Port H, J, P interrupt input pulse filtered (STOP)3 P Port H, J, P interrupt input pulse passed (STOP) D Port H, J, P interrupt input pulse filtered (STOP) D Port H, J, P interrupt input pulse passed (STOP) D IRQ pulse width, edge-sensitive mode (STOP) 3 tPULSE tPULSE tPULSE tPULSE PWIRQ — 10 — 4 1 4 — — — — — — 3 — 3 — — — µs µs tcyc tcyc tcyc tosc PWXIRQ 18 D XIRQ pulse width with X-bit set (STOP) Maximum leakage current occurs at maximum operating temperature. 1 2 Refer to Section A.1.4, “Current Injection” for more details 3 Parameter only applies in stop or pseudo stop mode. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 665 Electrical Characteristics Table A-8. 5-V I/O Characteristics Conditions are 4.5 V < VDD35 < 5.5 V junction temperature from –40°C to +150°C, unless otherwise noted I/O Characteristics for all I/O pins except EXTAL, XTAL,TEST and supply pins. Num C 1 P Input high voltage T Input high voltage 2 P Input low voltage T Input low voltage 3 4a T Input hysteresis P Input leakage current (pins in high impedance input mode)1 Vin = VDD35 or VSS35 M Temperature range -40°C to 150°C V Temperature range -40°C to 130°C C Temperature range -40°C to 110°C C Input leakage current (pins in high impedance input mode) Vin = VDD35 or VSS35 −40°C 27°C 70°C 85°C 100°C 105°C 110°C 120°C 125°C 130°C 150°C C Output high voltage (pins in output mode) Partial drive IOH = –2 mA P Output high voltage (pins in output mode) Full drive IOH = –10 mA C Output low voltage (pins in output mode) Partial drive IOL = +2 mA P Output low voltage (pins in output mode) Full drive IOL = +10 mA P Internal pull up resistance VIH min > input voltage > VIL max P Internal pull down resistance VIH min > input voltage > VIL max D Input capacitance T Injection current Single pin limit Total device Limit, sum of all injected currents P Port H, J, P interrupt input pulse filtered (STOP)3 P Port H, J, P interrupt input pulse passed (STOP) D Port H, J, P interrupt input pulse filtered (STOP) 3 2 Rating Symbol V IH Min 0.65*VDD35 — — VSS35 – 0.3 — Typ — — — — 250 Max — VDD35 + 0.3 0.35*VDD35 — — Unit V V V V mV VIH VIL VIL VHYS I in –1 –0.75 –0.5 I in — — — — — ±1 ±1 ±8 ±14 ±26 ±32 40 ±60 ±74 ±92 ±240 — — — — — — 6 — 1 0.75 0.5 — µA 4b — nA 5 6 7 8 9 10 11 12 V OH VDD35 – 0.8 VDD35 – 0.8 — — 25 25 — –2.5 –25 — 10 — — — 0.8 0.8 50 50 — 2.5 25 V V V V KΩ KΩ pF mA VOH VOL V OL RPUL RPDH Cin IICS IICP tPULSE tPULSE tPULSE 13 14 15 — — — 3 — 3 µs µs tcyc S12XS Family Reference Manual, Rev. 1.09 666 Freescale Semiconductor Electrical Characteristics Table A-8. 5-V I/O Characteristics Conditions are 4.5 V < VDD35 < 5.5 V junction temperature from –40°C to +150°C, unless otherwise noted I/O Characteristics for all I/O pins except EXTAL, XTAL,TEST and supply pins. 16 17 D Port H, J, P interrupt input pulse passed (STOP) D IRQ pulse width, edge-sensitive mode (STOP) tPULSE PWIRQ 4 1 4 — — — — — — tcyc tcyc tosc PWXIRQ 18 D XIRQ pulse width with X-bit set (STOP) Maximum leakage current occurs at maximum operating temperature. 1 2 Refer to Section A.1.4, “Current Injection” for more details 3 Parameter only applies in stop or pseudo stop mode. A.1.10 Supply Currents This section describes the current consumption characteristics of the device as well as the conditions for the measurements. A.1.10.1 Typical Run Current Measurement Conditions Since the current consumption of the output drivers is load dependent, all measurements are without output loads and with minimum I/O activity. The currents are measured in single chip mode, S12XCPU code is executed from Flash. VDD35=5V, internal voltage regulator is enabled and the bus frequency is 40MHz using a 4MHz oscillator in loop controlled Pierce mode. Since the DBG and BDM modules are typically not used in the end application, the supply current values for these modules is not specified. An overhead of current consumption exists independent of the listed modules, due to voltage regulation and clock logic that is not dedicated to a specific module. This is listed in the table row named “overhead”. Table A-9 shows the configuration of the peripherals for typical run current. Table A-9. Module Configurations for Typical Run Supply (VDDR+VDDA) Current VDD35=5V Peripheral S12XCPU MSCAN SPI SCI PWM TIM ATD Overhead Configuration 420 cycle loop: 384 DBNE cycles plus subroutine entry to stimulate stacking (RAM access) Configured to loop-back mode using a bit rate of 500kbit/s Configured to master mode, continuously transmit data (0x55 or 0xAA) at 2Mbit/s Configured into loop mode, continuously transmit data (0x55) at speed of 19200 baud Configured to toggle its pins at the rate of 1kHz The peripheral shall be configured in output compare mode. Pulse accumulator and modulus counter enabled. The peripheral is configured to operate at its maximum specified frequency and to continuously convert voltages on all input channels in sequence. VREG supplying 1.8V from a 5V input voltage, PLL on A.1.10.2 Maximum Run Current Measurement Conditions Currents are measured in single chip mode, S12XCPU with VDD35=5.5V, internal voltage regulator enabled and a 40MHz bus frequency from a 4MHz input. Characterized parameters are derived using a S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 667 Electrical Characteristics 4MHz loop controlled Pierce oscillator. Production test parameters are tested with a 4MHz square wave oscillator. Table A-10 shows the configuration of the peripherals for maximum run current Table A-10. Module Configurations for Maximum Run Supply (VDDR+VDDA) Current VDD35=5.5V Peripheral S12XCPU MSCAN SPI SCI PWM TIM ATD Overhead Configuration 420 cycle loop: 384 DBNE cycles plus subroutine entry to stimulate stacking (RAM access) Configured to loop-back mode using a bit rate of 1Mbit/s Configured to master mode, continuously transmit data (0x55 or 0xAA) at 4Mbit/s Configured into loop mode, continuously transmit data (0x55) at speed of 57600 baud Configured to toggle its pins at the rate of 40kHz The peripheral shall be configured in output compare mode. Pulse accumulator and modulus counter enabled. The peripheral is configured to operate at its maximum specified frequency and to continuously convert voltages on all input channels in sequence. VREG supplying 1.8V from a 5V input voltage, PLL on A.1.10.3 Stop Current Conditions Unbonded ports must be correctly initialized to prevent current consumption due to floating inputs. Typical Stop current is measured with VDD35=5V, maximum Stop current is measured with VDD35=5.5V. Pseudo Stop currents are measured with the oscillator configured for 4MHz LCP mode. Production test parameters are tested with a 4MHz square wave oscillator. A.1.10.4 Measurement Results Table A-11. Module Run Supply Currents Conditions are shown in Table A-9 at ambient temperature unless otherwise noted Num 1 2 3 4 5 6 7 8 C T T T T T T T T Rating S12XCPU MSCAN SPI SCI PWM TIM ATD Overhead Min — — — — — — — — Typ 1.1 0.5 0.4 0.6 0.9 0.3 1.7 13.6 Max — — — — — — — — Unit mA S12XS Family Reference Manual, Rev. 1.09 668 Freescale Semiconductor Electrical Characteristics Table A-12. Run and Wait Current Characteristics Conditions are shown in Table A-4 unless otherwise noted Num C Rating Peripheral Set1 fosc=4MHz, fbus=40MHz Peripheral Set1 Device 9S12XS256 fosc=4MHz, fbus=40MHz Peripheral Set1 fosc=4MHz, fbus=40MHz fosc=4MHz, fbus=20MHz fosc=4MHz, fbus=8MHz Peripheral Set2 fosc=4MHz, fbus=40MHz fosc=4MHz, fbus=20MHz fosc=4MHz, fbus=8MHz Peripheral Set3 fosc=4MHz, fbus=40MHz fosc=4MHz, fbus=20MHz fosc=4MHz, fbus=8MHz Peripheral Set4 fosc=4MHz, fbus=40MHz fosc=4MHz, fbus=20MHz fosc=4MHz, fbus=8MHz Peripheral Set5 fosc=4MHz, fbus=40MHz fosc=4MHz, fbus=20MHz fosc=4MHz, fbus=8MHz Wait supply current 7 7a 8 T T 1 2 3 4 5 Symbol Min Typ Max Unit Run supply current (No external load, Peripheral Configuration see Table A-10.) 1 1a P P IDD35 — IDD35 — IDD35 — — — — — — — — — — — — — — — IDDW — — — — — 22 12.5 7 21 12 7 21 11 6 21 11 6 21 11 5 11 16 10 5.4 1.8 — — — — — — — — — — — — — — — 22 24 — — 4 mA — 35 mA — 32 mA mA Run supply current (No external load, Peripheral Configuration see Table A-9.) 2 C T T 3 T T T 4 T T T 5 T T T 6 T T T P P Peripheral Set ,PLL on Peripheral Set ,PLL on, Device 9S12XS256 Peripheral Set fosc=4MHz, fbus=40MHz fosc=4MHz, fbus=8MHz 2 1 1 9 C All modules disabled, RTI enabled, PLL off The following peripherals are on: ATD0/TIM/PWM/SPI0/SCI0-SCI1/CAN0 The following peripherals are on: ATD0/TIM/PWM/SPI0/SCI0-SCI1 The following peripherals are on: ATD0/TIM/PWM/SPI0 The following peripherals are on: ATD0/TIM/PWM The following peripherals are on: ATD0/TIM S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 669 Electrical Characteristics Table A-13. Pseudo Stop and Full Stop Current Conditions are shown in Table A-4 unless otherwise noted Num C –40°C 27°C 70°C 85°C 105°C 110°C 130°C 150°C –40°C 27°C 110°C 130°C 150°C 27°C 70°C 85°C 105°C 125°C 150°C Stop Current 12 P P C C C C C C P T T T T T T T T –40°C 27°C 70°C 85°C 105°C 110°C 125°C 130°C 150°C –40°C 27°C 85°C 110°C 130°C 27°C 85°C 125°C IDDS — — — — — — — — — — — — — — — — — 20 25 40 65 80 95 220 250 380 25 40 70 100 255 190 230 400 60 80 — — — — — — 2000 — — — — — — — — µA Rating Symbol Min Typ Max Unit µA Pseudo stop current (API, RTI, and COP disabled) PLL off, LCP mode 10a C C C C C C C C P P P P P C C C C C C IDDPS — — — — — — — — — — — — — — — — — — — 155 171 199 216 233 270 350 452 60 70 160 210 400 186 209 245 270 383 487 300 400 — — — — — — 80 100 2400 2400 2400 — — — — — — Pseudo stop current (API, RTI, and COP disabled) PLL off, FSP mode 10b IDDPS µA Pseudo stop current (API, RTI, and COP enabled) PLL off, LCP mode 11 IDDPS µA Stop Current (API active) 13 IDDS µA Stop Current (ATD active) 14 IDDS µA S12XS Family Reference Manual, Rev. 1.09 670 Freescale Semiconductor Electrical Characteristics A.2 ATD Characteristics This section describes the characteristics of the analog-to-digital converter. A.2.1 ATD Operating Characteristics The Table A-14 and Table A-15 show conditions under which the ATD operates. The following constraints exist to obtain full-scale, full range results: VSSA ≤ VRL ≤ VIN ≤ VRH ≤ VDDA. This constraint exists since the sample buffer amplifier can not drive beyond the power supply levels that it ties to. If the input level goes outside of this range it will effectively be clipped. Table A-14. ATD Operating Characteristics Conditions are shown in Table A-4 unless otherwise noted, supply voltage 3.13 V < VDDA < 5.5 V Num C 1 D Reference potential Low High D Voltage difference VDDX to VDDA D Voltage difference VSSX to VSSA C Differential reference voltage1 C ATD Clock Frequency (derived from bus clock via the prescaler bus) P ATD Clock Frequency in Stop mode (internal generated temperature and voltage dependent clock, ICLK) D ADC conversion in stop, recovery time2 tATDSTPRCV Rating Symbol VRL VRH ∆VDDX ∆VSSX VRH-VRL fATDCLk 0.6 — 1 — 1.7 1.5 MHz µs Min VSSA VDDA/2 –2.35 –0.1 3.13 0.25 Typ — — 0 0 5.0 — Max VDDA/2 VDDA 0.1 0.1 5.5 8.3 Unit V V V V V MHz 2 3 4 5 6 7 ATD Conversion Period3 42 ATD 20 NCONV12 — 8 D 12 bit resolution: 41 clock 19 NCONV10 — 10 bit resolution: 39 cycles 17 NCONV8 — 8 bit resolution: 1 Full accuracy is not guaranteed when differential voltage is less than 4.50 V 2 When converting in Stop Mode (ICLKSTP=1) an ATD Stop Recovery time tATDSTPRCV is required to switch back to bus clock based ATDCLK when leaving Stop Mode. Do not access ATD registers during this time. 3 The minimum time assumes a sample time of 4 ATD clock cycles. The maximum time assumes a sample time of 24 ATD clock cycles and the discharge feature (SMP_DIS) enabled, which adds 2 ATD clock cycles. A.2.2 Factors Influencing Accuracy Source resistance, source capacitance and current injection have an influence on the accuracy of the ATD. A further factor is that PortAD pins that are configured as output drivers switching. A.2.2.1 Port AD Output Drivers Switching PortAD output drivers switching can adversely affect the ATD accuracy whilst converting the analog voltage on other PortAD pins because the output drivers are supplied from the VDDA/VSSA ATD supply pins. Although internal design measures are implemented to minimize the affect of output driver noise, it S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 671 Electrical Characteristics is recommended to configure PortAD pins as outputs only for low frequency, low load outputs. The impact on ATD accuracy is load dependent and not specified. The values specified are valid under condition that no PortAD output drivers switch during conversion. A.2.2.2 Source Resistance Due to the input pin leakage current as specified in Table A-7 and Table A-8 in conjunction with the source resistance there will be a voltage drop from the signal source to the ATD input. The maximum source resistance RS specifies results in an error (10-bit resolution) of less than 1/2 LSB (2.5 mV) at the maximum leakage current. If device or operating conditions are less than worst case or leakage-induced error is acceptable, larger values of source resistance of up to 10Kohm are allowed. A.2.2.3 Source Capacitance When sampling an additional internal capacitor is switched to the input. This can cause a voltage drop due to charge sharing with the external and the pin capacitance. For a maximum sampling error of the input voltage ≤ 1LSB (10-bit resilution), then the external filter capacitor, Cf ≥ 1024 * (CINS–CINN). A.2.2.4 Current Injection There are two cases to consider. 1. A current is injected into the channel being converted. The channel being stressed has conversion values of $3FF (in 10-bit mode) for analog inputs greater than VRH and $000 for values less than VRL unless the current is higher than specified as disruptive condition. 2. Current is injected into pins in the neighborhood of the channel being converted. A portion of this current is picked up by the channel (coupling ratio K), This additional current impacts the accuracy of the conversion depending on the source resistance. The additional input voltage error on the converted channel can be calculated as: VERR = K * RS * IINJ with IINJ being the sum of the currents injected into the two pins adjacent to the converted channel. S12XS Family Reference Manual, Rev. 1.09 672 Freescale Semiconductor Electrical Characteristics Table A-15. ATD Electrical Characteristics Conditions are shown in Table A-4 unless otherwise noted Num C 1 2 3 4 5 Rating Symbol RS CINN CINS RINA INA Kp Kn Min — — — — –2.5 — — Typ — — — 5 — — — Max 1 10 16 15 2.5 1E-4 3E-3 Unit KΩ pF kΩ mA A/A A/A C Max input source resistance1 D Total input capacitance Non sampling Total input capacitance Sampling D Input internal Resistance C Disruptive analog input current C Coupling ratio positive current injection 6 C Coupling ratio negative current injection Refer to A.2.2.2 for further information concerning source resistance 1 A.2.3 ATD Accuracy Table A-16 and Table A-17 specifies the ATD conversion performance excluding any errors due to current injection, input capacitance and source resistance. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 673 Electrical Characteristics A.2.3.1 ATD Accuracy Definitions For the following definitions see also Figure A-1. Differential non-linearity (DNL) is defined as the difference between two adjacent switching steps. V –V i i–1 DNL ( i ) = -------------------------- – 1 1LSB The integral non-linearity (INL) is defined as the sum of all DNLs: INL ( n ) = i=1 ∑ n V –V n 0 DNL ( i ) = -------------------- – n 1LSB S12XS Family Reference Manual, Rev. 1.09 674 Freescale Semiconductor Electrical Characteristics DNL Vi-1 $3FF $3FE $3FD $3FC $3FB $3FA $3F9 $3F8 $3F7 $3F6 $3F5 $3F4 10-Bit Resolution $3F3 LSB 10-Bit Absolute Error Boundary Vi 8-Bit Absolute Error Boundary $FF $FE $FD 8-Bit Resolution Vin mV 9 8 7 6 5 4 3 2 1 0 5 10 15 20 25 30 35 40 45 55 60 Ideal Transfer Curve 2 10-Bit Transfer Curve 1 8-Bit Transfer Curve 65 70 75 80 85 90 95 100 105 110 115 120 5000 + Figure A-1. ATD Accuracy Definitions NOTE Figure A-1 shows only definitions, for specification values refer to Table A16 and Table A-17. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 675 Electrical Characteristics Table A-16. ATD Conversion Performance 5V range Conditions are shown in Table A-4. unless otherwise noted. VREF = VRH - VRL = 5.12V. fATDCLK = 8.0MHz The values are tested to be valid with no PortAD output drivers switching simultaneous with conversions. Num C 1 2 3 4 5 6 7 8 9 10 11 P Resolution P Differential Nonlinearity P Integral Nonlinearity P Absolute Error3 C Resolution C Differential Nonlinearity C Integral Nonlinearity C Absolute Error3 C Resolution C Differential Nonlinearity C Integral Nonlinearity Rating1,2 12-Bit 12-Bit 12-Bit 12-Bit 10-Bit 10-Bit 10-Bit 10-Bit 8-Bit 8-Bit 8-Bit Symbol LSB DNL INL AE LSB DNL INL AE LSB DNL INL Min — -4 -5 -7 — -1 -2 -3 — -0.5 -1 Typ 1.25 ±2 ±2.5 ±4 5 ±0.5 ±1 ±2 20 ±0.3 ±0.5 Max — 4 5 7 — 1 2 3 — 0.5 1 Unit mV counts counts counts mV counts counts counts mV counts counts 8-Bit AE -1.5 ±1 1.5 counts 12 C Absolute Error3 1 The 8-bit and 10-bit mode operation is structurally tested in production test. Absolute values are tested in 12-bit mode. 2 Better performance is possible using specially designed multi-layer PCBs or averaging techniques. 3 These values include the quantization error which is inherently 1/2 count for any A/D converter. Table A-17. ATD Conversion Performance 3.3V range Conditions are shown in Table A-4. unless otherwise noted. VREF = VRH - VRL = 3.3V. fATDCLK = 8.0MHz The values are tested to be valid with no PortAD output drivers switching simultaneous with conversions. Num C 1 2 3 4 5 6 7 8 9 10 11 P Resolution P Differential Nonlinearity P Integral Nonlinearity P Absolute Error C Resolution C Differential Nonlinearity C Integral Nonlinearity C Absolute Error C Resolution C Differential Nonlinearity C Integral Nonlinearity 3 3 3 Rating1,2 12-Bit 12-Bit 12-Bit 12-Bit 10-Bit 10-Bit 10-Bit 10-Bit 8-Bit 8-Bit 8-Bit Symbol LSB DNL INL AE LSB DNL INL AE LSB DNL INL Min — -6 -7 -8 — -1.5 -2 -3 — -0.5 -1 Typ 0.80 ±3 ±3 ±4 3.22 ±1 ±1 ±2 12.89 ±0.3 ±0.5 Max — 6 7 8 — 1.5 2 3 — 0.5 1 Unit mV counts counts counts mV counts counts counts mV counts counts 8-Bit AE -1.5 ±1 1.5 counts 12 C Absolute Error The 8-bit and 10-bit mode operation is structurally tested in production test. Absolute values are tested in 12-bit mode. 1 2 Better performance is possible using specially designed multi-layer PCBs or averaging techniques. 3 These values include the quantization error which is inherently 1/2 count for any A/D converter. S12XS Family Reference Manual, Rev. 1.09 676 Freescale Semiconductor Electrical Characteristics A.3 A.3.1 NVM, Flash Timing Parameters The time base for all NVM program or erase operations is derived from the oscillator. A minimum oscillator frequency fNVMOSC is required for performing program or erase operations. The NVM modules do not have any means to monitor the frequency and will not prevent program or erase operation at frequencies above or below the specified minimum. When attempting to program or erase the NVM modules at a lower frequency, a full program or erase transition is not assured. The program and erase operations are timed using a clock derived from the oscillator using the FCLKDIV register. The frequency of this clock must be set within the limits specified as fNVMOP. The minimum program and erase times shown in Table A-18 are calculated for maximum fNVMOP and maximum fNVMBUS unless otherwise shown. The maximum times are calculated for minimum fNVMOP A.3.1.1 Erase Verify All Blocks (Blank Check) (FCMD=0x01) The time it takes to perform a blank check is dependant on the location of the first non-blank word starting at relative address zero. It takes one bus cycle per phrase to verify plus a setup of the command. Assuming that no non blank location is found, then the erase verify all blocks is given by. 1 t check = 33500 ⋅ -------------------f NVMBUS A.3.1.2 Erase Verify Block (Blank Check) (FCMD=0x02) The time it takes to perform a blank check is dependant on the location of the first non-blank word starting at relative address zero. It takes one bus cycle per phrase to verify plus a setup of the command. Assuming that no non blank location is found, then the erase verify time for a single 256K NVM array is given by 1 t check = 33500 ⋅ -------------------f NVMBUS For a 128K NVM or D-Flash array the erase verify time is given by 1 t check = 17200 ⋅ -------------------f NVMBUS A.3.1.3 Erase Verify P-Flash Section (FCMD=0x03) The maximum time depends on the number of phrases being verified (NVP) 1 t check = ( 752 + N VP ) ⋅ -------------------f NVMBUS S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 677 Electrical Characteristics A.3.1.4 Read Once (FCMD=0x04) The maximum read once time is given by 1 t = ( 400 ) ⋅ -------------------f NVMBUS A.3.1.5 Program P-Flash (FCMD=0x06) The programming time for a single phrase of four P-Flash words + associated eight ECC bits is dependant on the bus frequency as a well as on the frequency fNVMOP and can be calculated according to the following formulas. The typical phrase programming time can be calculated using the following equation 1 1 t bwpgm = 128 ⋅ ------------------------- + 1725 ⋅ ---------------------------f NVMBUS f NVMOP The maximum phrase programming time can be calculated using the following equation 1 1 t bwpgm = 130 ⋅ ------------------------- + 2125 ⋅ ---------------------------f NVMBUS f NVMOP A.3.1.6 P-Flash Program Once (FCMD=0x07) The maximum P-Flash Program Once time is given by 1 1 t bwpgm ≈ 162 ⋅ ------------------------ + 2400 ⋅ --------------------------f NVMBUS f NVMOP A.3.1.7 Erase All Blocks (FCMD=0x08) Erasing all blocks takes: 1 1 t mass ≈ 100100 ⋅ ------------------------ + 35000 ⋅ --------------------------f NVMBUS f NVMOP S12XS Family Reference Manual, Rev. 1.09 678 Freescale Semiconductor Electrical Characteristics A.3.1.8 Erase P-Flash Block (FCMD=0x09) Erasing a 256K NVM block takes 1 1 t mass ≈ 100100 ⋅ ------------------------ + 70000 ⋅ --------------------------f NVMBUS f NVMOP Erasing a 128K NVM block takes 1 1 t mass ≈ 100100 ⋅ ------------------------ + 35000 ⋅ --------------------------f NVMBUS f NVMOP A.3.1.9 Erase P-Flash Sector (FCMD=0x0A) The typical time to erase a1024-byte P-Flash sector can be calculated using 1 1 t era = ⎛ 20020 ⋅ ------------------⎞ + ⎛ 700 ⋅ -------------------- ⎞ ⎝ f NVMBUS⎠ f NVMOP⎠ ⎝ The maximum time to erase a1024-byte P-Flash sector can be calculated using 1 1 t era = ⎛ 20020 ⋅ ------------------⎞ + ⎛ 1100 ⋅ -------------------- ⎞ ⎝ f NVMOP⎠ ⎝ f NVMBUS⎠ A.3.1.10 Unsecure Flash (FCMD=0x0B) The maximum time for unsecuring the flash is given by 1 1 t uns = ⎛ 100100 ⋅ ------------------------ + 70000 ⋅ --------------------------- ⎞ ⎝ f NVMBUS⎠ f NVMOP A.3.1.11 Verify Backdoor Access Key (FCMD=0x0C) The maximum verify backdoor access key time is given by 1 t = 400 ⋅ --------------------------f NVMBUS A.3.1.12 Set User Margin Level (FCMD=0x0D) The maximum set user margin level time is given by 1 t = 350 ⋅ --------------------------f NVMBUS A.3.1.13 Set Field Margin Level (FCMD=0x0E) The maximum set field margin level time is given by S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 679 Electrical Characteristics 1 t = 350 ⋅ --------------------------f NVMBUS A.3.1.14 Erase Verify D-Flash Section (FCMD=0x10) Erase Verify D-Flash for a given number of words NW is given by . 1 t check ≈ ( 840 + N W ) ⋅ --------------------------f NVMBUS A.3.1.15 D-Flash Programming (FCMD=0x11) D-Flash programming time is dependent on the number of words being programmed and their location with respect to a row boundary, because programming across a row boundary requires extra steps. The DFlash programming time is specified for different cases (1,2,3,4 words and 4 words across a row boundary) at a 40MHz bus frequency. The typical programming time can be calculated using the following equation, whereby Nw denotes the number of words; BC=0 if no boundary is crossed and BC=1 if a boundary is crossed. 1 1 t dpgm = ⎛ ( 15 + ( 54 ⋅ N w ) + ( 16 ⋅ BC ) ) ⋅ ------------------⎞ + ⎛ ( 460 + ( 640 ⋅ N W ) + ( 500 ⋅ BC ) ) ⋅ -------------------- ⎞ ⎝ f NVMOP⎠ ⎝ f NVMBUS⎠ The maximum programming time can be calculated using the following equation 1 1 t dpgm = ⎛ ( 15 + ( 56 ⋅ N w ) + ( 16 ⋅ BC ) ) ⋅ ------------------⎞ + ⎛ ( 460 + ( 840 ⋅ N W ) + ( 500 ⋅ BC ) ) ⋅ -------------------- ⎞ ⎝ f NVMOP⎠ ⎝ f NVMBUS⎠ A.3.1.16 Erase D-Flash Sector (FCMD=0x12) Typical D-Flash sector erase times are those expected on a new device, where no margin verify fails occur. They can be calculated using the following equation. 1 1 t eradf ≈ 5025 ⋅ ------------------------ + 700 ⋅ --------------------------f NVMBUS f NVMOP Maximum D-Fash sector erase times can be calculated using the following equation. 1 1 t eradf ≈ 20100 ⋅ ------------------------ + 3300 ⋅ --------------------------f NVMBUS f NVMOP The D-Flash sector erase time on a new device is ~5ms and can extend to 20ms as the flash is cycled. S12XS Family Reference Manual, Rev. 1.09 680 Freescale Semiconductor Electrical Characteristics Table A-18. NVM Timing Characteristics Conditions are as shown in Table A-4, with 40MHz bus and fNVMOP= 1MHz unless otherwise noted. Num C 1 2 3 4 6 7 7a 8 9a 9b 9c 9d 9e 10 D External oscillator clock D Bus frequency for programming or erase operations D Operating frequency D P-Flash phrase programming P P-Flash sector erase time P Erase All Blocks (Mass erase) time D Unsecure Flash D P-Flash erase verify (blank check) time2 D D-Flash word programming 1 word D D-Flash word programming 2 words D D-Flash word programming 3 words D D-Flash word programming 4 words D D-Flash word programming 4 words crossing row boundary D D-Flash sector erase time Rating Symbol fNVMOSC fNVMBUS fNVMOP tbwpgm tera tmass tuns tcheck tdpgm tdpgm tdpgm tdpgm tdpgm teradf Min 2 1 800 — — — — — — — — — — — Typ — — — 171 20 101 101 — 97 167 237 307 335 5.23 — Max 401 40 1050 183 21 102 102 335002 104 181 258 335 363 21 17500 Unit MHz MHz kHz µs ms ms ms tcyc µs µs µs µs µs ms tcyc — 11 D D-Flash erase verify (blank check) time tcheck Restrictions for oscillator in crystal mode apply. 1 2 Valid for both “Erase verify all” or “Erase verify block” on 256K block without failing locations 3 This is a typical value for a new device A.3.2 NVM Reliability Parameters The reliability of the NVM blocks is guaranteed by stress test during qualification, constant process monitors and burn-in to screen early life failures. The data retention and program/erase cycling failure rates are specified at the operating conditions noted. The program/erase cycle count on the sector is incremented every time a sector or mass erase event is executed. The standard shipping condition for both the D-Flash and P-Flash memory is erased with security disabled. However it is recommended that each block or sector is erased before factory programming to ensure that the full data retention capability is achieved. Data retention time is measured from the last erase operation. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 681 Electrical Characteristics Table A-19. NVM Reliability Characteristics Conditions are shown in Table A-4 unless otherwise noted Num C Rating P-Flash Array 1 2 3 C Data retention at an average junction temperature of TJavg = 85°C1 after up to 10,000 program/erase cycles C Data retention at an average junction temperature of TJavg = 85°C3 after less than 100 program/erase cycles C P-Flash number of program/erase cycles (-40°C ≤ tj ≤ 150°C) D-Flash Array 4 5 6 C Data retention at an average junction temperature of TJavg = 85°C3 after up to 50,000 program/erase cycles C Data retention at an average junction temperature of TJavg = 85°C3 after less than 10,000 program/erase cycles C Data retention at an average junction temperature of TJavg = 85°C3 after less than 100 program/erase cycles tDNVMRET tDNVMRET tDNVMRET 5 10 20 1002 1002 1002 — — — Years Years Years tPNVMRET tPNVMRET nPFLPE 15 20 10K 1002 1002 100K3 — — — Years Years Cycles Symbol Min Typ Max Unit 7 C D-Flash number of program/erase cycles (-40°C ≤ tj ≤ 150°C) nDFLPE 50K 500K3 — Cycles 1 TJavg does not exceed 85°C in a typical temperature profile over the lifetime of a consumer, industrial or automotive application. 2 Typical data retention values are based on intrinsic capability of the technology measured at high temperature and de-rated to 25°C using the Arrhenius equation. For additional information on how Freescale defines Typical Data Retention, please refer to Engineering Bulletin EB618 3 TJavg does not exceed 85°C in a typical temperature profile over the lifetime of a consumer, industrial or automotive application. S12XS Family Reference Manual, Rev. 1.09 682 Freescale Semiconductor Electrical Characteristics A.4 Voltage Regulator Table A-20. Voltage Regulator Electrical Characteristics Conditions are shown in Table A-4 unless otherwise noted Num 1 2 C P P Input Voltages Characteristic Symbol VVDDR,A VDD Min 3.13 1.72 — 2.60 — 1.72 — 4.04 4.19 Typical — 1.84 1.60 2.82 2.20 1.84 1.60 4.23 4.38 Max 5.50 1.98 — 2.90 — 1.98 — 4.40 4.49 Unit V V V V V V V V V Output Voltage Core Full Performance Mode Reduced Power Mode (MCU STOP mode) Output Voltage Flash Full Performance Mode Reduced Power Mode (MCU STOP mode) Output Voltage PLL Full Performance Mode Reduced Power Mode (MCU STOP mode) Low Voltage Interrupt1 Assert Level Deassert Level VDDX Low Voltage Reset 2 3 Assert Level Deassert Level Trimmed API internal clock4 ∆f / fnominal The first period after enabling the counter by APIFE might be reduced by API start up delay Temperature Sensor Slope High Temperature Interrupt Assert5 Assert (VREGHTTR=$88) Deassert (VREGHTTR=$88) 3 P VDDF 4 P VDDPLL 5 P VLVIA VLVID VLVRXA VLVRXD dfAPI tsdel dVTS THTIA THTID 6 P — — -5 — 5.05 3.02 — — — 5.25 — 3.13 +5 100 5.45 V V % µs mV/oC oC oC 7 8 9 C D T 10 T 120 110 132 122 144 134 1 2 3 4 5 VBG 1.13 1.21 1.32 V 11 P Bandgap Reference Voltage Monitors VDDA, active only in Full Performance Mode. Indicates I/O & ADC performance degradation due to low supply voltage. Device functionality is guaranteed on power down to the LVR assert level Monitors VDDX, active only in Full Performance Mode. MCU is monitored by the POR in RPM (see Figure A-2) The API Trimming bits must be set that the minimum period equals to 0.2 ms. A hysteresis is guaranteed by design S12XS Family Reference Manual, Rev. 1.09 683 Freescale Semiconductor Electrical Characteristics A.5 A.5.1 Output Loads Resistive Loads The voltage regulator is intended to supply the internal logic and oscillator. It allows no external DC loads. A.5.2 Capacitive Loads Table A-21. S12XS family - Capacitive Loads The capacitive loads are specified in Table A-21. Ceramic capacitors with X7R dielectricum are required. Num 1 3 Characteristic VDD/VDDF external capacitive load VDDPLL external capacitive load Symbol CDDext CDDPLLext Min 176 80 Recommended 220 220 Max 264 264 Unit nF nF A.5.3 Chip Power-up and Voltage Drops LVI (low voltage interrupt), POR (power-on reset) and LVRs (low voltage reset) handle chip power-up or drops of the supply voltage. Their function is shown in Figure A-2 . V VLVID VLVIA VLVRXD VLVRXA VDDX VDD VPORD t LVI LVI enabled LVI disabled due to LVR POR LVRX Figure A-2. S12XS family - Chip Power-up and Voltage Drops (not scaled) S12XS Family Reference Manual, Rev. 1.09 684 Freescale Semiconductor Electrical Characteristics V VDDR, VDDX VDDA >= 0 Figure A-3. S12XS family Power Sequencing t During power sequencing VDDA can be powered up before VDDR, VDDX. VDDR and VDDX must be powered up together adhering to the operating conditions differential. VRH power up must follow VDDA to avoid current injection. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 685 Electrical Characteristics A.6 Reset, Oscillator and PLL This section summarizes the electrical characteristics of the various startup scenarios for oscillator and phase-locked loop (PLL). A.6.1 Startup Table A-22 summarizes several startup characteristics explained in this section. Detailed description of the startup behavior can be found in the Clock and Reset Generator (CRG) block description Table A-22. Startup Characteristics Conditions are shown in Table A-4unless otherwise noted Num C 1 2 3 Rating Symbol PWRSTL nRST tWRS Min 2 192 — Typ — — — 50 Max — 196 14 100 Unit tosc nosc tcyc µs D Reset input pulse width, minimum input time D Startup from reset D Wait recovery startup time 4 D Fast wakeup from STOP1 — tfws Including voltage regulator startup; VDD /VDDF filter capacitors 220 nF, VDD35 = 5 V, T= 25°C 1 A.6.1.1 POR The release level VPORR and the assert level VPORA are derived from the VDD supply. They are also valid if the device is powered externally. After releasing the POR reset the oscillator and the clock quality check are started. If after a time tCQOUT no valid oscillation is detected, the MCU will start using the internal self clock. The fastest startup time possible is given by nuposc. A.6.1.2 SRAM Data Retention Provided an appropriate external reset signal is applied to the MCU, preventing the CPU from executing code when VDD35 is out of specification limits, the SRAM contents integrity is guaranteed if after the reset the PORF bit in the CRG flags register has not been set. A.6.1.3 External Reset When external reset is asserted for a time greater than PWRSTL the CRG module generates an internal reset, and the CPU starts fetching the reset vector without doing a clock quality check, if there was an oscillation before reset. A.6.1.4 Stop Recovery Out of stop the controller can be woken up by an external interrupt. A clock quality check as after POR is performed before releasing the clocks to the system. If the MCU is woken-up by an interrupt and the fast wake-up feature is enabled (FSTWKP = 1 and SCME = 1), the system will resume operation in self-clock mode after tfws. S12XS Family Reference Manual, Rev. 1.09 686 Freescale Semiconductor Electrical Characteristics A.6.1.5 Pseudo Stop and Wait Recovery The recovery from pseudo stop and wait is essentially the same since the oscillator is not stopped in both modes. The controller can be woken up by internal or external interrupts. After twrs the CPU starts fetching the interrupt vector. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 687 Electrical Characteristics A.6.2 Oscillator Table A-23. Oscillator Characteristics Conditions are shown in Table A-4. unless otherwise noted Num C 1a 1b 2 3a 3b 3c 4a 4b 4c 4d 4e 5 6 7 8 9 10 11 12 13 Rating Symbol fOSC fOSC iOSC tUPOSC tUPOSC tUPOSC tUPOSC tUPOSC tUPOSC tUPOSC tUPOSC tCQOUT fCMFA fEXT tEXTL tEXTH tEXTR tEXTF CIN VIH,EXTAL VIH,EXTAL VIL,EXTAL VIL,EXTAL VHYS,EXTAL Min 4.0 2.0 100 — — — — — — — — 0.45 200 2.0 9.5 9.5 — — — 0.75*VDDPLL — — VSSPLL - 0.3 — Typ — — — 2.2 1.1 0.75 5.2 3 1.8 1.2 1 — 400 — — — — — 7 — — — — 180 Max 16 40 — 10 8 5 40 20 10 5 4 2.5 800 50 — — 1 1 — — VDDPLL + 0.3 0.25*VDDPLL — — Unit MHz MHz µA ms ms ms ms ms ms ms ms s KHz MHz ns ns ns ns pF V V V V mV V C Crystal oscillator range (loop controlled Pierce) C Crystal oscillator range (full swing Pierce) 1,2 P Startup Current C Oscillator start-up time (LCP, 4MHz)3 C Oscillator start-up time (LCP, 8MHz)3 C Oscillator start-up time (LCP, 16MHz)3 C Oscillator start-up time (full swing Pierce, 2MHz)3 C Oscillator start-up time (full swing Pierce, 4MHz)3 C Oscillator start-up time (full swing Pierce, 8MHz)3 C Oscillator start-up time (full swing Pierce, 16MHz)3 C Oscillator start-up time (full swing Pierce, 40MHz)3 D Clock Quality check time-out P Clock Monitor Failure Assert Frequency P External square wave input frequency D External square wave pulse width low D External square wave pulse width high D External square wave rise time D External square wave fall time D Input Capacitance (EXTAL, XTAL pins) P EXTAL Pin Input High Voltage T EXTAL Pin Input High Voltage,4 14 P EXTAL Pin Input Low Voltage ,4 T EXTAL Pin Input Low Voltage 15 16 1 2 3 4 C EXTAL Pin Input Hysteresis C EXTAL Pin oscillation amplitude (loop controlled VPP,EXTAL — 0.9 — Pierce) Depending on the crystal a damping series resistor might be necessary Only valid if full swing Pierce oscillator/external clock mode is selected These values apply for carefully designed PCB layouts with capacitors that match the crystal/resonator requirements.. Only applies if EXTAL is externally driven S12XS Family Reference Manual, Rev. 1.09 688 Freescale Semiconductor Electrical Characteristics A.6.3 A.6.3.1 Phase Locked Loop Jitter Information With each transition of the clock fcmp, the deviation from the reference clock fref is measured and input voltage to the VCO is adjusted accordingly.The adjustment is done continuously with no abrupt changes in the clock output frequency. Noise, voltage, temperature and other factors cause slight variations in the control loop resulting in a clock jitter. This jitter affects the real minimum and maximum clock periods as illustrated in Figure A-4. 0 1 2 3 N-1 N tmin1 tnom tmax1 tminN tmaxN Figure A-4. Jitter Definitions The relative deviation of tnom is at its maximum for one clock period, and decreases towards zero for larger number of clock periods (N). Defining the jitter as: t (N) t (N) ⎞ ⎛ max min J ( N ) = max ⎜ 1 – ---------------------- , 1 – ---------------------- ⎟ N⋅t N⋅t ⎝ nom nom ⎠ S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 689 Electrical Characteristics For N < 1000, the following equation is a good fit for the maximum jitter: j1 J ( N ) = ------- + j 2 N J(N) 1 5 10 20 N Figure A-5. Maximum bus clock jitter approximation NOTE On timers and serial modules a prescaler will eliminate the effect of the jitter to a large extent. Table A-24. IPLL Characteristics Conditions are shown in Table A-4 unless otherwise noted Num C 1 2 3 4 5 7 8 9 10 11 12 Rating Symbol fSCM fVCO fREF |∆Lock| |∆unl| tlock j1 j2 fbus fbus Min 1 32 1 0 0.5 — — — — — Typ — — — — — 214 — — — — Max 4 120 40 1.5 2.5 150 + 256/fREF 1.2 0 38 39 Unit MHz MHz MHz %2 %2 µs % % MHz MHz P Self Clock Mode frequency1 T VCO locking range T Reference Clock D Lock Detection D Un-Lock Detection C Time to lock C Jitter fit parameter 13 C Jitter fit parameter 23 C Bus Frequency for FM1=1, FM0=1 (frequency modulation in PLLCTL register of s12xe_crg) C Bus Frequency for FM1=1, FM0=0 (frequency modulation in PLLCTL register of s12xe_crg) C Bus Frequency for FM1=0, FM0=1 (frequency fbus — — 39 MHz modulation in PLLCTL register of s12xe_crg) 1 Bus frequency is equivalent to fSCM/2 2 % deviation from target frequency 3 fOSC=4MHz, fBUS=40MHz equivalent fPLL=80MHz: REFDIV=$00, REFRQ=01, SYNDIV=$09, VCOFRQ=01, POSTDIV=$00 S12XS Family Reference Manual, Rev. 1.09 690 Freescale Semiconductor Electrical Characteristics A.7 MSCAN Table A-25. MSCAN Wake-up Pulse Characteristics Conditions are shown in Table A-4 unless otherwise noted Num C 1 2 Rating Symbol tWUP tWUP Min — 5 Typ — — Max 1.5 — Unit µs µs P MSCAN wakeup dominant pulse filtered P MSCAN wakeup dominant pulse pass S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 691 Electrical Characteristics A.8 SPI Timing This section provides electrical parametrics and ratings for the SPI. In Table A-26 the measurement conditions are listed. Table A-26. Measurement Conditions Description Drive mode Load capacitance CLOAD1, on all outputs Thresholds for delay measurement points 1 Timing specified for equal load on all SPI output pins. Avoid asymmetric load. Value Full drive mode 50 (20% / 80%) VDDX Unit — pF V A.8.1 Master Mode In Figure A-6 the timing diagram for master mode with transmission format CPHA = 0 is depicted. SS (Output) 2 SCK (CPOL = 0) (Output) SCK (CPOL = 1) (Output) 5 MISO (Input) 6 Bit MSB-1. . . 1 9 Bit MSB-1. . . 1 LSB OUT LSB IN 11 1 4 4 12 13 12 13 3 MSB IN2 10 MOSI (Output) MSB OUT2 1. If configured as an output. 2. LSBF = 0. For LSBF = 1, bit order is LSB, bit 1, bit 2... MSB. Figure A-6. SPI Master Timing (CPHA = 0) S12XS Family Reference Manual, Rev. 1.09 692 Freescale Semiconductor Electrical Characteristics In Figure A-7 the timing diagram for master mode with transmission format CPHA=1 is depicted. SS (Output) 1 2 SCK (CPOL = 0) (Output) 4 SCK (CPOL = 1) (Output) 5 MISO (Input) 9 MOSI (Output) Port Data Master MSB OUT2 6 Bit MSB-1. . . 1 11 Bit MSB-1. . . 1 Master LSB OUT Port Data LSB IN MSB IN2 4 12 13 12 13 3 1.If configured as output 2. LSBF = 0. For LSBF = 1, bit order is LSB, bit 1,bit 2... MSB. Figure A-7. SPI Master Timing (CPHA = 1) In Table A-27 the timing characteristics for master mode are listed. Table A-27. SPI Master Mode Timing Characteristics Num 1 1 2 3 4 5 6 9 10 11 12 13 1See C D D D D D D D D D D D SCK period Characteristic SCK frequency Enable lead time Enable lag time Clock (SCK) high or low time Data setup time (inputs) Data hold time (inputs) Data valid after SCK edge Data valid after SS fall (CPHA = 0) Data hold time (outputs) Rise and fall time inputs Symbol fsck tsck tlead tlag twsck tsu thi tvsck tvss tho trfi trfo Min 1/2048 2 — — — 8 8 — — 20 — — Typ — — 1/2 1/2 1/2 — — — — — — — Max 1/21 2048 — — — — — 29 15 — 8 8 Unit fbus tbus tsck tsck tsck ns ns ns ns ns ns ns D Rise and fall time outputs Figure A-8. S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 693 Electrical Characteristics fSCK/fbus 1/2 1/4 5 10 15 20 25 30 35 40 fbus [MHz] Figure A-8. Derating of maximum fSCK to fbus ratio in Master Mode A.8.2 Slave Mode In Figure A-9 the timing diagram for slave mode with transmission format CPHA = 0 is depicted. SS (Input) 1 SCK (CPOL = 0) (Input) 2 SCK (CPOL = 1) (Input) 10 7 MISO (Output) See Note 5 MOSI (Input) NOTE: Not defined MSB IN Slave MSB 6 Bit MSB-1. . . 1 LSB IN 9 Bit MSB-1 . . . 1 4 4 12 13 8 11 11 See Note 12 13 3 Slave LSB OUT Figure A-9. SPI Slave Timing (CPHA = 0) S12XS Family Reference Manual, Rev. 1.09 694 Freescale Semiconductor Electrical Characteristics In Figure A-10 the timing diagram for slave mode with transmission format CPHA = 1 is depicted. SS (Input) 1 2 SCK (CPOL = 0) (Input) 4 SCK (CPOL = 1) (Input) 9 MISO (Output) See Note 7 MOSI (Input) NOTE: Not defined Slave 5 MSB OUT 6 MSB IN Bit MSB-1 . . . 1 LSB IN 4 12 13 12 13 3 11 Bit MSB-1 . . . 1 Slave LSB OUT 8 Figure A-10. SPI Slave Timing (CPHA = 1) In Table A-28 the timing characteristics for slave mode are listed. Table A-28. SPI Slave Mode Timing Characteristics Num 1 1 2 3 4 5 6 7 8 9 10 11 12 C D D D D D D D D D D D D D Characteristic SCK frequency SCK period Enable lead time Enable lag time Clock (SCK) high or low time Data setup time (inputs) Data hold time (inputs) Slave access time (time to data active) Slave MISO disable time Data valid after SCK edge Data valid after SS fall Data hold time (outputs) Rise and fall time inputs Symbol fsck tsck tlead tlag twsck tsu thi ta tdis tvsck tvss tho trfi trfo Min DC 4 4 4 4 8 8 — — — — 20 — — Typ — — — — — — — — — — — — — — Max 1/4 ∞ — — — — — 20 22 29 + 0.5 ⋅ tbus1 29 + 0.5 ⋅ tbus — 8 8 1 Unit fbus tbus tbus tbus tbus ns ns ns ns ns ns ns ns ns 1 13 D Rise and fall time outputs 0.5 tbus added due to internal synchronization delay S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 695 Package Information Appendix B Package Information This section provides the physical dimensions of the S12XS family packages. S12XS Family Reference Manual, Rev. 1.09 696 Freescale Semiconductor Package Information B.1 112-pin LQFP Mechanical Dimensions Figure B-1. 112-pin LQFP (case no. 987) - page 1 S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 697 Package Information Figure B-2. 112-pin LQFP (case no. 987) - page 2 S12XS Family Reference Manual, Rev. 1.09 698 Freescale Semiconductor Package Information Figure B-3. 112-pin LQFP (case no. 987) - page 3 S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 699 Package Information B.2 80-Pin QFP Mechanical Dimensions Figure B-4. 80-pin QFP (case no. 841B) - page 1 S12XS Family Reference Manual, Rev. 1.09 700 Freescale Semiconductor Package Information Figure B-5. 80-pin QFP (case no. 841B) - page 2 S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 701 Package Information Figure B-6. 80-pin QFP (case no. 841B) - page 3 S12XS Family Reference Manual, Rev. 1.09 702 Freescale Semiconductor Package Information B.3 64-Pin LQFP Mechanical Dimensions S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 703 Package Information Figure B-7. 64-pin LQFP (case no. 840F) - page 2 S12XS Family Reference Manual, Rev. 1.09 704 Freescale Semiconductor Package Information Figure B-8. 64-pin LQFP (case no. 840F) - page 3 S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 705 PCB Layout Guidelines Appendix C PCB Layout Guidelines C.1 General The PCB must be carefully laid out to ensure proper operation of the voltage regulator as well as of the MCU itself. The following rules must be observed: • Every supply pair must be decoupled by a ceramic capacitor connected as near as possible to the corresponding pins . • Central point of the ground star should be the VSS3 pin. • Use low ohmic low inductance connections between VSS1, VSS2 and VSS3. • VSSPLL must be directly connected to VSS3. • Keep traces of VSSPLL, EXTAL, and XTAL as short as possible and occupied board area for C7, C8, and Q1 as small as possible. • Do not place other signals or supplies underneath area occupied by C7, C8, and Q1 and the connection area to the MCU. • Central power input should be fed in at the VDDA/VSSA pins. Example layouts are illustrated on the following pages. Table C-1. Recommended Decoupling Capacitor Choice Component C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 Q1 Purpose VDDF filter capacitor N/A VDDX2 filter capacitor VDDPLL filter capacitor OSC load capacitor OSC load capacitor VDDR filter capacitor N/A VDD filter capacitor VDDA1 filter capacitor VDDX1 filter capacitor Quartz X7R/tantalum — Ceramic X7R Ceramic X7R X7R/tantalum — >=100 nF — 220 nF >=100 nF >=100 nF — Type Ceramic X7R — X7R/tantalum Ceramic X7R Value 220 nF — >=100 nF 220 nF From crystal manufacturer S12XS Family Reference Manual, Rev. 1.09 706 Freescale Semiconductor PCB Layout Guidelines C.1.1 112-Pin LQFP Recommended PCB Layout Figure C-1. 112-Pin LQFP Recommended PCB Layout (Loop Controlled Pierce Oscillator) S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 707 PCB Layout Guidelines C.1.2 80-Pin QFP Recommended PCB Layout Figure C-2. 80-Pin QFP Recommended PCB Layout (Loop Controlled Pierce Oscillator) S12XS Family Reference Manual, Rev. 1.09 708 Freescale Semiconductor PCB Layout Guidelines C.1.3 64-Pin LQFP Recommended PCB Layout TBD Figure C-3. 64-Pin LQFP Recommended PCB Layout (Loop Controlled Pierce Oscillator) S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 709 Derivative Differences Appendix D Derivative Differences D.1 Memory Sizes and Package Options S12XS family Table D-1. Package and Memory Options of S12XS family Device 9S12XS256 Package 112 LQFP 80 QFP 64 LQFP 9S12XS128 112 LQFP 80 QFP 64 LQFP 9S12XS64 112 LQFP 80 QFP 64 LQFP 64K 4K 4K 128K 8K 8K Flash 256K RAM Data Flash 12K 8K Table D-2. Peripheral Options of S12XS family Members Device 9S12XS256 Package 112 LQFP 80 QFP 64 LQFP 9S12XS128 112 LQFP 80 QFP 64 LQFP 9S12XS64 112 LQFP 80 QFP 64 LQFP CAN 1 1 1 1 1 1 1 1 1 SCI 2 2 2 2 2 2 2 2 2 SPI 1 1 1 1 1 1 1 1 1 TIM 8ch 8ch 8ch 8ch 8ch 8ch 8ch 8ch 8ch PIT 4ch 4ch 4ch 4ch 4ch 4ch 4ch 4ch 4ch A/D 16ch 8ch 8ch 16ch 8ch 8ch 16ch 8ch 8ch PWM 8ch 8ch 8ch 8ch 8ch 8ch 8ch 8ch 8ch NOTE For the 80QFP and 64LQFP package options, several peripheral functions can be routed under software control to different pins. Not all functions are available simultaneously. For details see Table 1-5. S12XS Family Reference Manual, Rev. 1.09 710 Freescale Semiconductor Detailed Register Address Map Appendix E Detailed Register Address Map E.1 Detailed Register Map The following tables show the detailed register map of the S12XS family. 0x0000–0x0009 Port Integration Module (PIM) Map 1 of 5 Address 0x0000 0x0001 0x0002 0x0003 0x0004 0x0005 0x0006 0x0007 0x0008 0x0009 Name PORTA PORTB DDRA DDRB Reserved Reserved Reserved Reserved PORTE DDRE R W R W R W R W R W R W R W R W R W R W Bit 7 PA7 PB7 DDRA7 DDRB7 0 0 0 0 Bit 6 PA6 PB6 DDRA6 DDRB6 0 0 0 0 Bit 5 PA5 PB5 DDRA5 DDRB5 0 0 0 0 Bit 4 PA4 PB4 DDRA4 DDRB4 0 0 0 0 Bit 3 PA3 PB3 DDRA3 DDRB3 0 0 0 0 Bit 2 PA2 PB2 DDRA2 DDRB2 0 0 0 0 Bit 1 PA1 PB1 DDRA1 DDRB1 0 0 0 0 PE1 0 Bit 0 PA 0 PB0 DDRA0 DDRB0 0 0 0 0 PE0 0 PE7 DDRE7 PE6 DDRE6 PE5 DDRE5 PE4 DDRE4 PE3 DDRE3 PE2 DDRE2 0x000A–0x000B Module Mapping Control (S12XMMC) Map 1 of 2 Address 0x000A 0x000B Name Reserved MODE R W R W Bit 7 0 Bit 6 0 0 Bit 5 0 0 Bit 4 0 0 Bit 3 0 0 Bit 2 0 0 Bit 1 0 0 Bit 0 0 0 MODC 0x000C–0x000D Port Integration Module (PIM) Map 2 of 5 Address 0x000C 0x000D Name PUCR RDRIV R W R W Bit 7 PUPKE RDPK Bit 6 BKPUE 0 Bit 5 0 0 Bit 4 PUPEE RDPE Bit 3 0 0 Bit 2 0 0 Bit 1 PUPBE RDPB Bit 0 PUPAE RDPA S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 711 Detailed Register Address Map 0x000E–0x000F Reserved Register Space Address 0x000E 0x000F Name Reserved Reserved R W R W Bit 7 0 0 Bit 6 0 0 Bit 5 0 0 Bit 4 0 0 Bit 3 0 0 Bit 2 0 0 Bit 1 0 0 Bit 0 0 0 0x0010–0x0017 Module Mapping Control (S12XMMC) Map 2 of 2 Address 0x0010 0x0011 0x0012 0x0013 0x0014 0x0015 0x0016 0x0017 Name GPAGE DIRECT Reserved MMCCTL1 Reserved PPAGE RPAGE EPAGE Bit 7 R 0 W R DP15 W R 0 W R MGRAMO N W R 0 W R PIX7 W R RP7 W R EP7 W Bit 6 GP6 DP14 0 0 0 Bit 5 GP5 DP13 0 Bit 4 GP4 DP12 0 PGMIFRO N 0 Bit 3 GP3 DP11 0 0 0 Bit 2 GP2 DP10 0 0 0 Bit 1 GP1 DP9 0 0 0 Bit 0 GP0 DP8 0 0 0 DFIFRON 0 PIX6 RP6 EP6 PIX5 RP5 EP5 PIX4 RP4 EP4 PIX3 RP3 EP3 PIX2 RP2 EP2 PIX1 RP1 EP1 PIX0 RP0 EP0 0x0018–0x001B Miscellaneous Peripheral Address 0x0018 0x0019 0x001A 0x001B Name Reserved Reserved PARTIDH PARTIDL R W R W R W R W Bit 7 0 0 Bit 6 0 0 Bit 5 0 0 Bit 4 0 0 PARTIDH PARTIDL Bit 3 0 0 Bit 2 0 0 Bit 1 0 0 Bit 0 0 0 0x001C–0x001D Port Integration Module (PIM) Map 3 of 5 Address 0x001C 0x001D Name ECLKCTL Reserved R W R W Bit 7 NECLK 0 Bit 6 NCLKX2 0 Bit 5 DIV16 0 Bit 4 EDIV4 0 Bit 3 EDIV3 0 Bit 2 EDIV2 0 Bit 1 EDIV1 0 Bit 0 EDIV0 0 S12XS Family Reference Manual, Rev. 1.09 712 Freescale Semiconductor Detailed Register Address Map 0x001E–0x001F Port Integration Module (PIM) Map 3 of 5 Address 0x001E 0x001F Name IRQCR Reserved R W R W Bit 7 IRQE 0 Bit 6 IRQEN 0 Bit 5 0 0 Bit 4 0 0 Bit 3 0 0 Bit 2 0 0 Bit 1 0 0 Bit 0 0 0 0x0020–0x002F Debug Module (S12XDBG) Map Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 R 0 0x0020 DBGC1 ARM reserved BDM DBGBRK reserved W TRIG R TBF 0 0 0 0 SSF2 0x0021 DBGSR W R 0x0022 DBGTCR reserved TSOURCE TRANGE TRCMOD W R 0 0 0 0 0x0023 DBGC2 CDCM W R Bit 15 Bit 14 Bit 13 Bit 12 Bit 11 Bit 10 0x0024 DBGTBH W R Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 0x0025 DBGTBL W R 0 CNT 0x0026 DBGCNT W R 0 0 0 0 0x0027 DBGSCRX SC3 SC2 W R 0 0 0 0 MC3 MC2 0x0027 DBGMFR W R 0 DBGXCTL NDB TAG BRK RW RWE 0x00281 (COMPA/C) W R DBGXCTL SZE SZ TAG BRK RW RWE 0x00282 (COMPB/D) W R 0 0x0029 DBGXAH Bit 22 21 20 19 18 W R 0x002A DBGXAM Bit 15 14 13 12 11 10 W R 0x002B DBGXAL Bit 7 6 5 4 3 2 W R 0x002C DBGXDH Bit 15 14 13 12 11 10 W R 0x002D DBGXDL Bit 7 6 5 4 3 2 W R 0x002E DBGXDHM Bit 15 14 13 12 11 10 W R 0x002F DBGXDLM Bit 7 6 5 4 3 2 W 1 This represents the contents if the Comparator A or C control register is blended into this address 2 This represents the contents if the Comparator B or D control register is blended into this address COMRV SSF1 SSF0 TALIGN ABCM Bit 9 Bit 1 Bit 8 Bit 0 SC1 MC1 SC0 MC0 reserved reserved 17 9 1 9 1 9 1 COMPE COMPE Bit 16 Bit 8 Bit 0 Bit 8 Bit 0 Bit 8 Bit 0 S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 713 Detailed Register Address Map 0x0030–0x0031 Reserved Register Space Address 0x0030 0x0031 Name Reserved Reserved R W R W Bit 7 0 0 Bit 6 0 0 Bit 5 0 0 Bit 4 0 0 Bit 3 0 0 Bit 2 0 0 Bit 1 0 0 Bit 0 0 0 0x0032–0x0033 Port Integration Module (PIM) Map 4 of 5 Address 0x0032 0x0033 Name PORTK DDRK R W R W Bit 7 PK7 DDRK7 Bit 6 0 0 Bit 5 PK5 DDRK5 Bit 4 PK4 DDRK4 Bit 3 PK3 DDRK3 Bit 2 PK2 DDRK2 Bit 1 PK1 DDRK1 Bit 0 PK0 DDRK0 0x0034–0x003F Clock and Reset Generator (CRG) Map Address 0x0034 0x0035 0x0036 0x0037 0x0038 0x0039 0x003A 0x003B Name SYNR REFDV POSTDIV CRGFLG CRGINT CLKSEL PLLCTL RTICTL Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 R VCOFRQ[1:0] W R REFFRQ[1:0] W R 0 0 W R RTIF PORF W R 0 RTIE W R PLLSEL PSTP W R CME PLLON W R RTDEC RTR6 W R RSBCK W WCOP R W R W R W 0 0 0 Bit 7 0 0 0 6 SYNDIV[5:0] REFDIV[5:0] 0 LOCK 0 POSTDIV[4:0] LOCKIF LOCKIE 0 ILAF 0 0 SCMIF SCMIE RTIWAI PCE RTR1 SCM 0 LVRF 0 XCLKS PLLWAI FSTWKP RTR3 0 COPWAI SCME RTR0 FM1 RTR5 0 WRTMAS K 0 0 0 5 FM0 RTR4 0 PRE RTR2 0x003C COPCTL CR2 0 0 Reserved For Factory Test 0 Reserved For Factory Test 0 0 4 3 0 0 0 2 CR1 0 0 0 1 CR0 0 0 0 Bit 0 0x003D 0x003E 0x003F FORBYP CTCTL ARMCOP S12XS Family Reference Manual, Rev. 1.09 714 Freescale Semiconductor Detailed Register Address Map 0x0040–0x006F Timer Module (TIM) Map Address 0x0040 0x0041 0x0042 0x0043 0x0044 0x0045 0x0046 0x0047 0x0048 0x0049 0x004A 0x004B 0x004C 0x004D 0x004E 0x004F 0x0050 0x0051 0x0052 0x0053 0x0054 0x0055 0x0056 Name TIOS CFORC OC7M OC7D TCNTH TCNTL TSCR1 TTOV TCTL1 TCTL2 TCTL3 TCTL4 TIE TSCR2 TFLG1 TFLG2 TC0H TC0L TC1H TC1L TC2H TC2L TC3H R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W Bit 7 IOS7 0 FOC7 OC7M7 OC7D7 Bit 15 Bit 7 Bit 6 IOS6 0 FOC6 OC7M6 OC7D6 14 6 Bit 5 IOS5 0 FOC5 OC7M5 OC7D5 13 5 Bit 4 IOS4 0 FOC4 OC7M4 OC7D4 12 4 Bit 3 IOS3 0 FOC3 OC7M3 OC7D3 11 3 Bit 2 IOS2 0 FOC2 OC7M2 OC7D2 10 2 0 Bit 1 IOS1 0 FOC1 OC7M1 OC7D1 9 1 0 Bit 0 IOS0 0 FOC0 OC7M0 OC7D0 Bit 8 Bit 0 0 TEN TOV7 OM7 OM3 EDG7B EDG3B C7I TOI C7F TOF Bit 15 Bit 7 Bit 15 Bit 7 Bit 15 Bit 7 Bit 15 TSWAI TOV6 OL7 OL3 EDG7A EDG3A C6I 0 TSFRZ TOV5 OM6 OM2 EDG6B EDG2B C5I 0 TFFCA TOV4 OL6 OL2 EDG6A EDG2A C4I 0 PRNT TOV3 OM5 OM1 EDG5B EDG1B C3I TCRE C3F 0 TOV2 OL5 OL1 EDG5A EDG1A C2I PR2 C2F 0 TOV1 OM4 OM0 EDG4B EDG0B C1I PR1 C1F 0 TOV0 OL4 OL0 EDG4A EDG0A C0I PR0 C0F 0 C6F 0 C5F 0 C4F 0 Bit 14 Bit 6 Bit 14 Bit 6 Bit 14 Bit 6 Bit 14 Bit 13 Bit 5 Bit 13 Bit 5 Bit 13 Bit 5 Bit 13 Bit 12 Bit 4 Bit 12 Bit 4 Bit 12 Bit 4 Bit 12 Bit 11 Bit 3 Bit 11 Bit 3 Bit 11 Bit 3 Bit 11 Bit 10 Bit 2 Bit 10 Bit 2 Bit 10 Bit 2 Bit 10 Bit 9 Bit 1 Bit 9 Bit 1 Bit 9 Bit 1 Bit 9 Bit 8 Bit 0 Bit 8 Bit 0 Bit 8 Bit 0 Bit 8 S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 715 Detailed Register Address Map 0x0040–0x006F Timer Module (TIM) Map Address 0x0057 0x0058 0x0059 0x005A 0x005B 0x005C 0x005D 0x005E 0x005F 0x0060 0x0061 0x0062 0x0063 0x0064– 0x006B 0x006C 0x006D 0x006E 0x006F Name TC3L TC4H TC4L TC5H TC5L TC6H TC6L TC7H TC7L PACTL PAFLG PACNTH PACNTL Reserved OCPD Reserved PTPSR Reserved Bit 7 R Bit 7 W R Bit 15 W R Bit 7 W R Bit 15 W R Bit 7 W R Bit 15 W R Bit 7 W R Bit 15 W R Bit 7 W R 0 W R 0 W R PACNT15 W R PACNT7 W R 0 W R OCPD7 W R W R PTPS7 W R 0 W Bit 6 Bit 6 Bit 14 Bit 6 Bit 14 Bit 6 Bit 14 Bit 6 Bit 14 Bit 6 PAEN 0 Bit 5 Bit 5 Bit 13 Bit 5 Bit 13 Bit 5 Bit 13 Bit 5 Bit 13 Bit 5 PAMOD 0 Bit 4 Bit 4 Bit 12 Bit 4 Bit 12 Bit 4 Bit 12 Bit 4 Bit 12 Bit 4 PEDGE 0 Bit 3 Bit 3 Bit 11 Bit 3 Bit 11 Bit 3 Bit 11 Bit 3 Bit 11 Bit 3 CLK1 0 Bit 2 Bit 2 Bit 10 Bit 2 Bit 10 Bit 2 Bit 10 Bit 2 Bit 10 Bit 2 CLK0 0 Bit 1 Bit 1 Bit 9 Bit 1 Bit 9 Bit 1 Bit 9 Bit 1 Bit 9 Bit 1 PAOVI PAOVF PACNT9 PACNT1 0 Bit 0 Bit 0 Bit 8 Bit 0 Bit 8 Bit 0 Bit 8 Bit 0 Bit 8 Bit 0 PAI PAIF PACNT8 PACNT0 0 PACNT14 PACNT6 0 PACNT13 PACNT5 0 PACNT12 PACNT4 0 PACNT11 PACNT3 0 PACNT10 PACNT2 0 OCPD6 OCPD5 OCPD4 OCPD3 OCPD2 OCPD1 OCPD0 PTPS6 0 PTPS5 0 PTPS4 0 PTPS3 0 PTPS2 0 PTPS1 0 PTPS0 0 0x0070–0x00C7 Reserved Register Space Address 0x00700x00C7 Name Reserved R W Bit 7 0 Bit 6 0 Bit 5 0 Bit 4 0 Bit 3 0 Bit 2 0 Bit 1 0 Bit 0 0 S12XS Family Reference Manual, Rev. 1.09 716 Freescale Semiconductor Detailed Register Address Map 0x00C8–0x00CF Asynchronous Serial Interface (SCI0) Map Address 0x00C8 Name SCI0BDH1 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 SBR10 SBR2 ILT BERRV 0 Bit 1 SBR9 SBR1 PE BERRIF BERRIE BERRM0 RWU FE Bit 0 SBR8 SBR0 PT BKDIF BKDIE BKDFE SBK PF RAF 0 R0 T0 R IREN TNP1 TNP0 SBR12 SBR11 W R SBR7 SBR6 SBR5 SBR4 SBR3 0x00C9 SCI0BDL1 W R LOOPS SCISWAI RSRC M WAKE 0x00CA SCI0CR11 W R 0 0 0 0 RXEDGIF 0x00C8 SCI0ASR12 W R 0 0 0 0 RXEDGIE 0x00C9 SCI0ACR12 W R 0 0 0 0 0 0x00CA SCI0ACR22 W R 0x00CB SCI0CR2 TIE TCIE RIE ILIE TE W R TDRE TC RDRF IDLE OR 0x00CC SCI0SR1 W R 0 0 0x00CD SCI0SR2 AMAP TXPOL RXPOL W R R8 0 0 0 0x00CE SCI0DRH T8 W R R7 R6 R5 R4 R3 0x00CF SCI0DRL W T7 T6 T5 T4 T3 1 Those registers are accessible if the AMAP bit in the SCI0SR2 register is set to zero 2 Those registers are accessible if the AMAP bit in the SCI0SR2 register is set to one BERRM1 RE NF BRK13 0 R2 T2 TXDIR 0 R1 T1 0x00D0–0x00D7 Asynchronous Serial Interface (SCI1) Map Address 0x00D0 0x00D1 0x00D2 0x00D0 0x00D1 0x00D2 0x00D3 0x00D4 Name SCI1BDH1 SCI1BDL1 SCI1CR11 SCI1ASR12 SCI1ACR12 SCI1ACR22 SCI1CR2 SCI1SR1 Bit 7 R IREN W R SBR7 W R LOOPS W R RXEDGIF W R RXEDGIE W R 0 W R TIE W R TDRE W Bit 6 TNP1 SBR6 SCISWAI 0 0 0 Bit 5 TNP0 SBR5 RSRC 0 0 0 Bit 4 SBR12 SBR4 M 0 0 0 Bit 3 SBR11 SBR3 WAKE 0 0 0 Bit 2 SBR10 SBR2 ILT BERRV 0 Bit 1 SBR9 SBR1 PE BERRIF BERRIE BERRM0 RWU FE Bit 0 SBR8 SBR0 PT BKDIF BKDIE BKDFE SBK PF BERRM1 RE NF TCIE TC RIE RDRF ILIE IDLE TE OR S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 717 Detailed Register Address Map 0x00D0–0x00D7 Asynchronous Serial Interface (SCI1) Map (continued) Address 0x00D5 Name SCI1SR2 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 BRK13 0 R2 T2 Bit 1 TXDIR 0 R1 T1 Bit 0 RAF 0 R0 T0 R 0 0 AMAP TXPOL RXPOL W R R8 0 0 0 0x00D6 SCI1DRH T8 W R R7 R6 R5 R4 R3 0x00D7 SCI1DRL W T7 T6 T5 T4 T3 1 Those registers are accessible if the AMAP bit in the SCI1SR2 register is set to zero 2 Those registers are accessible if the AMAP bit in the SCI1SR2 register is set to one 0x00D8–0x00DF Serial Peripheral Interface (SPI0) Map Address 0x00D8 0x00D9 0x00DA 0x00DB 0x00DC 0x00DD 0x00DE 0x00DF Name SPI0CR1 SPI0CR2 SPI0BR SPI0SR SPI0DRH SPI0DRL Reserved Reserved R W R W R W R W R W R W R W R W Bit 7 SPIE 0 0 SPIF R15 T15 R7 T7 0 0 Bit 6 SPE XFRW SPPR2 0 R14 T14 R6 T6 0 0 Bit 5 SPTIE 0 Bit 4 MSTR MODFEN SPPR0 MODF R12 T12 R4 T4 0 0 Bit 3 CPOL BIDIROE 0 0 R11 T11 R3 T3 0 0 Bit 2 CPHA 0 Bit 1 SSOE SPISWAI SPR1 0 R9 T9 R1 T1 0 0 Bit 0 LSBFE SPC0 SPR0 0 R8 T8 R0 T0 0 0 SPPR1 SPTEF R13 T13 R5 T5 0 0 SPR2 0 R10 T10 R2 T2 0 0 0x00E0–0x00FF Reserved Register Space Address 0x00E00x00FF Name Reserved R W Bit 7 0 Bit 6 0 Bit 5 0 Bit 4 0 Bit 3 0 Bit 2 0 Bit 1 0 Bit 0 0 0x0100–0x0113 NVM Control Register (FTMR) Map Address 0x0100 0x0101 0x0102 0x0103 Name FCLKDIV FSEC FCCOBIX FECCRIX Bit 7 R FDIVLD W R KEYEN1 W R 0 W R 0 W Bit 6 FDIV6 KEYEN0 0 0 Bit 5 FDIV5 RNV5 0 0 Bit 4 FDIV4 RNV4 0 0 Bit 3 FDIV3 RNV3 0 0 Bit 2 FDIV2 RNV2 Bit 1 FDIV1 SEC1 Bit 0 FDIV0 SEC0 CCOBIX2 ECCRIX2 CCOBIX1 ECCRIX1 CCOBIX0 ECCRIX0 S12XS Family Reference Manual, Rev. 1.09 718 Freescale Semiconductor Detailed Register Address Map 0x0100–0x0113 NVM Control Register (FTMR) Map (continued) Address 0x0104 0x0105 0x0106 0x0107 0x0108 0x0109 0x010A 0x010B 0x010C 0x010D 0x010E 0x010F 0x0110 0x0111 0x0112 0x0113 Name FCNFG FERCNFG FSTAT FERSTAT FPROT DFPROT FCCOBHI FCCOBLO Reserved Reserved FECCRHI FECCRLO FOPT Reserved Reserved Reserved R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W Bit 7 CCIE 0 Bit 6 0 0 0 0 RNV6 0 Bit 5 0 0 Bit 4 IGNSF 0 Bit 3 0 0 MGBUSY 0 Bit 2 0 0 RSVD 0 Bit 1 FDFD DFDIE Bit 0 FSFD SFDIE CCIF 0 ACCERR 0 FPVIOL 0 MGSTAT1 MGSTAT0 DFDIF FPLS1 DPS1 CCOB9 CCOB1 0 0 ECCR9 ECCR1 NV1 0 0 0 SFDIF FPLS0 DPS0 CCOB8 CCOB0 0 0 ECCR8 ECCR0 NV0 0 0 0 FPOPEN DPOPEN CCOB15 CCOB7 0 0 ECCR15 ECCR7 NV7 0 0 0 FPHDIS 0 FPHS1 DPS4 CCOB12 CCOB4 0 0 ECCR12 ECCR4 NV4 0 0 0 FPHS0 DPS3 CCOB11 CCOB3 0 0 ECCR11 ECCR3 NV3 0 0 0 FPLDIS DPS2 CCOB10 CCOB2 0 0 ECCR10 ECCR2 NV2 0 0 0 CCOB14 CCOB6 0 0 ECCR14 ECCR6 NV6 0 0 0 CCOB13 CCOB5 0 0 ECCR13 ECCR5 NV5 0 0 0 0x0114–0x011F Reserved Register Space Address 0x01140x011F Name Reserved R W Bit 7 0 Bit 6 0 Bit 5 0 Bit 4 0 Bit 3 0 Bit 2 0 Bit 1 0 Bit 0 0 S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 719 Detailed Register Address Map 0x0120–0x012F Interrupt Module (S12XINT) Map Address 0x0120 0x0121 0x0122 0x0123 0x0124 0x0125 0x0126 0x0127 Name Reserved IVBR Reserved Reserved Reserved Reserved INT_XGPRIO INT_CFADDR R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W Bit 7 0 Bit 6 0 Bit 5 0 Bit 4 0 Bit 3 0 Bit 2 0 Bit 1 0 Bit 0 0 IVB_ADDR[7:0] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 XILVL[2:0] 0 0 INT_CFADDR[7:4] RQST RQST RQST RQST RQST RQST RQST RQST 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x0128 INT_CFDATA0 0x0129 INT_CFDATA1 0x012A INT_CFDATA2 0x012B INT_CFDATA3 0x012C INT_CFDATA4 0x012D INT_CFDATA5 0x012E INT_CFDATA6 0x012F INT_CFDATA7 PRIOLVL[2:0] PRIOLVL[2:0] PRIOLVL[2:0] PRIOLVL[2:0] PRIOLVL[2:0] PRIOLVL[2:0] PRIOLVL[2:0] PRIOLVL[2:0] 0x00130–0x013F Reserved Register Space Address 0x01300x013F Name Reserved R W Bit 7 0 Bit 6 0 Bit 5 0 Bit 4 0 Bit 3 0 Bit 2 0 Bit 1 0 Bit 0 0 0x0140–0x017F MSCAN (CAN0) Map Address 0x0140 0x0141 Name CAN0CTL0 CAN0CTL1 Bit 7 R RXFRM W R CANE W Bit 6 RXACT Bit 5 CSWAI LOOPB Bit 4 SYNCH Bit 3 TIME BORM Bit 2 WUPE WUPM Bit 1 SLPRQ SLPAK Bit 0 INITRQ INITAK CLKSRC LISTEN S12XS Family Reference Manual, Rev. 1.09 720 Freescale Semiconductor Detailed Register Address Map 0x0140–0x017F MSCAN (CAN0) Map (continued) Address 0x0142 0x0143 0x0144 0x0145 0x0146 0x0147 0x0148 0x0149 0x014A 0x014B 0x014C 0x014D 0x014E 0x014F 0x01500x0153 Name CAN0BTR0 CAN0BTR1 CAN0RFLG CAN0RIER CAN0TFLG CAN0TIER CAN0TARQ CAN0TAAK CAN0TBSEL CAN0IDAC Reserved CAN0MISC CAN0RXERR CAN0TXERR CAN0IDAR0CAN0IDAR3 Bit 7 R SJW1 W R SAMP W R WUPIF W R WUPIE W R 0 W R 0 W R 0 W R 0 W R 0 W R 0 W R 0 W R 0 W R RXERR7 W R TXERR7 W R AC7 W R AM7 W R AC7 W R AM7 W R W R W Bit 6 SJW0 TSEG22 CSCIF CSCIE 0 0 0 0 0 0 0 0 RXERR6 TXERR6 Bit 5 BRP5 TSEG21 RSTAT1 Bit 4 BRP4 TSEG20 RSTAT0 Bit 3 BRP3 TSEG13 TSTAT1 Bit 2 BRP2 TSEG12 TSTAT0 Bit 1 BRP1 TSEG11 OVRIF OVRIE TXE1 TXEIE1 ABTRQ1 ABTAK1 Bit 0 BRP0 TSEG10 RXF RXFIE TXE0 TXEIE0 ABTRQ0 ABTAK0 RSTATE1 0 0 0 0 0 RSTATE0 0 0 0 0 0 TSTATE1 0 0 0 0 0 0 0 0 RXERR3 TXERR3 TSTATE0 TXE2 TXEIE2 ABTRQ2 ABTAK2 TX2 IDHIT2 0 0 RXERR2 TXERR2 TX1 IDHIT1 0 0 RXERR1 TXERR1 TX0 IDHIT0 0 IDAM1 0 0 RXERR5 TXERR5 IDAM0 0 0 RXERR4 TXERR4 BOHOLD RXERR0 TXERR0 AC6 AM6 AC6 AM6 AC5 AM5 AC5 AM5 AC4 AM4 AC4 AM4 AC3 AM3 AC3 AM3 AC2 AM2 AC2 AM2 AC1 AM1 AC1 AM1 AC0 AM0 AC0 AM0 0x0154- CAN0IDMR00x0157 CAN0IDMR3 0x01580x015B CAN0IDAR4CAN0IDAR7 0x015C- CAN0IDMR40x015F CAN0IDMR7 0x01600x016F 0x01700x017F CAN0RXFG FOREGROUND RECEIVE BUFFER (See Detailed MSCAN Foreground Receive and Transmit Buffer Layout) FOREGROUND TRANSMIT BUFFER (See Detailed MSCAN Foreground Receive and Transmit Buffer Layout) CAN0TXFG S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 721 Detailed Register Address Map Detailed MSCAN Foreground Receive and Transmit Buffer Layout Address 0xXXX0 Name Extended ID Standard ID CANxRIDR0 Extended ID Standard ID CANxRIDR1 Extended ID Standard ID CANxRIDR2 Extended ID Standard ID CANxRIDR3 R R W R R W R R W R R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W Bit 7 ID28 ID10 ID20 ID2 ID14 Bit 6 ID27 ID9 ID19 ID1 ID13 Bit 5 ID26 ID8 ID18 ID0 ID12 Bit 4 ID25 ID7 SRR=1 RTR ID11 Bit 3 ID24 ID6 IDE=1 IDE=0 ID10 Bit 2 ID23 ID5 ID17 Bit 1 ID22 ID4 ID16 Bit 0 ID21 ID3 ID15 0xXXX1 ID9 ID8 ID7 0xXXX2 ID6 ID5 ID4 ID3 ID2 ID1 ID0 RTR 0xXXX3 0xXXX4- CANxRDSR00xXXXB CANxRDSR7 0xXXXC 0xXXXD CANRxDLR Reserved DB7 DB6 DB5 DB4 DB3 DLC3 DB2 DLC2 DB1 DLC1 DB0 DLC0 0xXXXE CANxRTSRH 0xXXXF CANxRTSRL Extended ID CANxTIDR0 Standard ID Extended ID CANxTIDR1 Standard ID Extended ID CANxTIDR2 Standard ID Extended ID CANxTIDR3 Standard ID TSR15 TSR7 TSR14 TSR6 TSR13 TSR5 TSR12 TSR4 TSR11 TSR3 TSR10 TSR2 TSR9 TSR1 TSR8 TSR0 ID28 ID10 ID20 ID2 ID14 ID27 ID9 ID19 ID1 ID13 ID26 ID8 ID18 ID0 ID12 ID25 ID7 SRR=1 RTR ID11 ID24 ID6 IDE=1 IDE=0 ID10 ID23 ID5 ID17 ID22 ID4 ID16 ID21 ID3 ID15 0xXX10 0xXX0x XX10 ID9 ID8 ID7 0xXX12 ID6 ID5 ID4 ID3 ID2 ID1 ID0 RTR 0xXX13 0xXX14- CANxTDSR0– 0xXX1B CANxTDSR7 0xXX1C 0xXX1D 0xXX1E CANxTDLR CANxTTBPR CANxTTSRH DB7 DB6 DB5 DB4 DB3 DLC3 DB2 DLC2 PRIO2 TSR10 DB1 DLC1 PRIO1 TSR9 DB0 DLC0 PRIO0 TSR8 PRIO7 TSR15 PRIO6 TSR14 PRIO5 TSR13 PRIO4 TSR12 PRIO3 TSR11 S12XS Family Reference Manual, Rev. 1.09 722 Freescale Semiconductor Detailed Register Address Map Detailed MSCAN Foreground Receive and Transmit Buffer Layout (continued) Address 0xXX1F Name CANxTTSRL R W Bit 7 TSR7 Bit 6 TSR6 Bit 5 TSR5 Bit 4 TSR4 Bit 3 TSR3 Bit 2 TSR2 Bit 1 TSR1 Bit 0 TSR0 0x0180–0x023F Reserved Register Space Address 0x01800x023F Name Reserved R W Bit 7 0 Bit 6 0 Bit 5 0 Bit 4 0 Bit 3 0 Bit 2 0 Bit 1 0 Bit 0 0 0x0240–0x027F Port Integration Module (PIM) Map 5 of 5 Address 0x0240 0x0241 0x0242 0x0243 0x0244 0x0245 0x0246 0x0247 Name PTT PTIT DDRT RDRT PERT PPST Reserved PTTRR Bit 7 R PTT7 W R PTIT7 W R DDRT7 W R RDRT7 W R PERT7 W R PPST7 W R 0 W R PTTRR7 W Bit 6 PTT6 PTIT6 Bit 5 PTT5 PTIT5 Bit 4 PTT4 PTIT4 Bit 3 PTT3 PTIT3 Bit 2 PTT2 PTIT2 Bit 1 PTT1 PTIT1 Bit 0 PTT0 PTIT0 DDRT6 RDRT6 PERT6 PPST6 0 DDRT5 RDRT5 PERT5 PPST5 0 DDRT4 RDRT4 PERT4 PPST4 0 DDRT3 RDRT3 PERT3 PPST3 0 0 DDRT2 RDRT2 PERT2 PPST2 0 DDRT1 RDRT1 PERT1 PPST1 0 DDRT0 RDRT0 PERT0 PPST0 0 PTTRR6 PTTRR5 PTTRR4 PTTRR2 PTTRR1 PTTRR0 S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 723 Detailed Register Address Map 0x0240–0x027F Port Integration Module (PIM) Map 5 of 5 Address 0x0248 0x0249 0x024A 0x024B 0x024C 0x024D 0x024E 0x024F 0x0250 0x0251 0x0252 0x0253 0x0254 0x0255 0x0256 0x0257 0x0258 0x0259 0x025A 0x025B 0x025C 0x025D 0x025E 0x025F Name PTS PTIS DDRS RDRS PERS PPSS WOMS Reserved PTM PTIM DDRM RDRM PERM PPSM WOMM MODRR PTP PTIP DDRP RDRP PERP PPSP PIEP PIFP R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W Bit 7 PTS7 PTIS7 Bit 6 PTS6 PTIS6 Bit 5 PTS5 PTIS5 Bit 4 PTS4 PTIS4 Bit 3 PTS3 PTIS3 Bit 2 PTS2 PTIS2 Bit 1 PTS1 PTIS1 Bit 0 PTS0 PTIS0 DDRS7 RDRS7 PERS7 PPSS7 WOMS7 0 DDRS6 RDRS6 PERS6 PPSS6 WOMS6 0 DDRS5 RDRS5 PERS5 PPSS5 WOMS5 0 DDRS4 RDRS4 PERS4 PPSS4 WOMS4 0 DDRS3 RDRS3 PERS3 PPSS3 WOMS3 0 DDRS2 RDRS2 PERS2 PPSS2 WOMS2 0 DDRS1 RDRS1 PERS1 PPSS1 WOMS1 0 DDRS0 RDRS0 PERS0 PPSS0 WOMS0 0 PTM7 PTIM7 PTM6 PTIM6 PTM5 PTIM5 PTM4 PTIM4 PTM3 PTIM3 PTM2 PTIM2 PTM1 PTIM1 PTM0 PTIM0 DDRM7 RDRM7 PERM7 PPSM7 WOMM7 MODRR7 PTP7 PTIP7 DDRM6 RDRM6 PERM6 PPSM6 WOMM6 MODRR6 PTP6 PTIP6 DDRM5 RDRM5 PERM5 PPSM5 WOMM5 0 DDRM4 RDRM4 PERM4 PPSM4 WOMM4 MODRR4 PTP4 PTIP4 DDRM3 RDRM3 PERM3 PPSM3 WOMM3 0 DDRM2 RDRM2 PERM2 PPSM2 WOMM2 0 DDRM1 RDRM1 PERM1 PPSM1 WOMM1 0 DDRM0 RDRM0 PERM0 PPSM0 WOMM0 0 PTP5 PTIP5 PTP3 PTIP3 PTP2 PTIP2 PTP1 PTIP1 PTP0 PTIP0 DDRP7 RDRP7 PERP7 PPSP7 PIEP7 PIFP7 DDRP6 RDRP6 PERP6 PPSP6 PIEP6 PIFP6 DDRP5 RDRP5 PERP5 PPSP5 PIEP5 PIFP5 DDRP4 RDRP4 PERP4 PPSP4 PIEP4 PIFP4 DDRP3 RDRP3 PERP3 PPSP3 PIEP3 PIFP3 DDRP2 RDRP2 PERP2 PPSP2 PIEP2 PIFP2 DDRP1 RDRP1 PERP1 PPSP1 PIEP1 PIFP1 DDRP0 RDRP0 PERP0 PPSS0 PIEP0 PIFP0 S12XS Family Reference Manual, Rev. 1.09 724 Freescale Semiconductor Detailed Register Address Map 0x0240–0x027F Port Integration Module (PIM) Map 5 of 5 Address 0x0260 0x0261 0x0262 0x0263 0x0264 0x0265 0x0266 0x0267 0x0268 0x0269 0x026A 0x026B 0x026C 0x026D 0x026E 0x026f 0x0270 0x0271 0x0272 0x0273 0x0274 0x0275 Name PTH PTIH DDRH RDRH PERH PPSH PIEH PIFH PTJ PTIJ DDRJ RDRJ PERJ PPSJ PIEJ PIFJ PT0AD0 PT1AD0 DDR0AD0 DDR1AD0 RDR0AD0 RDR1AD0 R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W Bit 7 PTH7 PTIH7 Bit 6 PTH6 PTIH6 Bit 5 PTH5 PTIH5 Bit 4 PTH4 PTIH4 Bit 3 PTH3 PTIH3 Bit 2 PTH2 PTIH2 Bit 1 PTH1 PTIH1 Bit 0 PTH0 PTIH0 DDRH7 RDRH7 PERH7 PPSH7 PIEH7 PIFH7 PTJ7 PTIJ7 DDRH6 RDRH6 PERH6 PPSH6 PIEH6 PIFH6 PTJ6 PTIJ6 DDRH5 RDRH5 PERH5 PPSH5 PIEH5 PIFH5 0 0 0 0 0 0 0 0 PT0AD0 5 PT1AD0 5 DDRH4 RDRH4 PERH4 PPSH4 PIEH4 PIFH4 0 0 0 0 0 0 0 0 PT0AD0 4 PT1AD0 4 DDRH3 RDRH3 PERH3 PPSH3 PIEH3 PIFH3 0 0 0 0 0 0 0 0 PT0AD0 3 PT1AD0 3 DDRH2 RDRH2 PERH2 PPSH2 PIEH2 PIFH2 0 0 0 0 0 0 0 0 PT0AD0 2 PT1AD0 2 DDRH1 RDRH1 PERH1 PPSH1 PIEH1 PIFH1 PTJ1 PTIJ1 DDRH0 RDRH0 PERH0 PPSH0 PIEH0 PIFH0 PTJ0 PTIJ0 DDRJ7 RDRJ7 PERJ7 PPSJ7 PIEJ7 PIFJ7 PT0AD0 7 PT1AD0 7 DDRJ6 RDRJ6 PERJ6 PPSJ6 PIEJ6 PIFJ6 PT0AD0 6 PT1AD0 6 DDRJ1 RDRJ1 PERJ1 PPSJ1 PIEJ1 PIFJ1 PT0AD0 1 PT1AD0 1 DDRJ0 RDRJ0 PERJ0 PPSJ0 PIEJ0 PIFJ0 PT0AD0 0 PT1AD0 0 DDR0AD0 DDR0AD0 DDR0AD0 DDR0AD0 DDR0AD0 DDR0AD0 DDR0AD0 DDR0AD0 7 6 5 4 3 2 1 0 DDR1AD0 DDR1AD0 DDR1AD0 DDR1AD0 DDR1AD0 DDR1AD0 DDR1AD0 DDR1AD0 7 6 5 4 3 2 1 0 RDR0AD0 RDR0AD0 RDR0AD0 RDR0AD0 RDR0AD0 RDR0AD0 RDR0AD0 RDR0AD0 7 6 5 4 3 2 1 0 RDR1AD0 RDR1AD0 RDR1AD0 RDR1AD0 RDR1AD0 RDR1AD0 RDR1AD0 RDR1AD0 7 6 5 4 3 2 1 0 S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 725 Detailed Register Address Map 0x0240–0x027F Port Integration Module (PIM) Map 5 of 5 Address 0x0276 0x0277 0x02780x027F Name PER0AD0 PER1AD0 Reserved Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 R PER0AD0 PER0AD0 PER0AD0 PER0AD0 PER0AD0 PER0AD0 PER0AD0 PER0AD0 7 6 5 4 3 2 1 0 W R PER1AD0 PER1AD0 PER1AD0 PER1AD0 PER1AD0 PER1AD0 PER1AD0 PER1AD0 7 6 5 4 3 2 1 0 W R 0 0 0 0 0 0 0 0 W 0x0280–0x02BF Reserved Register Space Address 0x02800x02BF Name Reserved R W Bit 7 0 Bit 6 0 Bit 5 0 Bit 4 0 Bit 3 0 Bit 2 0 Bit 1 0 Bit 0 0 0x02C0–0x02EF Analog-to-Digital Converter 12-Bit 16-Channel (ATD0) Map Address 0x02C0 0x02C1 0x02C2 0x02C3 0x02C4 0x02C5 0x02C6 0x02C7 0x02C8 0x02C9 0x02CA 0x02CB 0x02CC 0x02CD Name ATD0CTL0 ATD0CTL1 ATD0CTL2 ATD0CTL3 ATD0CTL4 ATD0CTL5 ATD0STAT0 Reserved ATD0CMPEH ATD0CMPEL ATD0STAT2H ATD0STAT2L ATD0DIENH ATD0DIENL Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 WRAP1 ETRIG CH1 ASCIE FRZ1 PRS1 CB CC1 0 Bit 0 WRAP0 ETRIG CH0 ACMPIE FRZ0 PRS0 CA CC0 0 R 0 0 0 0 WRAP3 WRAP2 W R ETRIG ETRIG ETRIG SRES1 SRES0 SMP_DIS SEL CH3 CH2 W R 0 AFFC ICLKSTP ETRIGLE ETRIGP ETRIGE W R DJM S8C S4C S2C S1C FIFO W R SMP2 SMP1 SMP0 PRS4 PRS3 PRS2 W R 0 SC SCAN MULT CD CC W R 0 CC3 CC2 SCF ETORF FIFOR W R 0 0 0 0 0 0 W R CMPE15 CMPE14 CMPE13 CMPE12 CMPE11 CMPE10 W R CMPE7 CMPE6 CMPE5 CMPE4 CMPE3 CMPE2 W R CCF15 CCF14 CCF13 CCF12 CCF11 CCF10 W R CCF7 CCF6 CCF5 CCF4 CCF3 CCF2 W R IEN15 IEN14 IEN13 IEN12 IEN11 IEN10 W R IEN7 IEN6 IEN5 IEN4 IEN3 IEN2 W R CMPHT15 CMPHT14 CMPHT13 CMPHT12 CMPHT11 CMPHT10 W CMPE9 CMPE1 CCF9 CCF1 CMPE8 CMPE0 CCF8 CCF0 IEN9 IEN1 CMPHT9 IEN8 IEN0 CMPHT8 0x02CE ATD0CMPHTH S12XS Family Reference Manual, Rev. 1.09 726 Freescale Semiconductor Detailed Register Address Map 0x02C0–0x02EF Analog-to-Digital Converter 12-Bit 16-Channel (ATD0) Map (continued) Address Name Bit 7 Bit 6 CMPHT6 14 Bit6 14 Bit6 14 Bit6 14 Bit6 14 Bit6 14 Bit6 14 Bit6 14 Bit6 14 Bit6 14 Bit6 14 Bit6 Bit 5 CMPHT5 13 0 13 0 13 0 13 0 13 0 13 0 13 0 13 0 13 0 13 0 13 0 Bit 4 CMPHT4 12 0 12 0 12 0 12 0 12 0 12 0 12 0 12 0 12 0 12 0 12 0 Bit 3 CMPHT3 11 0 11 0 11 0 11 0 11 0 11 0 11 0 11 0 11 0 11 0 11 0 Bit 2 CMPHT2 10 0 10 0 10 0 10 0 10 0 10 0 10 0 10 0 10 0 10 0 10 0 Bit 1 CMPHT1 9 0 9 0 9 0 9 0 9 0 9 0 9 0 9 0 9 0 9 0 9 0 Bit 0 CMPHT0 Bit8 0 Bit8 0 Bit8 0 Bit8 0 Bit8 0 Bit8 0 Bit8 0 Bit8 0 Bit8 0 Bit8 0 Bit8 0 R CMPHT7 W R Bit15 ATD0DR0H W R Bit7 ATD0DR0L W R Bit15 ATD0DR1H W R Bit7 ATD0DR1L W R Bit15 ATD0DR2H W R Bit7 ATD0DR2L W R Bit15 ATD0DR3H W R Bit7 ATD0DR3L W R Bit15 ATD0DR4H W R Bit7 ATD0DR4L W R Bit15 ATD0DR5H W R Bit7 ATD0DR5L W R Bit15 ATD0DR6H W R Bit7 ATD0DR6L W R Bit15 ATD0DR7H W R Bit7 ATD0DR7L W R Bit15 ATD0DR8H W R Bit7 ATD0DR8L W R Bit15 ATD0DR9H W R Bit7 ATD0DR9L W R Bit15 ATD0DR10H W R Bit7 ATD0DR10L W 0x02CF ATD0CMPHTL 0x02D0 0x02D1 0x02D2 0x02D3 0x02D4 0x02D5 0x02D6 0x02D7 0x02D8 0x02D9 0x02DA 0x02DB 0x02DC 0x02DD 0x02DE 0x02DF 0x02E0 0x02E1 0x02E2 0x02E3 0x02E4 0x02E5 S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 727 Detailed Register Address Map 0x02C0–0x02EF Analog-to-Digital Converter 12-Bit 16-Channel (ATD0) Map (continued) Address 0x02E6 0x02E7 0x02E8 0x02E9 0x02EA 0x02EB 0x02EC 0x02ED 0x02EE 0x02EF Name ATD0DR11H ATD0DR11L ATD0DR12H ATD0DR12L ATD0DR13H ATD0DR13L ATD0DR14H ATD0DR14L ATD0DR15H ATD0DR15L R W R W R W R W R W R W R W R W R W R W Bit 7 Bit15 Bit7 Bit15 Bit7 Bit15 Bit7 Bit15 Bit7 Bit15 Bit7 Bit 6 14 Bit6 14 Bit6 14 Bit6 14 Bit6 14 Bit6 Bit 5 13 0 13 0 13 0 13 0 13 0 Bit 4 12 0 12 0 12 0 12 0 12 0 Bit 3 11 0 11 0 11 0 11 0 11 0 Bit 2 10 0 10 0 10 0 10 0 10 0 Bit 1 9 0 9 0 9 0 9 0 9 0 Bit 0 Bit8 0 Bit8 0 Bit8 0 Bit8 0 Bit8 0 0x02F0–0x02F7 Voltage Regulator (VREG_3V3) Map Address 0x02F0 0x02F1 0x02F2 0x02F3 0x02F4 0x02F5 0x02F6 0x02F7 Name VREGHTCL VREGCTRL VREGAPICL VREGAPITR VREGAPIRH VREGAPIRL Reserved VREGHTTR Bit 7 R 0 W R 0 W R APICLK W R APITR5 W R APIR15 W R APIR7 W R 0 W R HTOEN W Bit 6 0 0 0 Bit 5 VSEL 0 0 Bit 4 VAE 0 Bit 3 HTEN 0 Bit 2 HTDS LVDS Bit 1 HTIE LVIE APIE 0 Bit 0 HTIF LVIF APIF 0 APIFES APITR2 APIR12 APIR4 0 0 APIEA APITR1 APIR11 APIR3 0 APIFE APITR0 APIR10 APIR2 0 APITR4 APIR14 APIR6 0 0 APITR3 APIR13 APIR5 0 0 APIR9 APIR1 0 APIR8 APIR0 0 HTTR3 HTTR2 HTTR1 HTTR0 0x02F8–0x02FF Reserved Address 0x02F8– 0x02FF Name Reserved R W Bit 7 0 Bit 6 0 Bit 5 0 Bit 4 0 Bit 3 0 Bit 2 0 Bit 1 0 Bit 0 0 S12XS Family Reference Manual, Rev. 1.09 728 Freescale Semiconductor Detailed Register Address Map 0x0300–0x0327 Pulse Width Modulator 8-Bit 8-Channel (PWM) Map Address 0x0300 0x0301 0x0302 0x0303 0x0304 0x0305 0x0306 0x0307 0x0308 0x0309 0x030A 0x030B 0x030C 0x030D 0x030E 0x030F 0x0310 0x0311 0x0312 0x0313 0x0314 0x0315 0x0316 Name PWME Bit 7 Bit 6 PWME6 PPOL6 PCLK6 PCKB2 CAE6 CON45 0 0 Bit 5 PWME5 PPOL5 PCLK5 PCKB1 CAE5 CON23 0 0 Bit 4 PWME4 PPOL4 PCLK4 PCKB0 CAE4 CON01 0 0 Bit 3 PWME3 PPOL3 PCLK3 0 Bit 2 PWME2 PPOL2 PCLK2 PCKA2 CAE2 PFRZ 0 0 Bit 1 PWME1 PPOL1 PCLK1 PCKA1 CAE1 0 0 0 Bit 0 PWME0 PPOL0 PCLK0 PCKA0 CAE0 0 0 0 R PWME7 W R PWMPOL PPOL7 W R PWMCLK PCLK7 W R 0 PWMPRCLK W R PWMCAE CAE7 W R PWMCTL CON67 W R 0 PWMTST Test Only W R 0 PWMPRSC W R PWMSCLA Bit 7 W R PWMSCLB Bit 7 W R 0 PWMSCNTA W R 0 PWMSCNTB W R Bit 7 PWMCNT0 W 0 R Bit 7 PWMCNT1 W 0 R Bit 7 PWMCNT2 W 0 R Bit 7 PWMCNT3 W 0 R Bit 7 PWMCNT4 W 0 R Bit 7 PWMCNT5 W 0 R Bit 7 PWMCNT6 W 0 R Bit 7 PWMCNT7 W 0 R PWMPER0 Bit 7 W R PWMPER1 Bit 7 W R PWMPER2 Bit 7 W CAE3 PSWAI 0 0 6 6 0 0 6 0 6 0 6 0 6 0 6 0 6 0 6 0 6 0 6 6 6 5 5 0 0 5 0 5 0 5 0 5 0 5 0 5 0 5 0 5 0 5 5 5 4 4 0 0 4 0 4 0 4 0 4 0 4 0 4 0 4 0 4 0 4 4 4 3 3 0 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 3 3 2 2 0 0 2 0 2 0 2 0 2 0 2 0 2 0 2 0 2 0 2 2 2 1 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 Bit 0 Bit 0 0 0 Bit 0 0 Bit 0 0 Bit 0 0 Bit 0 0 Bit 0 0 Bit 0 0 Bit 0 0 Bit 0 0 Bit 0 Bit 0 Bit 0 S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 729 Detailed Register Address Map 0x0300–0x0327 Pulse Width Modulator 8-Bit 8-Channel (PWM) Map Address 0x0317 0x0318 0x0319 0x031A 0x031B 0x031C 0x031D 0x031E 0x031F 0x0320 0x0321 0x0322 0x0323 Name PWMPER3 PWMPER4 PWMPER5 PWMPER6 PWMPER7 PWMDTY0 PWMDTY1 PWMDTY2 PWMDTY3 PWMDTY4 PWMDTY5 PWMDTY6 PWMDTY7 R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W Bit 7 Bit 7 Bit 7 Bit 7 Bit 7 Bit 7 Bit 7 Bit 7 Bit 7 Bit 7 Bit 7 Bit 7 Bit 7 Bit 7 Bit 6 6 6 6 6 6 6 6 6 6 6 6 6 6 Bit 5 5 5 5 5 5 5 5 5 5 5 5 5 5 0 PWM RSTRT 0 0 0 Bit 4 4 4 4 4 4 4 4 4 4 4 4 4 4 Bit 3 3 3 3 3 3 3 3 3 3 3 3 3 3 0 PWMLVL 0 0 0 0 0 0 0 0 0 Bit 2 2 2 2 2 2 2 2 2 2 2 2 2 2 PWM7IN PWM7INL 0 0 0 Bit 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Bit 0 Bit 0 Bit 0 Bit 0 Bit 0 Bit 0 Bit 0 Bit 0 Bit 0 Bit 0 Bit 0 Bit 0 Bit 0 Bit 0 PWM7 ENA 0 0 0 0x0324 PWMSDN PWMIF 0 0 0 PWMIE 0 0 0 0x0325 0x0326 0x0327 Reserved Reserved Reserved 0x0328–0x033F Reserved Address 0x0328– 0x033F Name Reserved R W Bit 7 0 Bit 6 0 Bit 5 0 Bit 4 0 Bit 3 0 Bit 2 0 Bit 1 0 Bit 0 0 S12XS Family Reference Manual, Rev. 1.09 730 Freescale Semiconductor Detailed Register Address Map 0x00340–0x0367 – Periodic Interrupt Timer (PIT) Map Address 0x0340 0x0341 0x0342 0x0343 0x0344 0x0345 0x0346 0x0347 0x0348 0x0349 0x034A 0x034B 0x034C 0x034D 0x034E 0x034F 0x0350 0x0351 0x0352 0x0353 0x0354 0x0355 Name PITCFLMT PITFLT PITCE PITMUX PITINTE PITTF PITMTLD0 PITMTLD1 PITLD0 (hi) PITLD0 (lo) PITCNT0 (hi) PITCNT0 (lo) PITLD1 (hi) PITLD1 (lo) PITCNT1 (hi) PITCNT1 (lo) PITLD2 (hi) PITLD2 (lo) PITCNT2 (hi) PITCNT2 (lo) PITLD3 (hi) PITLD3 (lo) R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W Bit 7 PITE 0 0 0 0 0 Bit 6 PITSWAI 0 0 0 0 0 Bit 5 PITFRZ 0 0 0 0 0 Bit 4 0 0 0 0 0 0 Bit 3 0 0 PFLT3 PCE3 PMUX3 PINTE3 PTF3 PMTLD3 PMTLD3 PLD11 PLD3 PCNT11 PCNT3 PLD11 PLD3 PCNT11 PCNT3 PLD11 PLD3 PCNT11 PCNT3 PLD11 PLD3 Bit 2 0 0 PFLT2 PCE2 PMUX2 PINTE2 PTF2 PMTLD2 PMTLD2 PLD10 PLD2 PCNT10 PCNT2 PLD10 PLD2 PCNT10 PCNT2 PLD10 PLD2 PCNT10 PCNT2 PLD10 PLD2 Bit 1 0 PFLMT1 0 PFLT1 PCE1 PMUX1 PINTE1 PTF1 PMTLD1 PMTLD1 PLD9 PLD1 PCNT9 PCNT1 PLD9 PLD1 PCNT9 PCNT1 PLD9 PLD1 PCNT9 PCNT1 PLD9 PLD1 Bit 0 0 PFLMT0 0 PFLT0 PCE0 PMUX0 PINTE0 PTF0 PMTLD0 PMTLD0 PLD8 PLD0 PCNT8 PCNT0 PLD8 PLD0 PCNT8 PCNT0 PLD8 PLD0 PCNT8 PCNT0 PLD8 PLD0 PMTLD7 PMTLD7 PLD15 PLD7 PCNT15 PCNT7 PLD15 PLD7 PCNT15 PCNT7 PLD15 PLD7 PCNT15 PCNT7 PLD15 PLD7 PMTLD6 PMTLD6 PLD14 PLD6 PCNT14 PCNT6 PLD14 PLD6 PCNT14 PCNT6 PLD14 PLD6 PCNT14 PCNT6 PLD14 PLD6 PMTLD5 PMTLD5 PLD13 PLD5 PCNT13 PCNT5 PLD13 PLD5 PCNT13 PCNT5 PLD13 PLD5 PCNT13 PCNT5 PLD13 PLD5 PMTLD4 PMTLD4 PLD12 PLD4 PCNT12 PCNT4 PLD12 PLD4 PCNT12 PCNT4 PLD12 PLD4 PCNT12 PCNT4 PLD12 PLD4 S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 731 Detailed Register Address Map Address 0x0356 Name PITCNT3 (hi) Bit 7 Bit 6 PCNT14 PCNT6 0 Bit 5 PCNT13 PCNT5 0 Bit 4 PCNT12 PCNT4 0 Bit 3 PCNT11 PCNT3 0 Bit 2 PCNT10 PCNT2 0 Bit 1 PCNT9 PCNT1 0 Bit 0 PCNT8 PCNT0 0 R PCNT15 W R 0x0357 PITCNT3 (lo) PCNT7 W R 0 0x0358– Reserved 0x0367 W 0x0368–0x077F Reserved Address 0x0368 Name Reserved R W Bit 7 0 Bit 6 0 Bit 5 0 Bit 4 0 Bit 3 0 Bit 2 0 Bit 1 0 Bit 0 0 S12XS Family Reference Manual, Rev. 1.09 732 Freescale Semiconductor Ordering Information Appendix F Ordering Information F.1 Ordering Information The following figure provides an ordering part number example for the devices covered by this data book. There are two options when ordering a device. Customers must choose between ordering either the maskspecific part number or the generic / mask-independent part number. Ordering the mask-specific part number enables the customer to specify which particular maskset they will receive whereas ordering the generic maskset means that FSL will ship the currently preferred maskset (which may change over time). In either case, the marking on the device will always show the generic / mask-independent peritoneums and the mask set number. NOTE The mask identifier suffix and the Tape & Reel suffix are always both omitted from the part number which is actually marked on the device. For specific part numbers to order, please contact your local sales office. The below figure illustrates the structure of a typical mask-specific ordering number for the S12XS family devices. S 9 S12X S256 J1 C AL R Tape & Reel: R = Tape & Reel No R = No Tape & Reel Package Option: AE = 64 LQFP AA = 80 QFP AL = 112 LQFP Temperature Option: C = -40˚C to 85˚C V = -40˚C to 105˚C M = -40˚C to 125˚C Maskset identifier Suffix: First digit usually references wafer fab Second digit usually differentiates mask rev (this suffix is omitted in generic part numbers) Device Title Controller Family Main Memory Type: 9 = Flash Status / Partnumber type: S or SC = Maskset specific part number MC = Generic / mask-independent part number P or PC = prototype status (pre qualification) Figure F-1. Order Part Number Example S12XS Family Reference Manual, Rev. 1.09 Freescale Semiconductor 733 Ordering Information S12XS Family Reference Manual, Rev. 1.09 734 Freescale Semiconductor How to Reach Us: Home Page: www.freescale.com USA/Europe or Locations Not Listed: Freescale Semiconductor Technical Information Center, CH370 1300 N. Alma School Road Chandler, Arizona 85224 1-800-521-6274 or 480-768-2130 Europe, Middle East, and Africa: +44 1296 380 456 (English) +46 8 52200080 (English) +49 89 92103 559 (German) +33 1 69 35 48 48 (French) Japan: Freescale Semiconductor Japan Ltd. Technical Information Center 3-20-1, Minami-Azabu, Minato-ku Tokyo 106-0047, Japan 0120-191014 or +81-3-3440-3569 Asia/Pacific: Freescale Semiconductor Hong Kong Ltd. Technical Information Center 2 Dai King Street Tai Po Industrial Estate Tai Po, N.T., Hong Kong 852-26668334 For Literature Requests Only: Freescale Semiconductor Literature Distribution Center P.O. Box 5405 Denver, Colorado 80217 1-800-441-2447 or 303-675-2140 Fax: 303-675-2150 Information in this document is provided solely to enable system and software implementers to use Freescale Semiconductor products. There are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document. Freescale Semiconductor reserves the right to make changes without further notice to any products herein. Freescale Semiconductor makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpose, nor does Freescale Semiconductor assume any liability arising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without limitation consequential or incidental damages. “Typical” parameters that may be provided in Freescale Semiconductor data sheets and/or specifications can and do vary in different applications and actual performance may vary over time. All operating parameters, including “Typicals”, must be validated for each customer application by customer’s technical experts. Freescale Semiconductor does not convey any license under its patent rights nor the rights of others. Freescale Semiconductor products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the failure of the Freescale Semiconductor product could create a situation where personal injury or death may occur. Should Buyer purchase or use Freescale Semiconductor products for any such unintended or unauthorized application, Buyer shall indemnify and hold Freescale Semiconductor and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claim alleges that Freescale Semiconductor was negligent regarding the design or manufacture of the part. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. Java and all other Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. © Freescale Semiconductor, Inc. 2007. All rights reserved. MC9S12XS256RMV1 Rev. 1.09 09/2009
MC9S12XS128 价格&库存

很抱歉,暂时无法提供与“MC9S12XS128”相匹配的价格&库存,您可以联系我们找货

免费人工找货