![]() |
|
If you can't view the Datasheet, Please click here to try to view without PDF Reader . |
|
Datasheet File OCR Text: |
hcs12 microcontrollers freescale.com mc9s12ne64 data sheet mc9s12ne64v1 rev. 1.1 06/2006
mc9s12ne64 data sheet mc9s12ne64v1 rev. 1.1 06/2006 mc9s12ne64 data sheet, rev. 1.1 4 freescale semiconductor to provide the most up-to-date information, the revision of our documents on the world wide web will be the most current. your printed copy may be an earlier revision. to verify you have the latest information available, refer to: http://freescale.com/ the following revision history table summarizes changes contained in this document. revision history date revision level description september, 2004 1.0 initial external release. june 27, 2006 1.1 fixed labels for addresses $0167-$0169 on detailed register map. updated phy rx and tx esd protection characteristics on table a-3. freescale and the freescale logo are trademarks of freescale semiconductor, inc. this product incorporates superflash?technology licensed from sst. freescale semiconductor, inc., 2006. all rights reserved. mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 5 chapter 1 mc9s12ne64 device overview . . . . . . . . . . . . . . . . . . . . . . . . . 19 chapter 2 64 kbyte flash module (s12fts64kv3) . . . . . . . . . . . . . . . . . . 67 chapter 3 port integration module (pim9ne64v1) . . . . . . . . . . . . . . . . . 105 chapter 4 clocks and reset generator (crgv4) . . . . . . . . . . . . . . . . . . 141 chapter 5 oscillator (oscv2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 chapter 6 timer module (tim16b4cv1) . . . . . . . . . . . . . . . . . . . . . . . . . . 181 chapter 7 analog-to-digital converter (atd10b8cv3) . . . . . . . . . . . . . 205 chapter 8 serial communication interface (sciv3) . . . . . . . . . . . . . . . . 229 chapter 9 serial peripheral interface (spiv3) . . . . . . . . . . . . . . . . . . . . . 261 chapter 10 inter-integrated circuit (iicv2) . . . . . . . . . . . . . . . . . . . . . . . . 283 chapter 11 ethernet media access controller (emacv1) . . . . . . . . . . . . 307 chapter 12 ethernet physical transceiver (ephyv2). . . . . . . . . . . . . . . . 347 chapter 13 penta output voltage regulator (vregphyv1) . . . . . . . . . . 379 chapter 14 interrupt (intv1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387 chapter 15 multiplexed external bus interface (mebiv3) . . . . . . . . . . . . 395 chapter 16 module mapping control (mmcv4) . . . . . . . . . . . . . . . . . . . . . 423 chapter 17 background debug module (bdmv4). . . . . . . . . . . . . . . . . . . 443 chapter 18 debug module (dbgv1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469 list of chapters mc9s12ne64 data sheet, rev. 1.1 6 freescale semiconductor mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 7 chapter 1 mc9s12ne64 device overview 1.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 1.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 1.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21 1.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 1.1.4 device memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 1.1.5 detailed register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 1.1.6 part id assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39 1.2 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 1.2.1 device pinout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 1.2.2 signal properties summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 1.2.3 detailed signal descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 1.2.4 power supply pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57 1.3 system clock description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 1.4 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 1.4.1 chip con?uration summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 1.4.2 security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 1.5 low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 1.5.1 stop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 1.5.2 pseudo stop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 1.5.3 wait . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 1.5.4 run . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 1.6 resets and interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 1.6.1 vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 1.6.2 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 1.7 block con?uration for mc9s12ne64 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 1.7.1 v ddr /v regen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 1.7.2 v dd1 , v dd2 , v ss1 , v ss2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 4 1.7.3 clock reset generator (crg) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 1.7.4 oscillator (osc) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 1.7.5 ethernet media access controller (emac) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 1.7.6 ethernet physical transceiver (ephy) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 1.7.7 ram 8k block description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 chapter 2 64 kbyte flash module (s12fts64kv3) 2.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 2.1.1 glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 2.1.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 2.1.3 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67 2.1.4 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 2.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 2.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68 table of contents mc9s12ne64 data sheet, rev. 1.1 8 freescale semiconductor 2.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 2.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .73 2.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 2.4.1 flash command operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 2.5 operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 2.5.1 wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 2.5.2 stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 2.5.3 background debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 2.6 flash module security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 2.6.1 unsecuring the mcu using backdoor key access . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 2.6.2 unsecuring the flash module in special single-chip mode using bdm . . . . . . . . . . . 102 2.7 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 2.7.1 flash reset sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 02 2.7.2 reset while flash command active . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 2.8 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 2.8.1 description of flash interrupt operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 chapter 3 port integration module (pim9ne64v1) 3.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 3.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 3.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 3.3 memory map and register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 0 3.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 3.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 3.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 3.4.1 i/o register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 3.4.2 input register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 3.4.3 reduced drive register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 3.4.4 pull device enable register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 3.4.5 polarity select register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 3.4.6 port t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 3.4.7 port s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 3.4.8 port g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 3.4.9 port h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 3.4.10 port j . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 3.4.11 port l . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 3.4.12 port a, b, e and bkgd pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 3.4.13 external pin descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 8 3.4.14 low power options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 38 3.5 initialization/application information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 3.5.1 reset initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 3.6 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 3.6.1 interrupt sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 3.6.2 recovery from stop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 39 mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 9 chapter 4 clocks and reset generator (crgv4) 4.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 4.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 4.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 42 4.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 4.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 4.2.1 v ddpll , v sspll ?pll operating voltage, pll ground . . . . . . . . . . . . . . . . . . . . . . 143 4.2.2 xfc ?pll loop filter pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 4.2.3 reset ?reset pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 4.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 44 4.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 4.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 4.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 4.4.1 phase locked loop (pll) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 4.4.2 system clocks generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 4.4.3 clock monitor (cm) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 0 4.4.4 clock quality checker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 0 4.4.5 computer operating properly watchdog (cop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 4.4.6 real-time interrupt (rti) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 4.4.7 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 63 4.4.8 low-power operation in run mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 4.4.9 low-power operation in wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 4.4.10 low-power operation in stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 4.5 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 4.5.1 clock monitor reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 74 4.5.2 computer operating properly watchdog (cop) reset . . . . . . . . . . . . . . . . . . . . . . . . . 174 4.5.3 power-on reset, low voltage reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 4.6 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 4.6.1 real-time interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 4.6.2 pll lock interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 4.6.3 self-clock mode interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 chapter 5 oscillator (oscv2) 5.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 5.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 5.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 77 5.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 5.2.1 v ddpll and v sspll ?pll operating voltage, pll ground . . . . . . . . . . . . . . . . . . . 178 5.2.2 extal and xtal ?clock/crystal source pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 5.2.3 xclks ?colpitts/pierce oscillator selection signal . . . . . . . . . . . . . . . . . . . . . . . . . 179 5.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 80 5.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 mc9s12ne64 data sheet, rev. 1.1 10 freescale semiconductor 5.4.1 amplitude limitation control (alc) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 5.4.2 clock monitor (cm) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 0 5.5 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 chapter 6 timer module (tim16b4cv1) 6.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 6.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 6.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 81 6.1.3 block diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 6.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 6.2.1 ioc7 ?input capture and output compare channel 7 pin . . . . . . . . . . . . . . . . . . . . 184 6.2.2 ioc6 ?input capture and output compare channel 6 pin . . . . . . . . . . . . . . . . . . . . 184 6.2.3 ioc5 ?input capture and output compare channel 5 pin . . . . . . . . . . . . . . . . . . . . 184 6.2.4 ioc4 ?input capture and output compare channel 4 pin . . . . . . . . . . . . . . . . . . . . 184 6.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 85 6.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 6.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 6.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 6.4.1 prescaler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 6.4.2 input capture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 6.4.3 output compare . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 6.4.4 pulse accumulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 6.4.5 event counter mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 3 6.4.6 gated time accumulation mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 6.5 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 6.6 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 6.6.1 channel [7:4] interrupt (c[7:4]f) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 6.6.2 pulse accumulator input interrupt (paovi) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 6.6.3 pulse accumulator over?w interrupt (paovf) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 6.6.4 timer over?w interrupt (tof) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 chapter 7 analog-to-digital converter (atd10b8cv3) 7.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 7.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 7.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 05 7.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 7.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 7.2.1 anx (x = 7, 6, 5, 4, 3, 2, 1, 0) ?analog input pin . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 7.2.2 etrig3, etrig2, etrig1, and etrig0 ?external trigger pins . . . . . . . . . . . . . . 206 7.2.3 v rh and v rl ?high and low reference voltage pins . . . . . . . . . . . . . . . . . . . . . . . . 206 7.2.4 v dda and v ssa ?power supply pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 7.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 08 mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 11 7.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 7.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 7.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 7.4.1 analog sub-block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 7.4.2 digital sub-block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 7.5 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 7.6 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 chapter 8 serial communication interface (sciv3) 8.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 8.1.1 glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 8.1.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 8.1.3 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 30 8.1.4 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231 8.2 external signal descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232 8.2.1 txd ?sci transmit pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232 8.2.2 rxd ?sci receive pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232 8.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 32 8.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232 8.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232 8.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 8.4.1 infrared interface submodule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 8.4.2 data format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 8.4.3 baud rate generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 5 8.4.4 transmitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 8.4.5 receiver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 8.4.6 single-wire operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 7 8.4.7 loop operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 8.5 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 8.5.1 description of interrupt operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 8.5.2 recovery from wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 chapter 9 serial peripheral interface (spiv3) 9.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 9.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 9.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 61 9.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 9.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 9.2.1 mosi ?master out/slave in pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 9.2.2 miso ?master in/slave out pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 9.2.3 ss ?slave select pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 9.2.4 sck ?serial clock pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 mc9s12ne64 data sheet, rev. 1.1 12 freescale semiconductor 9.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 63 9.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 9.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264 9.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 9.4.1 master mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272 9.4.2 slave mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 9.4.3 transmission formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 4 9.4.4 spi baud rate generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277 9.4.5 special features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278 9.4.6 error conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279 9.4.7 operation in run mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 9.4.8 operation in wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 9.4.9 operation in stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 9.5 reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 9.6 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 9.6.1 modf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 9.6.2 spif . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 9.6.3 sptef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 chapter 10 inter-integrated circuit (iicv2) 10.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283 10.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283 10.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284 10.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284 10.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 10.2.1 iic_scl ?serial clock line pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 10.2.2 iic_sda ?serial data line pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 10.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 10.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 10.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 10.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 10.4.1 i-bus protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 10.4.2 operation in run mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300 10.4.3 operation in wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 0 10.4.4 operation in stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 0 10.5 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301 10.6 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301 10.7 initialization/application information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301 10.7.1 iic programming examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301 mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 13 chapter 11 ethernet media access controller (emacv1) 11.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307 11.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307 11.1.2 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308 11.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308 11.2.1 mii_txclk ?mii transmit clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 11.2.2 mii_txd[3:0] ?mii transmit data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 11.2.3 mii_txen ?mii transmit enable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 11.2.4 mii_txer ?mii transmit coding error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 11.2.5 mii_rxclk ?mii receive clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 11.2.6 mii_rxd[3:0] ?mii receive data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310 11.2.7 mii_rxdv ?mii receive data valid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310 11.2.8 mii_rxer ?mii receive error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310 11.2.9 mii_crs ?mii carrier sense . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310 11.2.10mii_col ?mii collision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310 11.2.11mii_mdc ?mii management data clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311 11.2.12mii_mdio ?mii management data input/output . . . . . . . . . . . . . . . . . . . . . . . . . . 311 11.3 memory map and register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 11 11.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311 11.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312 11.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330 11.4.1 ethernet frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330 11.4.2 receiver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333 11.4.3 transmitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338 11.4.4 ethernet buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340 11.4.5 full-duplex operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 41 11.4.6 mii management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342 11.4.7 loopback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344 11.4.8 software reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345 11.4.9 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345 11.4.10debug and stop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345 chapter 12 ethernet physical transceiver (ephyv2) 12.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347 12.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347 12.1.2 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348 12.2 external signal descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349 12.2.1 phy_txp ?ephy twisted pair output + . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349 12.2.2 phy_txn ?ephy twisted pair output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349 12.2.3 phy_rxp ?ephy twisted pair input + . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349 12.2.4 phy_rxn ?ephy twisted pair input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350 12.2.5 phy_rbias ?ephy bias control resistor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350 mc9s12ne64 data sheet, rev. 1.1 14 freescale semiconductor 12.2.6 phy_vddrx, phy_vssrx ?power supply pins for ephy receiver . . . . . . . . . 350 12.2.7 phy_vddtx, phy_vsstx ?power supply pins for ephy transmitter . . . . . . . 350 12.2.8 phy_vdda, phy_vssa ?power supply pins for ephy analog . . . . . . . . . . . . . 350 12.2.9 colled ?collision led . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350 12.2.10dupled ?duplex led . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350 12.2.11spdled ?speed led . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350 12.2.12lnkled ?link led . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350 12.2.13actlec ?activity led . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351 12.3 memory map and register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 51 12.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351 12.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351 12.3.3 mii registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354 12.3.4 phy-speci? registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 4 12.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 12.4.1 power down/initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368 12.4.2 auto-negotiation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370 12.4.3 10base-t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 12.4.4 100base-tx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373 12.4.5 low power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 76 chapter 13 penta output voltage regulator (vregphyv1) 13.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379 13.1.1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379 13.1.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379 13.1.3 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379 13.1.4 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380 13.2 signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381 13.2.1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381 13.2.2 detailed signal descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381 13.3 memory map and registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383 13.3.1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383 13.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383 13.4.1 general . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383 13.4.2 reg - regulator core . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 83 13.4.3 por - power-on reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384 13.4.4 lvr - low voltage reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384 13.4.5 ctrl - regulator control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384 13.5 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384 13.5.1 general . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384 13.5.2 description of reset operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384 13.6 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385 13.6.1 general . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385 mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 15 chapter 14 interrupt (intv1) 14.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387 14.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388 14.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388 14.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388 14.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389 14.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389 14.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389 14.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391 14.4.1 low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 91 14.5 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391 14.6 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391 14.6.1 interrupt registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392 14.6.2 highest priority i-bit maskable interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392 14.6.3 interrupt priority decoder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 92 14.7 exception priority . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392 chapter 15 multiplexed external bus interface (mebiv3) 15.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395 15.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395 15.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397 15.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397 15.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399 15.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400 15.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400 15.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416 15.4.1 detecting access type from external signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416 15.4.2 stretched bus cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417 15.4.3 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417 15.4.4 internal visibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422 15.4.5 low-power options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 22 chapter 16 module mapping control (mmcv4) 16.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423 16.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423 16.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424 16.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424 16.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424 16.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424 16.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426 16.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435 mc9s12ne64 data sheet, rev. 1.1 16 freescale semiconductor 16.4.1 bus control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435 16.4.2 address decoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436 16.4.3 memory expansion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 37 chapter 17 background debug module (bdmv4) 17.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443 17.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443 17.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444 17.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444 17.2.1 bkgd ?background interface pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445 17.2.2 t a ghi ?high byte instruction tagging pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445 17.2.3 t a glo ?low byte instruction tagging pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445 17.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446 17.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446 17.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447 17.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452 17.4.1 security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452 17.4.2 enabling and activating bdm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452 17.4.3 bdm hardware commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453 17.4.4 standard bdm firmware commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454 17.4.5 bdm command structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455 17.4.6 bdm serial interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457 17.4.7 serial interface hardware handshake protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460 17.4.8 hardware handshake abort procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462 17.4.9 sync ?request timed reference pulse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465 17.4.10instruction tracing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465 17.4.11instruction tagging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466 17.4.12serial communication time-out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466 17.4.13operation in wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 67 17.4.14operation in stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 67 chapter 18 debug module (dbgv1) 18.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469 18.1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469 18.1.2 modes of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471 18.1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471 18.2 external signal description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473 18.3 memory map and register de?ition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474 18.3.1 module memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474 18.3.2 register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474 18.4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489 18.4.1 dbg operating in bkp mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489 mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 17 18.4.2 dbg operating in dbg mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491 18.4.3 breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498 18.5 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499 18.6 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499 appendix a electrical characteristics a.1 parameter classification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501 a.2 power supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501 a.3 pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502 a.3.1 3.3 v i/o pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502 a.3.2 analog reference, special function analog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502 a.3.3 oscillator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503 a.3.4 test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503 a.4 current injection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503 a.5 absolute maximum ratings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503 a.6 esd protection and latch-up immunity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 4 a.7 operating conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506 a.8 power dissipation and thermal characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506 a.9 i/o characteristics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508 a.10 supply currents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 510 a.10.1 measurement conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 510 a.10.2 additional remarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 510 a.11 atd electrical characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512 a.11.1 atd operating characteristics ?3.3 v range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512 a.11.2 factors influencing accuracy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512 a.11.3 atd accuracy ?3.3 v range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513 a.12 reset, oscillator, and pll electrical characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516 a.12.1 startup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516 a.12.2 oscillator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517 a.12.3 phase-locked loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 518 a.13 emac electrical characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523 a.13.1 mii timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523 a.14 ephy electrical characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527 a.14.1 10base-t jab and unjab timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527 a.14.2 auto negotiation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528 a.15 flash nvm electrical characteristics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 532 a.15.1 nvm timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 532 a.15.2 nvm reliability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533 a.16 spi electrical characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535 a.16.1 master mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535 a.16.2 slave mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 536 a.17 voltage regulator operating characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 539 a.17.1 mcu power-up and lvr graphical explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 539 a.17.2 output loads. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540 mc9s12ne64 data sheet, rev. 1.1 18 freescale semiconductor a.18 external bus timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541 appendix b schematic and pcb layout design recommendations b.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543 b.1.1 schematic designing with the mc9s12ne64 and adding an ethernet interface . . . . . 543 b.1.2 power supply notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545 b.1.3 clocking notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545 b.1.4 ephy notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545 b.1.5 ephy led indicator notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545 b.2 pcb design recommendation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546 b.2.1 general pcb design recommendations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546 b.2.2 ethernet pcb design recommendations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546 appendix c package information c.1 112-pin lqfp package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549 c.2 80-pin tqfp-ep package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 550 mc9s12ne64 data sheet, rev 1.0 freescale semiconductor 19 chapter 1 mc9s12ne64 device overview 1.1 introduction the mc9s12ne64 is a 112-/80-pin cost-effective, low-end connectivity applications mcu family. the mc9s12ne64 is composed of standard on-chip peripherals including a 16-bit central processing unit (hcs12 cpu), 64k bytes of flash eeprom, 8k bytes of ram, ethernet media access controller (emac) with integrated 10/100 mbps ethernet physical transceiver (ephy), two asynchronous serial communications interface modules (sci), a serial peripheral interface (spi), one inter-ic bus (iic), a 4-channel/16-bit timer module (tim), an 8-channel/10-bit analog-to-digital converter (atd), up to 21 pins available as keypad wakeup inputs (kwu), and two additional external asynchronous interrupts. the inclusion of a pll circuit allows power consumption and performance to be adjusted to suit operational requirements. furthermore, an on-chip bandgap-based voltage regulator (vreg_phy) generates the internal digital supply voltage of 2.5 v (vdd) from a 3.15 v to 3.45 v external supply range. the mc9s12ne64 has full 16-bit data paths throughout. the 112-pin package version has a total of 70 i/o port pins and 10 input-only pins available. the 80-pin package version has a total of 38 i/o port pins and 10 input-only pins available. 1.1.1 features 16-bit hcs12 core hcs12 cpu upward compatible with m68hc11 instruction set interrupt stacking and programmer s model identical to m68hc11 instruction queue enhanced indexed addressing memory map and interface (mmc) interrupt control (int) background debug mode (bdm) enhanced debug12 module, including breakpoints and change-of-?w trace buffer (dbg) multiplexed expansion bus interface (mebi) ?available only in 112-pin package version wakeup interrupt inputs up to 21 port bits available for wakeup interrupt function with digital ?tering memory 64k bytes of flash eeprom 8k bytes of ram analog-to-digital converter (atd) one 8-channel module with 10-bit resolution external conversion trigger capability chapter 1 mc9s12ne64 device overview mc9s12ne64 data sheet, rev 1.0 20 freescale semiconductor timer module (tim) 4-channel timer each channel con?urable as either input capture or output compare simple pwm mode modulo reset of timer counter 16-bit pulse accumulator external event counting gated time accumulation serial interfaces two asynchronous serial communications interface (sci) one synchronous serial peripheral interface (spi) one inter-ic bus (iic) ethernet media access controller (emac) ieee 802.3 compliant medium-independent interface (mii) full-duplex and half-duplex modes flow control using pause frames mii management function address recognition frames with broadcast address are always accepted or always rejected exact match for single 48-bit individual (unicast) address hash (64-bit hash) check of group (multicast) addresses promiscuous mode ethertype ?ter loopback mode two receive and one transmit ethernet buffer interfaces ethernet 10/100 mbps transceiver (ephy) ieee 802.3 compliant digital adaptive equalization half-duplex and full-duplex auto-negotiation next page ability baseline wander (blw) correction 125-mhz clock generator and timing recovery integrated wave-shaping circuitry loopback modes crg (clock and reset generator module) windowed cop watchdog real-time interrupt introduction mc9s12ne64 data sheet, rev 1.0 freescale semiconductor 21 clock monitor pierce oscillator phase-locked loop clock frequency multiplier limp home mode in absence of external clock 25-mhz crystal oscillator reference clock operating frequency 50 mhz equivalent to 25 mhz bus speed for single chip 32 mhz equivalent to 16 mhz bus speed in expanded bus modes internal 2.5-v regulator supports an input voltage range from 3.3 v 5% low-power mode capability includes low-voltage reset (lvr) circuitry 80-pin tqfp-ep or 112-pin lqfp package up to 70 i/o pins with 3.3 v input and drive capability (112-pin package) up to two dedicated 3.3 v input only lines ( irq, xirq) development support single-wire background debug mode (bdm) on-chip hardware breakpoints enhanced dbg debug features 1.1.2 modes of operation normal modes normal single-chip mode normal expanded wide mode 1 normal expanded narrow mode 1 emulation expanded wide mode 1 emulation expanded narrow mode 1 special operating modes special single-chip mode with active background debug mode each of the above modes of operation can be configured for three low-power submodes stop mode pseudo stop mode wait mode secure operation, preventing the unauthorized read and write of the memory contents 2 1.mebi is available only in the 112-pin package and specified at a maximum speed of 16 mhz. if using mebi from 2.5 mhz to 16 mhz, only 10base-t communication is available. 2.no security feature is absolutely secure. however, freescale semiconductor? strategy is to make reading or copying the flash difficult for unauthorized users. chapter 1 mc9s12ne64 device overview mc9s12ne64 data sheet, rev 1.0 22 freescale semiconductor 1.1.3 block diagram figure 1-1. mc9s12ne64 block diagram 64k byte flash eeprom 8k byte ram reset serial communication bkgd r/ w modb xirq noacc vddr / cpu12 periodic interrupt cop watchdog clock monitor single-wire background multiplexed address/data bus analog-to-digital multiplexed wide bus multiplexed narrow bus irq lstrb eclk moda pa4 pa3 pa2 pa1 pa0 pa7 pa6 pa5 addr12 addr11 addr10 addr9 addr8 addr15 addr14 addr13 data12 data11 data10 data9 data8 data15 data14 data13 pb4 pb3 pb2 pb1 pb0 pb7 pb6 pb5 addr4 addr3 addr2 addr1 addr0 addr7 addr6 addr5 data4 data3 data2 data1 data0 data7 data6 data5 data4 data3 data2 data1 data0 data7 data6 data5 pe3 pe4 pe5 pe6 pe7 pe0 pe1 pe2 ioc6 ioc7 ioc4 ioc5 pt4 pt5 pt6 pt7 vrh vrl vdda vssa vrh vrl an2 an6 an0 an7 an1 an3 an4 an5 pad3 pad0 pad1 pad2 vdda vssa rxd txd miso mosi ps3 ps4 ps5 ps0 ps1 ps2 rxd txd pg3 pg4 pg5 pg6 pg0 pg1 pg2 sck ss ps6 ps7 serial peripheral mii_crs mii_col pj2 pj3 kwh2 kwh6 kwh0 kwh1 kwh3 kwh4 kwh5 ph3 ph4 ph5 ph6 ph0 ph1 kwj0 kwj1 pj0 pj1 ddra ddrb pta ptb ddre pte pad ptt ddrt ptg ddrg pts ddrs pth ddrh ptj ddrj voltage regulator debug module vdd1,2 vss1,2 mii_txclk mii_txen mii_txer mii_txd0 mii_txd1 mii_txd2 mii_txd3 kwg2 kwg6 kwg0 kwg1 kwg3 kwg4 kwg5 kwj2 kwj3 timer signals shown in bold are not available on the 80-pin package mii_rxd2 mii_rxer mii_rxd0 mii_rxd1 mii_rxd3 mii_rxclk mii_rxdv xaddr16 xaddr14 xaddr15 xaddr17 pk3 pk0 pk1 pk2 xaddr18 pk4 ddre ptk ecs/romctl pk7 debugger breakpoints clock and reset generator expanded bus interface converter interface interface 0 serial communication interface 1 mii_mdc mii_mdio ph2 mii pl3 pl4 pl0 pl1 ptl ddrl pl2 lnkled spdled actled phy_txp phy_txn phy_rxp phy_rxn 10base-t/ physical transceiver phy_vdda phy_vssa phy_rbias pad5 pad4 pad7 pad6 extal xtal vddpll vsspll xfc dupled pg7 kwg7 pl5 colled pl6 (ephy) emac phy_vddrx phy_vssrx phy_vddtx phy_vsstx kwj7 pj7 kwj6 pj6 sda scl iic xaddr19 pk5 xcs pk6 vddx1,2 100base-tx ethernet test vregen introduction mc9s12ne64 data sheet, rev 1.0 freescale semiconductor 23 1.1.4 device memory map table 1-1 shows the device register map of the mc9s12ne64 after reset. figure 1-1 illustrates the full device memory map with flash and ram. table 1-1. device register map overview address module 1 1 information about the hcs12 core can be found in the mmc, int, mebi, bdm, and dbg block description chapters in this data sheet, and also in the hcs12 cpu reference manual, s12cpuv2/d. size (in bytes) $0000 ?$0017 core (ports a, b, e, modes, inits ?mmc, int, mebi) 24 $0018 ?$0019 reserved 2 $001a ?$001b device id register (partid) 2 $001c ?$001f core (memsiz, irq, hprio ?int, mmc) 4 $0020 ?$002f core (dbg) 16 $0030 ?$0033 core (ppage, port k ?mebi, mmc) 4 $0034 ?$003f clock and reset generator (pll, rti, cop) 12 $0040 ?$006f standard timer 16-bit 4 channels (tim) 48 $0070 ?$007f reserved 16 $0080 ?$009f analog-to-digital converter 10-bit, 8-channel (atd) 32 $00a0 ?$00c7 reserved 40 $00c8 ?$00cf serial communications interface 0 (sci0) 8 $00d0 ?$00d7 serial communications interface 1 (sci1) 8 $00d8 ?$00df serial peripheral interface (spi) 8 $00e0 ?$00e7 inter ic bus (iic) 8 $00e8 ?$00ff reserved 24 $0100 ?$010f flash control register 16 $0110 ?$011f reserved 16 $0120 ?$0123 ethernet physical interface (ephy) 4 $0124 ?$013f reserved 28 $0140 ?$016f ethernet media access controller (emac) 48 $0170 ?$023f reserved 208 $0240 ?$026f port integration module (pim) 48 $0270 ?$03ff reserved 400 chapter 1 mc9s12ne64 device overview mc9s12ne64 data sheet, rev 1.0 24 freescale semiconductor figure 1-2. mc9s12ne64 user con?urable memory map 1.1.5 detailed register map the following tables show the register maps of the mc9s12ne64. for detailed information about register functions, please see the appropriate block description chapter. $0000 $ffff $c000 $8000 $4000 $0400 $2000 $ff00 ext normal single chip expanded special single chip $ff00 $ffff bdm (if active) $c000 $ffff 16k fixed flash eeprom 2k, 4k, 8k, or 16k protected boot sector $8000 $bfff 16k page window four * 16k flash eeprom pages $4000 $7fff 16k fixed flash eeprom 0.5k, 1k, 2k, or 4k protected sector $2000 $3fff 8k bytes ram mappable to any 8k boundary $0000 $03ff 1k register space mappable to any 2k boundary this ?ure shows a suggested map, which is not the map out of reset. after reset the map is: $0000 ?$03ff: register space $0000 ?$1fff: 7k ram (1k ram hidden behind register space) vectors vectors vectors introduction mc9s12ne64 data sheet, rev 1.0 freescale semiconductor 25 $0000 - $000f multiplexed external bus interface module (mebi) map 1 of 3 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $0000 porta read: bit 7 654321 bit 0 write: $0001 portb read: bit 7 654321 bit 0 write: $0002 ddra read: bit 7 654321 bit 0 write: $0003 ddrb read: bit 7 654321 bit 0 write: $0004 reserved read: 00000000 write: $0005 ?0007 reserved read: 00000000 write: $0008 porte read: bit 7 65432 1 bit 0 write: $0009 ddre read: bit 7 65432 00 write: $000a pear read: noacce 0 pipoe neclk lstre rdwe 00 write: $000b mode read: modc modb moda 0 ivis 0 emk eme write: $000c pucr read: pupke 00 pupee 00 pupbe pupae write: $000d rdriv read: rdpk 00 rdpe 00 rdpb rdpa write: $000e ebictl read: 0000000 estr write: $000f reserved read: 00000000 write: $0010 - $0014 module mapping control module (mmc) map 1 of 4 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $0010 initrm read: ram15 ram14 ram13 ram12 ram11 00 ramhal write: $0011 initrg read: 0 reg14 reg13 reg12 reg11 000 write: $0012 initee read: ee15 ee14 ee13 ee12 ee11 00 eeon write: $0013 misc read: 0000 exstr1 exstr0 romhm romon write: $0014 mtst0 read: bit 7 654321 bit 0 write: chapter 1 mc9s12ne64 device overview mc9s12ne64 data sheet, rev 1.0 26 freescale semiconductor $0015 - $0016 interrupt module (int) map 1 of 2 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $0015 itcr read: 0 0 0 wrtint adr3 adr2 adr1 adr0 write: $0016 itest read: inte intc inta int8 int6 int4 int2 int0 write: $0017 - $0017 module mapping control module (mmc) map 2 of 4 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $0017 mtst1 read: bit 7 654321 bit 0 write: $0018 - $0019 reserved address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $0018 $0019 reserved read: 00000000 write: $001a - $001b miscellaneous peripherals address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $001a partidh read: id15 id14 id13 id12 id11 id10 id9 id8 write: $001b partidl read: id7 id6 id5 id4 id3 id2 id1 id0 write: $001c - $001d module mapping control module (mmc) map 3 of 4 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $001c memsiz0 read: reg_sw0 0 eep_sw1 eep_sw0 0 ram_sw2 ram_sw1 ram_sw0 write: $001d memsiz1 read: rom_sw1 rom_sw0 0000pa g_sw1 pag_sw0 write: $001e - $001e multiplexed external bus interface module (mebi) map 2 of 3 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $001e irqcr read: irqe irqen 000000 write: introduction mc9s12ne64 data sheet, rev 1.0 freescale semiconductor 27 $001f - $001f interrupt module (int) map 2 of 2 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $001f hprio read: psel7 psel6 psel5 psel4 psel3 psel2 psel1 0 write: $0020 - $002f debug module (dbg) including bkp map 1 of 1 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $0020 dbgc1 read: dbgen arm trgsel begin dbgbrk 0 capmod write: $0021 dbgsc read: af bf cf 0 trg write: $0022 dbgtbh read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: $0023 dbgtbl read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: $0024 dbgcnt read: tbf 0 cnt write: $0025 dbgccx read: pagsel extcmp write: $0026 dbgcch read: bit 15 14 13 12 11 10 9 bit 8 write: $0027 dbgccl read: bit 7 654321 bit 0 write: $0028 dbgc2 read: bkaben full bdm tagab bkcen tagc rwcen rwc (bkpct0) 1 1 legacy hcs12 mcus used this name for this register. write: $0029 dbgc3 read: bkambh bkambl bkbmbh bkbmbl rwaen rwa rwben rwb (bkpct1) 1 write: $002a dbgcax read: pagsel extcmp (bkp0x) 1 write: $002b dbgcah read: bit 15 14 13 12 11 10 9 bit 8 (bkp0h) 1 write: $002c dbgcal read: bit 7 654321 bit 0 (bkp0l) 1 write: $002d dbgcbx read: pagsel extcmp (bkp1x) 1 write: $002e dbgcbh read: bit 15 14 13 12 11 10 9 bit 8 (bkp1h) 1 write: $002f dbgcbl read: bit 7 654321 bit 0 (bkp1l) 1 write: chapter 1 mc9s12ne64 device overview mc9s12ne64 data sheet, rev 1.0 28 freescale semiconductor $0030 - $0031 module mapping control module (mmc) map 4 of 4 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $0030 ppage read: 0 0 pix5 pix4 pix3 pix2 pix1 pix0 write: $0031 reserved read: 00000000 write: $0032 - $0033 multiplexed external bus interface module (mebi) map 3 of 3 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $0032 portk read: bit 7 654321 bit 0 write: $0033 ddrk read: bit 7 654321 bit 0 write: $0034 - $003f clock and reset generator (crg) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $0034 synr read: 0 0 syn5 syn4 syn3 syn2 syn1 syn0 write: $0035 refdv read: 0000 refdv3 refdv2 refdv1 refdv0 write: $0036 ctflg reserved read: 00000000 write: $0037 crgflg read: rtif porf lvrf lockif lock track scmif scm write: $0038 crgint read: rtie 00 lockie 00 scmie 0 write: $0039 clksel read: pllsel pstp syswai roawai pllwai cwai rtiwai copwai write: $003a pllctl read: cme pllon auto acq 0 pre pce scme write: $003b rtictl read: 0 rtr6 rtr5 rtr4 rtr3 rtr2 rtr1 rtr0 write: $003c copctl read: wcop rsbck 000 cr2 cr1 cr0 write: $003d forbyp reserved read: 00000000 write: $003e ctctl reserved read: 00000000 write: $003f armcop read: 00000000 write: bit 7 654321 bit 0 introduction mc9s12ne64 data sheet, rev 1.0 freescale semiconductor 29 $0040 - $006f 16-bit, 4-channel timer module (tim) (sheet 1 of 2) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $0040 tios read: ios7 ios6 ios5 ios4 0000 write: $0041 cforc read: 00000000 write: foc7 foc6 foc5 foc4 $0042 oc7m read: oc7m7 oc7m6 oc7m5 oc7m4 0000 write: $0043 oc7d read: oc7d7 oc7d6 oc7d5 oc7d4 0000 write: $0044 tcnt (hi) read: bit 15 14 13 12 11 10 9 bit 8 write: $0045 tcnt (lo) read: bit 7 654321 bit 0 write: $0046 tscr1 read: ten tswai tsfrz tffca 0000 write: $0047 ttov read: tov7 tov6 tov5 tov4 0000 write: $0048 tctl1 read: om7 ol7 om6 ol6 om5 ol5 om4 ol4 write: $0049 reserved read: 00000000 write: $004a tctl3 read: edg7b edg7a edg6b edg6a edg5b edg5a edg4b edg4a write: $004b reserved read: 00000000 write: $004c tie read: c7i c6i c5i c4i 0000 write: $004d tscr2 read: toi 000 tcre pr2 pr1 pr0 write: $004e tflg1 read: c7f c6f c5f c4f 0000 write: $004f tflg2 read: tof 0000000 write: $0050 $0057 reserved read: 00000000 write: $0058 tc4 (hi) read: bit 15 14 13 12 11 10 9 bit 8 write: $0059 tc4 (lo) read: bit 7 654321 bit 0 write: $005a tc5 (hi) read: bit 15 14 13 12 11 10 9 bit 8 write: $005b tc5 (lo) read: bit 7 654321 bit 0 write: $005c tc6 (hi) read: bit 15 14 13 12 11 10 9 bit 8 write: chapter 1 mc9s12ne64 device overview mc9s12ne64 data sheet, rev 1.0 30 freescale semiconductor $005d tc6 (lo) read: bit 7 654321 bit 0 write: $005e tc7 (hi) read: bit 15 14 13 12 11 10 9 bit 8 write: $005f tc7 (lo) read: bit 7 654321 bit 0 write: $0060 pactl read: 0 paen pamod pedge clk1 clk0 paovi pai write: $0061 paflg read: 000000 paovf paif write: $0062 pacnt (hi) read: bit 15 14 13 12 11 10 9 bit 8 write: $0063 pacnt (lo) read: bit 7 654321 bit 0 write: $0064 $006f reserved read: 00000000 write: $0080 - $009f 10-bit, 8-channel analog-to-digital converter module (atd) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $0080 atdctl0 read: 00000 wrap2 wrap1 wrap0 write: $0081 atdctl1 read: etrig sel 0000 etrig ch2 etrig ch1 etrig ch0 write: $0082 atdctl2 read: adpu affc awai etrigle etrigp etrige ascie ascif write: $0083 atdctl3 read: 0 s8c s4c s2c s1c fifo frz1 frz0 write: $0084 atdctl4 read: sres8 smp1 smp0 prs4 prs3 prs2 prs1 prs0 write: $0085 atdctl5 read: djm dsgn scan mult 0 cc cb ca write: $0086 atdstat0 read: scf 0 etorf fifor 0 cc2 cc1 cc0 write: $0087 reserved read: 00000000 write: $0088 atdtest0 reserved read: uuuuuuuu write: $0089 atdtest1 read: u u 00000 sc write: $008a unimplemented read: uuuuuuuu write: $008b atdstat1 read: ccf7 ccf6 ccf5 ccf4 ccf3 ccf2 ccf1 ccf0 write: $0040 - $006f 16-bit, 4-channel timer module (tim) (sheet 2 of 2) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 introduction mc9s12ne64 data sheet, rev 1.0 freescale semiconductor 31 $008c unimplemented read: uuuuuuuu write: $008d atddien read: ien7 ien6 ien5 ien4 ien3 ien2 ien1 ien0 write: $008e unimplemented read: uuuuuuuu write: $008f portad read: ptad7 ptad6 ptad5 ptad4 ptad3 ptad2 ptad1 ptad0 write: $0090 atddr0h read: bit15 14 13 12 11 10 9 bit8 write: $0091 atddr0l read: bit7 bit6 000000 write: $0092 atddr1h read: bit15 14 13 12 11 10 9 bit8 write: $0093 atddr1l read: bit7 bit6 000000 write: $0094 atddr2h read: bit15 14 13 12 11 10 9 bit8 write: $0095 atddr2l read: bit7 bit6 000000 write: $0096 atddr3h read: bit15 14 13 12 11 10 9 bit8 write: $0097 atddr3l read: bit7 bit6 000000 write: $0098 atddr4h read: bit15 14 13 12 11 10 9 bit8 write: $0099 atddr4l read: bit7 bit6 000000 write: $009a atddr5h read: bit15 14 13 12 11 10 9 bit8 write: $009b atddr5l read: bit7 bit6 000000 write: $009c atddr6h read: bit15 14 13 12 11 10 9 bit8 write: $009d atddr6l read: bit7 bit6 000000 write: $009e atddr7h read: bit15 14 13 12 11 10 9 bit8 write: $009f atddr7l read: bit7 bit6 000000 write: $00a0 - $00c7 reserved $00a0 ?$00c7 reserved read: 00000000 write: $0080 - $009f 10-bit, 8-channel analog-to-digital converter module (atd) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 chapter 1 mc9s12ne64 device overview mc9s12ne64 data sheet, rev 1.0 32 freescale semiconductor $00c8 - $00cf asynchronous serial communications interface module (sci0) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $00c8 scibdh read: iren tnp1 tnp0 sbr12 sbr11 sbr10 sbr9 sbr8 write: $00c9 scibdl read: sbr7 sbr6 sbr5 sbr4 sbr3 sbr2 sbr1 sbr0 write: $00ca scicr1 read: loops sciswai rsrc m wake ilt pe pt write: $00cb scicr2 read: tie tcie rie ilie te re rwu sbk write: $00cc scisr1 read: tdre tc rdrf idle or nf fe pf write: $00cd scisr2 read: 00000 brk13 txdir raf write: $00ce scidrh read: r8 t8 000000 write: $00cf scidrl read: r7 r6 r5 r4 r3 r2 r1 r0 write: t7 t6 t5 t4 t3 t2 t1 t0 $00d0 - $00d7 asynchronous serial communications interface module (sci1) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $00d0 scibdh read: iren tnp1 tnp0 sbr12 sbr11 sbr10 sbr9 sbr8 write: $00d1 scibdl read: sbr7 sbr6 sbr5 sbr4 sbr3 sbr2 sbr1 sbr0 write: $00d2 scicr1 read: loops sciswai rsrc m wake ilt pe pt write: $00d3 scicr2 read: tie tcie rie ilie te re rwu sbk write: $00d4 scisr1 read: tdre tc rdrf idle or nf fe pf write: $00d5 scisr2 read: 00000 brk13 txdir raf write: $00d6 scidrh read: r8 t8 000000 write: $00d7 scidrl read: r7 r6 r5 r4 r3 r2 r1 r0 write: t7 t6 t5 t4 t3 t2 t1 t0 introduction mc9s12ne64 data sheet, rev 1.0 freescale semiconductor 33 $00d8 - $00df serial peripheral interface module (spi) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $00d8 spicr1 read: spie spe sptie mstr cpol cpha ssoe lsbfe write: $00d9 spicr2 read: 0 0 0 modfen bidiroe 0 spiswai spc0 write: $00da spibr read: 0 sppr2 sppr1 sppr0 0 spr2 spr1 spr0 write: $00db spisr read: spif 0 sptef modf 0000 write: $00dc reserved read: 00000000 write: $00dd spidr read: bit7 654321 bit0 write: $00de reserved read: 00000000 write: $00df reserved read: 00000000 write: $00e0 - $00e7 inter-ic bus module (iic) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $00e0 ibad read: adr7 adr6 adr5 adr4 adr3 adr2 adr1 0 write: $00e1 ibfd read: ibc7 ibc6 ibc5 ibc4 ibc3 ibc2 ibc1 ibc0 write: $00e2 ibcr read: iben ibie ms/ sl tx/ rx txak 00 ibswai write: rsta $00e3 ibsr read: tcf iaas ibb ibal 0 srw ibif rxak write: $00e4 ibdr read: d7 d6 d5 d4 d3 d2 d1 d0 write: $00e5 $00e7 reserved read: 00000000 write: $00e8 - $00ff reserved address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $00e8- $00ff reserved read: 00000000 write: chapter 1 mc9s12ne64 device overview mc9s12ne64 data sheet, rev 1.0 34 freescale semiconductor $0100 - $010f flash control register (fts64k) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $0100 fclkdiv read: fdivld prdiv8 fdiv5 fdiv4 fdiv3 fdiv2 fdiv1 fdiv0 write: $0101 fsec read: keyen nv6 nv5 nv4 nv3 nv2 sec1 sec0 write: $0102 reserved read: 00000000 write: $0103 fcnfg read: cbeie ccie keyacc 00000 write: $0104 fprot read: fpopen nv6 fphdis fphs1 fphs0 fpldis fpls1 fpls0 write: $0105 fstat read: cbeif ccif pviol accerr 0 blank 0 0 write: $0106 fcmd read: 0 cmdb6 cmdb5 00 cmdb2 0 cmdb0 write: $0107 $010f reserved read: 00000000 write: $0110 - $011f reserved address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $0110 ?$011f reserved read: 00000000 write: $0120 - $0123 ethernet physical transceiver module (ephy) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $0120 ephyctl0 read: ephyen andis dis100 dis10 leden ephywai 0 ephyien write: $0121 ephyctl1 read: 0 0 0 phyadd4 phyadd3 phyadd2 phyadd1 phyadd0 write: $0122 ephysr read: 0 0 100dis 10dis 0 0 0 ephyif write: $0123 ephytst reserved read: 00000000 write: $0124 - $013f reserved address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $0124 ?$013f reserved read: 00000000 write: introduction mc9s12ne64 data sheet, rev 1.0 freescale semiconductor 35 $0140 - $016f ethernet media access controller (emac) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $0140 netctl read: emace 00 eswai extphy mlb fdx 0 write: $0141 reserved read: 00000000 write: $0142 reserved read: 00000000 write: $0143 rxcts read: rxact 0 0 rfce 0 prom conmc bcrej write: $0144 txcts read: txact 0 cslf ptrc ssb 000 write: tcmd $0145 etctl read: fpet 00 femw fipv6 farp fipv4 fieee write: $0146 etype read: etype[15:8] write: $0147 etype read: etype[7:0] write: $0148 ptime read: ptime[15:8] write: $0149 ptime read: ptime[7:0] write: $014a ievent [15:8] read: rfcif 0 breif rxeif rxaoif rxboif rxacif rxbcif write: $014b ievent [7:0] read: mmcif 0 lcif ecif 00 txcif 0 write: $0141c imask [15:8] read: rfcie 0 breie rxeie rxaoie rxboie rxacie rxbcie write: $014d imask [7:0] read: mmcie 0 lcie ecie 00 txcie 0 write: $014e swrst read: 00000000 write: macrst $014f reserved read: 00000000 write: $0150 mpadr read: 0 0 0 paddr write: $0151 mradr read: 0 0 0 raddr write: $0152 mwdata read: wdata[15:8] write: $0123 mwdata read: wdata[7:0] write: $0154 mrdata read: rdata[15:8] write: $0155 mrdata read: rdata[7:0] write: chapter 1 mc9s12ne64 device overview mc9s12ne64 data sheet, rev 1.0 36 freescale semiconductor $0156 mcmst read: 0 0 busy nopre mdcsel write: op $0157 reserved read: 00000000 write: $0158 bufcfg [15:8] read: 0 bufmap 0 maxfl[10:8] write: $0159 bufcfg [7:0] read: maxfl[7:0] write: $015a rxaefp [15:8] read: 00000 rxaefp[10:8] write: $015b rxaefp [7:0] read: rxaefp[7:0] write: $015c rxbefp [15:8] read: 00000 rxbefp[10:8] write: $015d rxbefp [7:0] read: rxbefp[7:0] write: $015e txefp [15:8] read: 00000 txefp[10:8] write: $015f txefp read: txefp[7:0] write: $0160 mchash read: mchash[63:56] write: $0161 mchash read: mchash[55:48] write: $0162 mchash read: mchash[47:40] write: $0163 mchash read: mchash[39:32] write: $0164 mchash read: mchash[31:24] write: $0165 mchash read: mchash[23:16] write: $0166 mchash read: mchash[15:8] write: $0167 mchash read: mchash[7:0] write: $0168 macad read: macad[47:40] write: $0169 macad read: macad[39:32] write: $016a macad read: macad[31:24] write: $016b macad read: macad[23:16] write: $016c macad read: macad[15:8] write: $0140 - $016f ethernet media access controller (emac) (continued) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 introduction mc9s12ne64 data sheet, rev 1.0 freescale semiconductor 37 $016d macad read: macad[7:0] write: $016e emisc read: index 0 0 misc[10:8] write: $016f emisc read: misc[7:0] write: $0170 - $023f reserved address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $0170 - $023f reserved read: 00000000 write: $0240 - $026f port integration module (pim) (sheet 1 of 3) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $0240 ptt read: ptt7 ptt6 ptt5 ptt4 0000 write: $0241 ptit read: ptit7 ptit6 ptit5 ptit4 0000 write: $0242 ddrt read: ddrt7 ddrt6 ddrt5 ddrt4 0000 write: $0243 rdrt read: rdrt7 rdrt6 rdrt5 rdrt4 0000 write: $0244 pert read: pert7 pert6 pert5 pert4 0000 write: $0245 ppst read: ppst7 ppst6 ppst5 ppst4 0000 write: $0246 reserved read: 00000000 write: $0247 reserved read: 00000000 write: $0248 pts read: pts7 pts6 pts5 pts4 pts3 pts2 pts1 pts0 write: $0249 ptis read: ptis7 ptis6 ptis5 ptis4 ptis3 ptis2 ptis1 ptis0 write: $024a ddrs read: ddrs7 ddrs6 ddrs5 ddrs4 ddrs3 ddrs2 ddrs1 ddrs0 write: $024b rdrs read: rdrs7 rdrs6 rdrs5 rdrs4 rdrs3 rdrs2 rdrs1 rdrs0 write: $024c pers read: pers7 pers6 pers5 pers4 pers3 pers2 pers1 pers0 write: $024d ppss read: ppss7 ppss6 ppss5 ppss4 ppss3 ppss2 ppss1 ppss0 write: $0140 - $016f ethernet media access controller (emac) (continued) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 chapter 1 mc9s12ne64 device overview mc9s12ne64 data sheet, rev 1.0 38 freescale semiconductor $024e woms read: woms7 woms6 woms5 woms4 woms3 woms2 woms1 woms0 write: $024f reserved read: 00000000 write: $0250 ptg read: ptg7 ptg6 ptg5 ptg4 ptg3 ptg2 ptg1 ptg0 write: $0251 ptig read: ptig7 ptig6 ptig5 ptig4 ptig3 ptig2 ptig1 ptig0 write: $0252 ddrg read: ddrg7 ddrg6 ddrg5 ddrg4 ddrg3 ddrg2 ddrg1 ddrg0 write: $0253 rdrg read: rdrg7 rdrg6 rdrg5 rdrg4 rdrg3 rdrg2 rdrg1 rdrg0 write: $0254 perg read: perg7 perg6 perg5 perg4 perg3 perg2 perg1 perg0 write: $0255 ppsg read: ppsg7 ppsg6 ppsg5 ppsg4 ppsg3 ppsg2 ppsg1 ppsg0 write: $0256 pieg read: pieg7 pieg6 pieg5 pieg4 pieg3 pieg2 pieg1 pieg0 write: $0257 pifg read: pifg7 pifg6 pifg5 pifg4 pifg3 pifg2 pifg1 pifg0 write: $0258 pth read: 0 pth6 pth5 pth4 pth3 pth2 pth1 pth0 write: $0259 ptih read: 0 ptih6 ptih5 ptih4 ptih3 ptih2 ptih1 ptih0 write: $025a ddrh read: 0 ddrh6 ddrh5 ddrh4 ddrh3 ddrh2 ddrh1 ddrh0 write: $025b rdrh read: 0 rdrh6 rdrh5 rdrh4 rdrh3 rdrh2 rdrh1 rdrh0 write: $025c perh read: 0 perh6 perh5 perh4 perh3 perh2 perh1 perh0 write: $025d ppsh read: 0 ppsh6 ppsh5 ppsh4 ppsh3 ppsh2 ppsh1 ppsh0 write: $025e pieh read: 0 pieh6 pieh5 pieh4 pieh3 pieh2 pieh1 pieh0 write: $025f pifh read: 0 pifh6 pifh5 pifh4 pifh3 pifh2 pifh1 pifh0 write: $0260 ptj read: ptj7 ptj6 00 ptj3 ptj2 ptj1 ptj0 write: $0262 ptij read: ptij7 ptij6 0 0 ptij3 ptij2 ptij1 ptij0 write: $0262 ddrj read: ddrj7 ddrj6 00 ddrj3 ddrj2 ddrj1 ddrj0 write: $0263 rdrj read: rdrj7 rdrj6 00 rdrj3 rdrj2 rdrj1 rdrj0 write: $0264 perj read: perj7 perj6 00 perj3 perj2 perj1 perj0 write: $0240 - $026f port integration module (pim) (sheet 2 of 3) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 introduction mc9s12ne64 data sheet, rev 1.0 freescale semiconductor 39 1.1.6 part id assignments the part id is located in two 8-bit registers partidh and partidl (addresses $001a and $001b after reset). the read-only value is a unique part id for each revision of the mcu. table 1-2 shows the assigned part id number. $0265 ppsj read: ppsj7 ppsj6 00 ppsj3 ppsj2 ppsj1 ppsj0 write: $0266 piej read: piej7 piej6 00 piej3 piej2 piej1 piej0 write: $0267 pifj read: pifj7 pifj6 00 pifj3 pifj2 pifj1 pifj0 write: $0268 ptl read: 0 ptl6 ptl5 ptl4 ptl3 ptl2 ptl1 ptl0 write: $0269 ptil read: 0 ptil6 ptil5 ptil4 ptil3 ptil2 ptil1 ptil0 write: $026a ddrl read: 0 ddrl6 ddrl5 ddrl4 ddrl3 ddrl2 ddrl1 ddrl0 write: $026b rdrl read: 0 rdrl6 rdrl5 rdrl4 rdrl3 rdrl2 rdrl1 rdrl0 write: $026c perl read: 0 perl6 perl5 perl4 perl3 perl2 perl1 perl0 write: $026d ppsl read: 0 ppsl6 ppsl5 ppsl4 ppsl3 ppsl2 ppsl1 ppsl0 write: $026e woml read: 0 woml6 woml5 woml4 woml3 woml2 woml1 woml0 write: $026f reserved read: 00000000 write: $0270 - $03ff reserved space address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $0270 ?$3ff reserved read: 00000000 write: table 1-2. assigned part id numbers device mask set number part id 1 1 the coding is as follows: bit 15-12: major family identi?r bit 11-8: minor family identi?r bit 7-4: major mask set revision number including fab transfers bit 3-0: minor (or non full) mask set revision mc9s12ne64 0l19s $8200 mc9s12ne64 1l19s $8201 $0240 - $026f port integration module (pim) (sheet 3 of 3) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 chapter 1 mc9s12ne64 device overview mc9s12ne64 data sheet, rev 1.0 40 freescale semiconductor the prtidh register is constructed of four hexadecimal digits (0xabcd) as follows: digit a?= family id digit ??= memory id (?sh size) digit ??= major mask revision digit ??= minor mask revision currently, family ids are: 0x0 = d family 0x1 = h family 0x2 = b family 0x3 = c family 0x4 = t family 0x5 = e family 0x6 = reserved 0x7 = reserved 0x8 = ne family current memory ids are: 0x0 = 256k 0x1 = 128k 0x2 = 64k 0x3 = 32k 0x4 = 512k the major and minor mask revision increments from 0x0 as follows: major mask increments on a complete (full/all layer) mask change. minor mask increments on a single or smaller than full mask change. the device memory sizes are located in two 8-bit registers memsiz0 and memsiz1 (addresses $001c and $001d after reset). table 1-3 shows the read-only values of these registers. see the module mapping and control (mmc) block description chapter for further details. 1.2 signal description this section describes signals that connect off-chip. it includes a pinout diagram, a table of signal properties, and detailed discussion of signals. table 1-3. memory size registers register name value mc9s12ne64 memsiz0 $03 mc9s12ne64 memsiz1 $80 signal description mc9s12ne64 data sheet, rev 1.0 freescale semiconductor 41 1.2.1 device pinout the mc9s12ne64 is available in a 112-pin low-pro?e quad ?t pack (lqfp) and in an 80-pin quad ?t pack (tqfp-ep). most pins perform two or more functions, as described in this section. figure 1-3 and figure 1-4 show the pin assignments. 1.2.1.1 112-pin lqfp figure 1-3. pin assignments in 112-pin lqfp for mc9s12ne64 pl0/actled pl1/lnkled vddr pl2/spdled pa7/addr15/data15 pa6/addr14/data14 pa5/addr13/data13 pa4/addr12/data12 phy_vssrx phy_vddrx phy_rxn phy_rxp phy_vsstx phy_txn phy_txp phy_vddtx phy_vdda phy_vssa phy_rbias vdd2 vss2 pa3/addr11/data11 pa2/addr10/data10 pa1/addr9/data9 pa0/addr8/data8 pl3/dupled pl4/colled bkgd/modc/ t a ghi pj6/kwj6/iic_sda pj7/kwj7/iic_scl pt4/tim_ioc4 pt5/tim_ioc5 pt6/tim_ioc6 pt7/tim_ioc7 pk7/ ecs/romctl pk6/ xcs pk5/xaddr19 pk4/xaddr18 vdd1 vss1 pk3/xaddr17 pk2/xaddr16 pk1/xaddr15 pk0/xaddr14 vssa vrl vrh vdda pad7/an7 pad6/an6 pad5/an5 pad4/an4 pad3/an3 pad2/an2 pad1/an1 pad0/an0 mii_txer/kwh6/ph6 mii_txen/kwh5/ph5 mii_txclk/kwh4/ph4 mii_txd3/kwh3/ph3 mii_txd2/kwh2/ph2 mii_txd1/kwh1/ph1 mii_txd0/kwh0/ph0 mii_mdc/kwj0/pj0 mii_mdio/kwj1/pj1 addr0/data0/pb0 addr1/data1/pb1 addr2/data2/pb2 addr3/data3/pb3 vddx1 vssx1 addr4/data4/pb4 addr5/data5/pb5 addr6/data6/pb6 addr7/data7/pb7 mii_crs/kwj2/pj2 mii_col/kwj3/pj3 mii_rxd0/kwg0/pg0 mii_rxd1/kwg1/pg1 mii_rxd2/kwg2/pg2 mii_rxd3/kwg3/pg3 mii_rxclk/kwg4/pg4 mii_rxdv/kwg5/pg5 mii_rxer/kwg6/pg6 kwg7/pg7 sci0_rxd/ps0 sci0_txd/ps1 sci1_rxd/ps2 sci1_txd/ps3 spi_miso/ps4 spi_mosi/ps5 spi_sck/ps6 spi_ ss/ps7 noacc/pe7 modb/ipipe1/pe6 moda/ipipe0/pe5 eclk/pe4 vssx2 vddx2 reset vddpll xfc vsspll extal xtal test pl6 pl5 lstrb/ t a glo/pe3 r/ w/pe2 irq/pe1 xirq/pe0 112-pin lqfp 112 111 110 109 108 107 106 105 104 103 102 101 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 signals shown in bold are not available on the 80-pin package chapter 1 mc9s12ne64 device overview mc9s12ne64 data sheet, rev 1.0 42 freescale semiconductor 1.2.1.2 80-pin tqfp-ep the mebi is not available in the 80-pin package. the 80-pin package features an exposed tab that is used for enhanced thermal management. the exposed tab requires special pcb layout considerations as described in appendix b, ?chematic and pcb layout design recommendations . figure 1-4. pin assignments in 80-pin tqfp-ep for mc9s12ne64 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 80-pin tpfp-ep pl0/actled pl1/lnkled vddr pl2/spdled phy_vssrx phy_vddrx phy_rxn phy_rxp phy_vsstx phy_txn phy_txp phy_vddtx phy_vdda phy_vssa phy_rbias vdd2 vss2 pl3/dupled pl4/colled bkgd/modc pj6/kwj6/iic_sda pj7/kwj7/iic_scl pt4/tim_ioc4/ pt5/tim_ioc5 pt6/tim_ioc6 pt7/tim_ioc7 vdd1 vss1 vssa vrl vrh vdda pad7/an7 pad6/an6 pad5/an5 pad4/an4 pad3/an3 pad2/an2 pad1/an1 pad0/an0 mii_txer/kwh6/ph6 mii_txen/kwh5/ph5 mii_txclk/kwh4/ph4 mii_txd3/kwh3/ph3 mii_txd2/kwh2/ph2 mii_txd1/kwh1/ph1 mii_txd0/kwh0/ph0 mii_mdc/kwj0/pj0 mii_mdio/kwj1/pj1 vddx1 vssx1 mii_crs/kwj2/pj2 mii_col/kwj3/pj3 mii_rxd0/kwg0/pg0 mii_rxd1/kwg1/pg1 mii_rxd2/kwg2/pg2 mii_rxd3/kwg3/pg3 mii_rxclk/kwg4/pg4 mii_rxdv/kwg5/pg5 mii_rxer/kwg6/pg6 sci0_rxd/ps0 sci0_txd/ps1 sci1_rxd/ps2 sci1_txd/ps3 spi_miso/ps4 spi_mosi/ps5 spi_sck/ps6 spi_ ss/ps7 eclk/pe4 vssx2 vddx2 reset vddpll xfc vsspll extal xtal test irq/pe1 xirq/pe0 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 signal description mc9s12ne64 data sheet, rev 1.0 freescale semiconductor 43 1.2.2 signal properties summary table 1-4. signal properties (sheet 1 of 4) orig. order 80 pin no. 112 pin no. pin name function 1 pin name function 2 pin name function 3 power domain internal pull resistor description reset state ctrl reset state 28 1 1 ph6 kwh6 mii_txer vddx perh/ ppsh disabled port h i/o pin; emac mii transmit error; interrupt input 29 2 2 ph5 kwh5 mii_txen vddx perh/ ppsh disabled port h i/o pin; emac mii transmit enable; interrupt input 30 3 3 ph4 kwh4 mii_txclk vddx perh/ ppsh disabled port h i/o pin; emac mii transmit clock; interrupt input 31 4 4 ph3 kwh3 mii_txd3 vddx perh/ ppsh disabled port h i/o pin; emac mii transmit data; interrupt input 32 5 5 ph2 kwh2 mii_txd2 vddx perh/ ppsh disabled port h i/o pin; emac mii transmit data; interrupt input 33 6 6 ph1 kwh1 mii_txd1 vddx perh/ ppsh disabled port h i/o pin; emac mii transmit data; interrupt input 34 7 7 ph0 kwh0 mii_txd0 vddx perh/ ppsh disabled port h i/o pin; emac mii transmit data; interrupt input 40 8 8 pj0 kwj0 mii_mdc vddx perj/ ppsj disabled port j i/o pin; emac mii management data clock; interrupt input 39 9 9 pj1 kwj1 mii_mdio vddx perj/ ppsj disabled port j i/o pin; emac mii management data i/o; interrupt input 15 10?3 16?9 pb[7:0] addr[7:0] / data[7:0] vddx pucr disabled port b i/o pin; multiplexed address/data input 62 10 14 vddx1 see table 1-5 63 11 15 vssx1 see table 1-5 38 12 20 pj2 kwj2 mii_crs vddx perj/ ppsj disabled port j i/o pin; emac mii carrier sense; interrupt input 37 13 21 pj3 kwj3 mii_col vddx perj/ ppsj disabled port j i/o pin; emac mii collision; interrupt input 27 14 22 pg0 kwg0 mii_rxd0 vddx perg/ ppsg disabled port g i/o pin; emac mii receive data; interrupt input 26 15 23 pg1 kwg1 mii_rxd1 vddx perg/ ppsg disabled port g i/o pin; emac mii receive data; interrupt input chapter 1 mc9s12ne64 device overview mc9s12ne64 data sheet, rev 1.0 44 freescale semiconductor 25 16 24 pg2 kwg2 mii_rxd2 vddx perg/ ppsg disabled port g i/o pin; emac mii receive data; interrupt input 24 17 25 pg3 kwg3 mii_rxd3 vddx perg/ ppsg disabled port g i/o pin; emac mii receive data; interrupt input 23 18 26 pg4 kwg4 mii_rxclk vddx perg/ ppsg disabled port g i/o pin; emac mii receive clock; interrupt input 22 19 27 pg5 kwg5 mii_rxdv vddx perg/ ppsg disabled port g i/o pin; emac mii receive data valid; interrupt input 21 20 28 pg6 kwg6 mii_rxer vddx perg/ ppsg disabled port g i/o pin; emac mii receive error; interrupt input 20 29 pg7 kwg7 vddx perg/ ppsg disabled port g i/o pin; interrupt input 55 21 30 ps0 sci0_rxd vddx pers/ ppss disabled port s i/o pin; sci0 receive signal input 54 22 31 ps1 sci0_txd vddx pers/ ppss disabled port s i/o pin; sci0 transmit signal input 53 23 32 ps2 sci1_rxd vddx pers/ ppss disabled port s i/o pin; sci1 receive signal input 52 24 33 ps3 sci1_txd vddx pers/ ppss disabled port s i/o pin; sci1 transmit signal input 51 25 34 ps4 spi_ miso vddx pers/ ppss disabled port s i/o pin; spi miso signal input 50 26 35 ps5 spi_ mosi vddx pers/ ppss disabled port s i/o pin; spi mosi signal input 49 27 36 ps6 spi_sck vddx pers/ ppss disabled port s i/o pin; spi sck signal input 48 28 37 ps7 spi_ ss vddx pers/ ppss disabled port s i/o pin; spi ss signal input 6 38 pe7 noacc vddx pucr up port e i/o pin; access input 7 39 pe6 ipipe1 modb vddx while reset pin is low: down port e i/o pin; pipe status; mode selection input 8 40 pe5 ipipe0 moda vddx while reset pin is low: down port e i/o pin; pipe status; mode selection input 9 29 41 pe4 eclk vddx pucr up port e i/o pin; bus clock output input 64 30 42 vssx2 see table 1-5 65 31 43 vddx2 see table 1-5 table 1-4. signal properties (sheet 2 of 4) orig. order 80 pin no. 112 pin no. pin name function 1 pin name function 2 pin name function 3 power domain internal pull resistor description reset state ctrl reset state signal description mc9s12ne64 data sheet, rev 1.0 freescale semiconductor 45 4 32 44 reset vddx none none external reset pin input 66 33 45 vddpll see table 1-5 3 34 46 xfc vddpll na na pll ?ter pin 67 35 47 vsspll see table 1-5 1 36 48 extal vddpll na na oscillator pins input 2 37 49 xtal vddpll na na output 68 38 50 test vddx none none must be grounded input 41 51 pl6 vddx perl/ ppsl disabled port l i/o pin input 42 52 pl5 vddx perl/ ppsl disabled port l i/o pin input 10 53 pe3 t a glo lstrb vddx pucr up port e i/o pin; low strobe; tag signal low input 11 54 pe2 r/ w vddx pucr up port e i/o pin; r/ w in expanded modes input 12 39 55 pe1 irq vddx pucr up port e input; external interrupt pin input 13 40 56 pe0 xirq vddx pucr up port e input; non-maskable interrupt pin input 5 41 57 bkgd modc t a ghi vddx none up background debug; mode pin; tag signal high input 43 42 58 pl4 colled vddx perl/ ppsl disabled port l i/o pin; ephy collision led input 44 43 59 pl3 dupled vddx perl/ ppsl disabled port l i/o pin; ephy full duplex led input 14 60?3 77?0 pa[7:0] addr[15:8]/ data[15:8] vddx pucr disabled port a i/o pin; multiplexed address/data input 69 44 64 vss2 see table 1-5 70 45 65 vdd2 see table 1-5 61 46 66 phy_rbias phy_ vssa na na bias control:1.0% external resistor (see the electricals chapter for r bias ) analog input 71 47 67 phy_vssa see table 1-5 72 48 68 phy_vdda see table 1-5 73 49 69 phy_vddtx see table 1-5 58 50 70 phy_txp phy_ vddtx na na twisted pair output + analog output table 1-4. signal properties (sheet 3 of 4) orig. order 80 pin no. 112 pin no. pin name function 1 pin name function 2 pin name function 3 power domain internal pull resistor description reset state ctrl reset state chapter 1 mc9s12ne64 device overview mc9s12ne64 data sheet, rev 1.0 46 freescale semiconductor 57 51 71 phy_txn phy_ vddtx na na twisted pair output analog output 74 52 72 phy_vsstx see table 1-5 60 53 73 phy_rxp phy_ vddrx na na twisted pair input + analog input 59 54 74 phy_rxn phy_ vddrx na na twisted pair input analog input 75 55 75 phy_vddrx see table 1-5 76 56 76 phy_vssrx see table 1-5 45 57 81 pl2 spdled vddx perl/ ppsl disabled port l i/o pin; ephy 100 mbps led input 77 58 82 vddr/ vregen see table 1-5 46 59 83 pl1 lnkled vddx perl/ ppsl disabled port l i/o pin; ephy valid link led input 47 60 84 pl0 actled vddx perl/ ppsl disabled port l i/o pin; ephy transmit or receive led input 16 61?8 85?2 pad[7:0] an[7:0] vdda none none port ad input pins; atd inputs input 78 69 93 vdda see table 1-5 79 70 94 vrh see table 1-5 80 71 95 vrl see table 1-5 81 72 96 vssa see table 1-5 19 97?00 103?04 pk[5:0] xaddr [19:14] vddx pucr up port k i/o pins; extended addresses input 82 73 101 vss1 see table 1-5 83 74 102 vdd1 see table 1-5 18 105 pk[6] xcs vddx pucr up port k i/o pin; external chip select input 17 106 pk[7] ecs romctl vddx pucr up port k i/o pin; emulation chip select; input 56 75?8 107?10 pt[7:4] tim_ioc [7:4] vddx pert/ ppst disabled port t i/o pins; timer tim input cap. output compare input 35 79 111 pj7 kwj7 iic_scl vddx perj/ ppsj disabled port j i/o pin; iic scl; interrupt input 36 80 112 pj6 kwj6 iic_sda vddx perj/ ppsj disabled port j i/o pin; iic sda; interrupt input table 1-4. signal properties (sheet 4 of 4) orig. order 80 pin no. 112 pin no. pin name function 1 pin name function 2 pin name function 3 power domain internal pull resistor description reset state ctrl reset state signal description mc9s12ne64 data sheet, rev 1.0 freescale semiconductor 47 note signals shown in bold are not available in the 80-pin package. note if the port pins are not bonded out in the chosen package, the user must initialize the registers to be inputs with enabled pull resistance to avoid excess current consumption. this applies to the following pins: (80-pin tqfp-ep): port a[7:0], port b[7:0], port e[7,6,5,3,2], port k[7:0]; port g[7]; port l[6:5] 1.2.3 detailed signal descriptions 1.2.3.1 extal, xtal ?oscillator pins extal and xtal are the external clock and crystal driver pins. upon reset, all the device clocks are derived from the extal input frequency. xtal is the crystal output. 1.2.3.2 reset ?external reset pin reset is an active-low bidirectional control signal that acts as an input to initialize the mcu to a known start-up state. it also acts as an open-drain output to indicate that an internal failure has been detected in either the clock monitor or cop watchdog circuit. external circuitry connected to the reset pin must not include a large capacitance that would interfere with the ability of this signal to rise to a valid logic one within 32 eclk cycles after the low drive is released. upon detection of any reset, an internal circuit drives the reset pin low and a clocked reset sequence controls when the mcu can begin normal processing. the reset pin includes an internal pull-up device. 1.2.3.3 xfc ?pll loop filter pin dedicated pin used to create the pll ?ter. see a.12.3.1, ?fc component selection, and the crg block description chapter for more detailed information. 1.2.3.4 bkgd / modc / t a ghi ?background debug / tag high / mode pin the bkgd / modc / t a ghi pin is used as a pseudo-open-drain pin for background debug communication. it is used as an mcu operating mode select pin during reset. the state of this pin is latched to the modc bit at the rising edge of reset. in mcu expanded modes of operation, while instruction tagging is on, an input low on this pin during the falling edge of e-clock tags the high half of the instruction word being read into the instruction queue. this pin always has an internal pull-up. 1.2.3.5 pa[7:0] / addr[15:8] / data[15:8] ?port a i/o pins pa[7:0] are general-purpose i/o pins. in mcu expanded modes of operation, these pins are used for the multiplexed external address and data bus. pa[7:0] pins are not available in the 80-pin package version. chapter 1 mc9s12ne64 device overview mc9s12ne64 data sheet, rev 1.0 48 freescale semiconductor 1.2.3.6 pb[7:0] / addr[7:0] / data[7:0] ?port b i/o pins pb[7:0] are general-purpose i/o pins. in mcu expanded modes of operation, these pins are used for the multiplexed external address and data bus. pb[7:0] pins are not available in the 80-pin package version. 1.2.3.7 pe7 / noacc ?port e i/o pin 7 pe7 is a general-purpose i/o pin. during mcu expanded modes of operation, the noacc signal, while enabled, is used to indicate that the current bus cycle is an unused or free cycle. this signal will assert when the cpu is not using the bus. 1.2.3.8 pe6 / ipipe1/ modb ?port e i/o pin 6 pe6 is a general-purpose i/o pin. it is used as an mcu operating mode select pin during reset. the state of this pin is latched to the modb bit at the rising edge of reset. this pin is shared with the instruction queue tracking signal ipipe1. pe6 is an input with a pulldown device that is active only while reset is low. pe6 is not available in the 80-pin package version. 1.2.3.9 pe5 / ipipe0 / moda ?port e i/o pin 5 pe5 is a general-purpose i/o pin. it is used as an mcu operating mode select pin during reset. the state of this pin is latched to the moda bit at the rising edge of reset. this pin is shared with the instruction queue tracking signal ipipe0. this pin is an input with a pull-down device that is only active while reset is low. pe5 is not available in the 80-pin package version. 1.2.3.10 pe4 / eclk?port e i/o pin 4 / e-clock output pe4 is a general-purpose i/o pin. in normal single chip mode, pe4 is con?ured with an active pull-up while in reset and immediately out of reset. the pull-up can be turned off by clearing pupee in the pucr register. in all modes except normal single chip mode, the pe4 pin is initially con?ured as the output connection for the internal bus clock (eclk). eclk is used as a timing reference and to demultiplex the address and data in expanded modes. the eclk frequency is equal to 1/2 the crystal frequency out of reset. the eclk output function depends upon the settings of the neclk bit in the pear register, the ivis bit in the mode register, and the estr bit in the ebictl register. all clocks, including the eclk, are halted while the mcu is in stop mode. it is possible to con?ure the mcu to interface to slow external memory. eclk can be stretched for such accesses. the pe4 pin is initially con?ured as eclk output with stretch in all expanded modes. see the misc register (exstr[1:0] bits) for more information. in normal expanded narrow mode, the eclk is available for use in external select decode logic or as a constant speed clock for use in the external application system. signal description mc9s12ne64 data sheet, rev 1.0 freescale semiconductor 49 1.2.3.11 pe3 / t a glo / lstrb ?port e i/o pin 3 / low-byte strobe ( lstrb) pe3 can be used as a general-purpose i/o in all modes and is an input with an active pull-up out of reset. the pull-up can be turned off by clearing pupee in the pucr register. pe3 can also be con?ured as a low-byte strobe ( lstrb). the lstrb signal is used in write operations, so external low byte writes will not be possible until this function is enabled. lstrb can be enabled by setting the lstre bit in the pear register. in expanded wide and emulation narrow modes, and while bdm tagging is enabled, the lstrb function is multiplexed with the t a glo function. while enabled, a logic zero on the t a glo pin at the falling edge of eclk will tag the low byte of an instruction word being read into the instruction queue. pe3 is not available in the 80-pin package version. 1.2.3.12 pe2 / r / w ?port e i/o pin 2 / read/ write pe2 can be used as a general-purpose i/o in all modes and is con?ured as an input with an active pull-up out of reset. the pull-up can be turned off by clearing pupee in the pucr register. if the read/write function is required, it must be enabled by setting the rdwe bit in the pear register. external writes will not be possible until the read/write function is enabled. the pe2 pin is not available in the 80-pin package version. 1.2.3.13 pe1 / irq ?port e input pin 1 / maskable interrupt pin pe1 is always an input and can be read anytime. the pe1 pin is also the irq input used for requesting an asynchronous interrupt to the mcu. during reset, the i bit in the condition code register (ccr) is set and any irq interrupt is masked until the i bit is cleared. the irq is software programmable to either falling-edge-sensitive triggering or level-sensitive triggering based on the setting of the irqe bit in the irqcr register. the irq is always enabled and con?ured to level-sensitive triggering out of reset. it can be disabled by clearing irqen bit in the irqcr register. there is an active pull-up on this pin while in reset and immediately out of reset. the pull-up can be turned off by clearing pupee in the pucr register. 1.2.3.14 pe0 / xirq ?port e input pin 0 / non-maskable interrupt pin pe0 is always an input and can be read anytime. the pe0 pin is also the xirq input for requesting a non-maskable asynchronous interrupt to the mcu. during reset, the x bit in the condition code register (ccr) is set and any xirq interrupt is masked until the x bit is cleared. because the xirq input is level sensitive triggered, it can be connected to a multiple-source wired-or network. there is an active pull-up on this pin while in reset and immediately out of reset. the pull-up can be turned off by clearing pupee in the pucr register. 1.2.3.15 pk7 / ecs / romctl ?port k i/o pin 7 pk7 is a general-purpose i/o pin. during mcu expanded modes of operation, while the emk bit in the mode register is set to 1, this pin is used as the emulation chip select output ( ecs). in expanded modes, the pk7 pin can be used to determine the reset state of the romon bit in the misc register. at the rising edge of reset, the state of the pk7 pin is latched to the romon bit. there is an active pull-up on this pin while in reset and immediately out of reset. the pull-up can be turned off by clearing pupke in the pucr register. pk7 is not available in the 80-pin package version. chapter 1 mc9s12ne64 device overview mc9s12ne64 data sheet, rev 1.0 50 freescale semiconductor 1.2.3.16 pk6 / xcs ?port k i/o pin 6 pk6 is a general-purpose i/o pin. during mcu expanded modes of operation, while the emk bit in the mode register is set to 1, this pin is used as an external chip select signal for most external accesses that are not selected by ecs. there is an active pull-up on this pin while in reset and immediately out of reset. the pull-up can be turned off by clearing pupke in the pucr register. see the multiplexed external bus interface (mebi) block description chapter for further details. pk6 is not available in the 80-pin package version. 1.2.3.17 pk[5:0] / xaddr[19:14] ?port k i/o pins [5:0] pk[5:0] are general-purpose i/o pins. in mcu expanded modes of operation, when the emk bit in the mode register is set to 1, pk[5:0] provide the expanded address xaddr[19:14] for the external bus. there are active pull-ups on pk[5:0] pins while in reset and immediately out of reset. the pull-up can be turned off by clearing pupke in the pucr register. see multiplexed external bus interface (mebi) block description chapter for further details. pk[5:0] are not available in the 80-pin package version. 1.2.3.18 pad[7:0] / an[7:0] ?port ad input pins [7:0] pad[7:0] are the analog inputs for the analog-to-digital converter (atd). they can also be con?ured as general-purpose digital input. see the port integration module (pim) pim_9ne64 block description chapter and the atd_10b8c block description chapter for information about pin con?urations. 1.2.3.19 pg7 / kwg7 ?port g i/o pin 7 pg7 is a general-purpose i/o pin. it can be con?ured to generate an interrupt (kwg7) causing the mcu to exit stop or wait mode. while in reset and immediately out of reset, the pg7 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter for information about pin con?urations. 1.2.3.20 pg6 / kwg6 / mii_rxer ?port g i/o pin 6 pg6 is a general-purpose i/o pin. when the emac mii external interface is enabled, it becomes the receive error (mii_rxer) signal. it can be con?ured to generate an interrupt (kwg6) causing the mcu to exit stop or wait mode. while in reset and immediately out of reset, the pg6 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the emac block description chapter for information about pin con?urations. 1.2.3.21 pg5 / kwg5 / mii_rxdv ?port g i/o pin 5 pg5 is a general-purpose i/o pin. when the emac mii external interface is enabled, it becomes the receive data valid (mii_rxdv) signal. it can be con?ured to generate an interrupt (kwg5) causing the mcu to exit stop or wait mode. while in reset and immediately out of reset, the pg5 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the emac block description chapter for information about pin con?urations. signal description mc9s12ne64 data sheet, rev 1.0 freescale semiconductor 51 1.2.3.22 pg4 / kwg4 / mii_rxclk ?port g i/o pin 4 pg4 is a general-purpose i/o pin. when the emac mii external interface is enabled, it becomes the receive clock (mii_rxclk) signal. it can be con?ured to generate an interrupt (kwg4) causing the mcu to exit stop or wait mode. while in reset and immediately out of reset, the pg4 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the emac block description chapter for information about pin con?urations. 1.2.3.23 pg3 / kwg3 / mii_rxd3 ?port g i/o pin 3 pg3 is a general-purpose i/o pin. when the emac mii external interface is enabled, it becomes the receive data (mii_rxd3) signal. it can be con?ured to generate an interrupt (kwg3) causing the mcu to exit stop or wait mode. while in reset and immediately out of reset, the pg3 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the emac block description chapter for information about pin con?urations. 1.2.3.24 pg2 / kwg2 / mii_rxd2 ?port g i/o pin 2 pg2 is a general-purpose i/o pin. when the emac mii external interface is enabled, it becomes the receive data (mii_rxd2) signal. it can be con?ured to generate an interrupt (kwg2) causing the mcu to exit stop or wait mode. while in reset and immediately out of reset, the pg2 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the emac block description chapter for information about pin con?urations. 1.2.3.25 pg1 / kwg1 / mii_rxd1 ?port g i/o pin 1 pg1 is a general-purpose i/o pin. when the emac mii external interface is enabled, it becomes the receive data (mii_rxd1) signal. it can be con?ured to generate an interrupt (kwg1) causing the mcu to exit stop or wait mode. while in reset and immediately out of reset, the pg1 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the emac block description chapter for information about pin con?urations. 1.2.3.26 pg0 / kwg0 / mii_rxd0 ?port g i/o pin 0 pg0 is a general-purpose i/o pin. when the emac mii external interface is enabled, it becomes the receive data (mii_rxd0) signal. it can be con?ured to generate an interrupt (kwg0) causing the mcu to exit stop or wait mode. while in reset and immediately out of reset, the pg0 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the emac block description chapter for information about pin con?urations. 1.2.3.27 ph6 / kwh6 / mii_txer ?port h i/o pin 6 ph6 is a general-purpose i/o pin. when the emac mii external interface is enabled, it becomes the transmit error (mii_txer) signal. it can be con?ured to generate an interrupt (kwh6) causing the mcu to exit stop or wait mode. while in reset and immediately out of reset, the ph6 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the emac block description chapter for information about pin con?urations. chapter 1 mc9s12ne64 device overview mc9s12ne64 data sheet, rev 1.0 52 freescale semiconductor 1.2.3.28 ph5 / kwh5 / mii_txen ?port h i/o pin 5 ph5 is a general-purpose i/o pin. when the emac mii external interface is enabled, it becomes the transmit enabled (mii_txen) signal. it can be con?ured to generate an interrupt (kwh5) causing the mcu to exit stop or wait mode. while in reset and immediately out of reset, the ph5 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the emac block description chapter for information about pin con?urations. 1.2.3.29 ph4 / kwh4 / mii_txclk ?port h i/o pin 4 ph4 is a general-purpose i/o pin. when the emac mii external interface is enabled, it becomes the transmit clock (mii_txclk) signal. it can be con?ured to generate an interrupt (kwh4) causing the mcu to exit stop or wait mode. while in reset and immediately out of reset, the ph4 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the emac block description chapter for information about pin con?urations. 1.2.3.30 ph3 / kwh3 / mii_txd3 ?port h i/o pin 3 ph3 is a general-purpose i/o pin. when the emac mii external interface is enabled, it becomes the transmit data (mii_txd3) signal. it can be con?ured to generate an interrupt (kwh3) causing the mcu to exit stop or wait mode. while in reset and immediately out of reset, the ph3 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the emac block description chapter for information about pin con?urations. 1.2.3.31 ph2 / kwh2 / mii_txd2 ?port h i/o pin 2 ph2 is a general-purpose i/o pin. when the emac mii external interface is enabled, it becomes the transmit data (mii_txd2) signal. it can be con?ured to generate an interrupt (kwh2) causing the mcu to exit stop or wait mode. while in reset and immediately out of reset, the ph2 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the emac block description chapter for information about pin con?urations. 1.2.3.32 ph1 / kwh1 / mii_txd1 ?port h i/o pin 1 ph1 is a general-purpose i/o pin. when the emac mii external interface is enabled, it becomes the transmit data (mii_txd1) signal. it can be con?ured to generate an interrupt (kwh1) causing the mcu to exit stop or wait mode. while in reset and immediately out of reset, the ph1 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the emac block description chapter for information about pin con?urations. 1.2.3.33 ph0 / kwh0 / mii_txd0 ?port h i/o pin 0 ph0 is a general-purpose i/o pin. when the emac mii external interface is enabled, it becomes the transmit data (mii_txd0) signal. it can be con?ured to generate an interrupt (kwh0) causing the mcu to exit stop or wait mode. while in reset and immediately out of reset, the ph0 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the emac block description chapter for information about pin con?urations. signal description mc9s12ne64 data sheet, rev 1.0 freescale semiconductor 53 1.2.3.34 pj7 / kwj7 / iic_scl ?port j i/o pin 7 pj7 is a general-purpose i/o pin. when the iic module is enabled, it becomes the serial clock line (iic_scl) for the iic module (iic). it can be con?ured to generate an interrupt (kwj7) causing the mcu to exit stop or wait mode. while in reset and immediately out of reset, the pj7 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the iic block description chapter for information about pin con?urations. 1.2.3.35 pj6 / kwj6 / iic_sda ?port j i/o pin 6 pj6 is a general-purpose i/o pin. when the iic module is enabled, it becomes the serial data line (iic_sdl) for the iic module (iic). it can be con?ured to generate an interrupt (kwj6) causing the mcu to exit stop or wait mode. while in reset and immediately out of reset, the pj6 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the iic block description chapter for information about pin con?urations. 1.2.3.36 pj3 / kwj3 / mii_col ?port j i/o pin 3 pj3 is a general-purpose i/o pin. when the emac mii external interface is enabled, it becomes the collision (mii_col) signal. it can be con?ured to generate an interrupt (kwj3) causing the mcu to exit stop or wait mode. while in reset and immediately out of reset, the pj3 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the emac block description chapter for information about pin con?urations. 1.2.3.37 pj2 / kwj2 / mii_crs /?port j i/o pin 2 pj2 is a general-purpose i/o pin. when the emac mii external interface is enabled, it becomes the carrier sense (mii_crs) signal. it can be con?ured to generate an interrupt (kwj2) causing the mcu to exit stop or wait mode. while in reset and immediately out of reset, the pj2 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the emac block description chapter for information about pin con?urations. 1.2.3.38 pj1 / kwj1 / mii_mdio ?port j i/o pin 1 pj1 is a general-purpose i/o pin. when the emac mii external interface is enabled, it becomes the management data i/o (mii_mdio) signal. it can be con?ured to generate an interrupt (kwh1) causing the mcu to exit stop or wait mode. while in reset and immediately out of reset, the pj1 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the emac block description chapter for information about pin con?urations. 1.2.3.39 pj0 / kwj0 / mii_mdc ?port j i/o pin 0 pj0 is a general-purpose i/o pin. when the emac mii external interface is enabled, it becomes the management data clock (mii_mdc) signal. it can be con?ured to generate an interrupt (kwj0) causing the mcu to exit stop or wait mode. while in reset and immediately out of reset, the pj0 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the emac block description chapter for information about pin con?urations. chapter 1 mc9s12ne64 device overview mc9s12ne64 data sheet, rev 1.0 54 freescale semiconductor 1.2.3.40 pl6 ?port l i/o pin 6 pl6 is a general-purpose i/o pin. while in reset and immediately out of reset, the pl6 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter for information about pin con?urations. 1.2.3.41 pl5 ?port l i/o pin 5 pl5 is a general-purpose i/o pin. while in reset and immediately out of reset, the pl5 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter for information about pin con?urations. 1.2.3.42 pl4 / colled ?port l i/o pin 4 pl4 is a general-purpose i/o pin. when the internal ethernet physical transceiver (ephy) is enabled with the ephyctl0 leden bit set, it becomes the collision status signal (colled). while in reset and immediately out of reset the pl4 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the ephy block description chapter for information about pin con?urations. 1.2.3.43 pl3 / dupled ?port l i/o pin 3 pl3 is a general-purpose i/o pin. when the internal ethernet physical transceiver (ephy) is enabled with the ephyctl0 leden bit set, it becomes the duplex status signal (dupled). while in reset and immediately out of reset, the pl3 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the ephy block description chapter for information about pin con?urations. 1.2.3.44 pl2 / spdled ?port l i/o pin 2 pl2 is a general-purpose i/o pin. when the internal ethernet physical transceiver (ephy) is enabled with the ephyctl0 leden bit set, it becomes the speed status signal (spdled). while in reset and immediately out of reset, the pl2 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the ephy block description chapter for information about pin con?urations. 1.2.3.45 pl1 / lnkled ?port l i/o pin 1 pl1 is a general-purpose i/o pin. when the internal ethernet physical transceiver (ephy) is enabled with the ephyctl0 leden bit set, it becomes the link status signal (lnkled). while in reset and immediately out of reset, the pl1 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the ephy block description chapter for information about pin con?urations. signal description mc9s12ne64 data sheet, rev 1.0 freescale semiconductor 55 1.2.3.46 pl0 / actled ?port l i/o pin 0 pl0 is a general-purpose i/o pin. when the internal ethernet physical transceiver (ephy) is enabled with the ephyctl0 leden bit set, it becomes the active status signal (actled). while in reset and immediately out of reset, the pl0 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the ephy block description chapter for information about pin con?urations. 1.2.3.47 ps7 / spi_ ss ?port s i/o pin 7 ps7 is a general-purpose i/o. when the serial peripheral interface (spi) is enabled, ps7 becomes the slave select pin ss. while in reset and immediately out of reset, the ps7 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the spi block description chapter for information about pin con?urations. 1.2.3.48 ps6 / spi_sck ?port s i/o pin 6 ps6 is a general-purpose i/o pin. when the serial peripheral interface (spi) is enabled, ps6 becomes the serial clock pin, sck. while in reset and immediately out of reset, the ps6 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the spi block description chapter for information about pin con?urations. 1.2.3.49 ps5 / spi_mosi ?port s i/o pin 5 ps5 is a general-purpose i/o pin. when the serial peripheral interface (spi) is enabled, ps5 becomes the master output (during master mode) or slave input (during slave mode) pin. while in reset and immediately out of reset, the ps5 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the spi block description chapter for information about pin con?urations. 1.2.3.50 ps4 / spi_miso ?port s i/o pin 4 ps4 is a general-purpose i/o pin. when the serial peripheral interface (spi) is enabled, ps4 becomes the master input (during master mode) or slave output (during slave mode) pin. while in reset and immediately out of reset, the ps4 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the spi block description chapter for information about pin con?urations. 1.2.3.51 ps3 / sci1_txd ?port s i/o pin 3 ps3 is a general-purpose i/o. when the serial communications interface 1 (sci1) transmitter is enabled, ps3 becomes the transmit pin, txd, of sci1. while in reset and immediately out of reset, the ps3 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the sci block description chapter for information about pin con?urations. chapter 1 mc9s12ne64 device overview mc9s12ne64 data sheet, rev 1.0 56 freescale semiconductor 1.2.3.52 ps2 / sci1_rxd ?port s i/o pin 2 ps2 is a general-purpose i/o. when the serial communications interface 1 (sci1) receiver is enabled, ps2 becomes the receive pin rxd of sci1. while in reset and immediately out of reset, the ps2 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the sci block description chapter for information about pin con?urations. 1.2.3.53 ps1 / sci0_txd ?port s i/o pin 1 ps1 is a general-purpose i/o. when the serial communications interface 0 (sci0) transmitter is enabled, ps1 becomes the transmit pin, txd, of sci0. while in reset and immediately out of reset, the ps1 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the sci block description chapter for information about pin con?urations. 1.2.3.54 ps0 / sci0_rxd ?port s i/o pin 0 ps0 is a general-purpose i/o. when the serial communications interface 0 (sci0) receiver is enabled, ps0 becomes the receive pin rxd0 of sci0. while in reset and immediately out of reset, the ps0 pin is con?ured as a high-impedance input pin. see the port integration module (pim) pim_9ne64 block description chapter and the sci block description chapter for information about pin con?urations. 1.2.3.55 pt[7:4] / ioc1[7:4] ?port t i/o pins [7:4] pt[7:4] are general-purpose i/o pins. while the timer system 1 (tim1) is enabled, these pins can also be con?ured as the tim1 input capture or output compare pins ioc1[7-4]. while in reset and immediately out of reset, the pt[7:4] pins are con?ured as a high-impedance input pins. see the port integration module (pim) pim_9ne64 block description chapter and the tim_16b4c block description chapter for information about pin con?urations. 1.2.3.56 phy_txp ?ephy twisted pair output + ethernet twisted pair output pin. this pin is hi-z out of reset. 1.2.3.57 phy_txn ?ephy twisted pair output ethernet twisted pair output pin. this pin is hi-z out of reset. 1.2.3.58 phy_rxp ?ephy twisted pair input + ethernet twisted pair input pin. this pin is hi-z out of reset. 1.2.3.59 phy_rxn ?ephy twisted pair input ethernet twisted pair input pin. this pin is hi-z out of reset. signal description mc9s12ne64 data sheet, rev 1.0 freescale semiconductor 57 1.2.3.60 phy_rbias ?ephy bias control resistor connect a 1.0% external resistor, rbias, between phy_rbias pin and phy_vssa. this resistor must be placed as near as possible to the chip pin. stray capacitance must be kept to less than 10 pf (> 50 pf may cause instability). no high-speed signals are allowed in the region of rbias. 1.2.4 power supply pins 1.2.4.1 v ddx1 , v ddx2 , v ssx1 , v ssx2 ?power & ground pins for i/o & internal voltage regulator external power and ground for i/o drivers. bypass requirements depend on how heavily the mcu pins are loaded. 1.2.4.2 v ddr /v regen ?power pin for internal voltage regulator external power for internal voltage regulator. 1.2.4.3 v dd1 , v dd2 , v ss1 , v ss2 ?core power pins power is supplied to the mcu through vdd and vss. this 2.5v supply is derived from the internal voltage regulator. no static load is allowed on these pins. the internal voltage regulator is turned off, if vddr/vregen is tied to ground. 1.2.4.4 v dda , v ssa ?power supply pins for atd and vreg_phy vdda and vssa are the power supply and ground input pins for the voltage regulator and the analog-to-digital converter. 1.2.4.5 phy_vdda, phy_vssa ?power supply pins for ephy analog power is supplied to the ethernet physical transceiver (ephy) plls through phy_vdda and phy_vssa. this 2.5v supply is derived from the internal voltage regulator. no static load is allowed on these pins. the internal voltage regulator is turned off, if vddr/vregen is tied to ground. 1.2.4.6 phy_vddrx, phy_vssrx ?power supply pins for ephy receiver power is supplied to the ethernet physical transceiver (ephy) receiver through phy_vddrx and phy_vssrx. this 2.5v supply is derived from the internal voltage regulator. no static load is allowed on these pins. the internal voltage regulator is turned off, if vddr/vregen is tied to ground. 1.2.4.7 phy_vddtx, phy_vsstx ?power supply pins for ephy transmitter external power is supplied to the ethernet physical transceiver (ephy) transmitter through phy_vddtx and phy_vsstx. this 2.5 v supply is derived from the internal voltage regulator. no static load is allowed on these pins. the internal voltage regulator is turned off, if v ddr /v regen is tied to ground. chapter 1 mc9s12ne64 device overview mc9s12ne64 data sheet, rev 1.0 58 freescale semiconductor 1.2.4.8 v rh , v rl ?atd reference voltage input pins v rh and v rl are the reference voltage input pins for the analog-to-digital converter. 1.2.4.9 v ddpll , v sspll ?power supply pins for pll provides operating voltage and ground for the oscillator and the phase-locked loop. this allows the supply voltage to the oscillator and pll to be bypassed independently. this 2.5 v voltage is generated by the internal voltage regulator. the internal voltage regulator is turned off, if v ddr /v regen is tied to ground. note all v ss pins must be connected together in the application. because fast signal transitions place high, short-duration current demands on the power supply, use bypass capacitors with high-frequency characteristics and place them as near to the mcu as possible. bypass requirements depend on mcu pin load. table 1-5. mc9s12ne64 power and ground connection summary mnemonic nominal voltage description v ddr /v regen 3.3 v external power and ground, supply to internal voltage regulator. to disable voltage regulator attach v regen to v ssx . v ddx1 v ddx2 3.3 v external power and ground, supply to pin drivers. v ssx1 v ssx2 0 v v dda 3.3 v operating voltage and ground for the analog-to-digital converter, the reference for the internal voltage regulator and the digital-to-analog converters, allows the supply voltage to the a/d to be bypassed independently. v ssa 0 v v rh 3.3 v reference voltage high for the analog-to-digital converter. v rl 0 v reference voltage low for the analog-to-digital converter. phy_vddtx phy_vddrx phy_vdda 2.5 v internal power and ground generated by internal regulator for internal ethernet physical transceiver (ephy). these also allow an external source to supply the ephy voltages and bypass the internal voltage regulator. phy_vsstx phy_vssrx phy_vssa 0v v dd1 v dd2 2.5 v internal power and ground generated by internal regulator. these also allow an external source to supply the core v dd /v ss voltages and bypass the internal voltage regulator. v ss1 v ss2 0 v v ddpll 2.5 v provide operating voltage and ground for the phase-locked loop. this allows the supply voltage to the pll to be bypassed independently. internal power and ground generated by internal regulator. v sspll 0 v system clock description mc9s12ne64 data sheet, rev 1.0 freescale semiconductor 59 1.3 system clock description the clock and reset generator provides the internal clock signals for the core and all peripheral modules. figure 1-5 shows the clock connections from the crg to all modules. see the crg block description chapter for details on clock generation. figure 1-5. clock connections 1.4 modes of operation there are eight possible modes of operation available on the mc9s12ne64. each mode has an associated default memory map and external bus con?uration. 1.4.1 chip con?uration summary the operating mode out of reset is determined by the states of the modc, modb, and moda pins during reset. the modc, modb, and moda bits in the mode register show the current operating mode and provide limited mode switching during operation. the states of the modc, modb, and moda pins are latched into these bits on the rising edge of the reset signal. the romctl signal allows the setting of the romon bit in the misc register thus controlling whether the internal flash is visible in the memory map. romon = 1 means the flash is visible in the memory map. the state of the romctl pin is latched into the romon bit in the misc register on the rising edge of the reset signal. crg bus clock core clock extal xtal oscillator clock s12_core ephy ram sci atd flash tim vreg_phy spi pim emac iic chapter 1 mc9s12ne64 device overview mc9s12ne64 data sheet, rev 1.0 60 freescale semiconductor for further explanation on the modes, see the mebi block description chapter. 1.4.2 security the mc9s12ne64 provides a security feature that prevents the unauthorized read and write of the memory contents 1 . this feature allows: protection of the contents of flash operation in single-chip mode operation from external memory with internal flash disabled on-chip security can be compromised by user code. an extreme example would be user code that dumps the contents of the internal program. this code would defeat the purpose of security. at the same time the user may also wish to put a back door in the user program. an example of this would be the user downloading a key through the sci, which would allow access to a programming routine that could update parameters. 1.4.2.1 securing the microcontroller after the user has programmed the flash, the mcu can be secured by programming the security bits located in the flash module. these nonvolatile bits will keep the mcu secured through resetting the mcu and through powering down the mcu. the security byte resides in a portion of the flash array. see the flash block description chapter for more details on the security con?uration. table 1-6. mode selection bkgd = modc pe6 = modb pe5 = moda pp6 = romctl romon bit mode description 000x1 special single chip, bdm allowed and active. bdm is allowed in all other modes but a serial command is required to make bdm active. 001 01 emulation expanded narrow, bdm allowed. 10 0 1 0 x 0 special test (expanded wide), bdm allowed. 011 01 emulation expanded wide, bdm allowed. 10 1 0 0 x 1 normal single chip, bdm allowed. 101 00 normal expanded narrow, bdm allowed. 11 110x1 peripheral; bdm allowed but bus operations would cause bus con?cts (must not be used). 111 00 normal expanded wide, bdm allowed. 11 1.no security feature is absolutely secure. however, freescale semiconductor? strategy is to make reading or copying the flash difficult for unauthorized users. low-power modes mc9s12ne64 data sheet, rev 1.0 freescale semiconductor 61 1.4.2.2 operation of the secured microcontroller 1.4.2.2.1 normal single chip mode this will be the most common usage of the secured mcu. everything will appear the same as if the mcu were not secured, with the exception of bdm operation. the bdm operation will be blocked. 1.4.2.2.2 executing from external memory the user may wish to execute from external memory with a secured microcontroller. this is accomplished by resetting directly into expanded mode. the internal flash will be disabled. bdm operations will be blocked. 1.4.2.3 unsecuring the microcontroller in order to unsecure the microcontroller, the internal flash must be erased. this can be performed through an external program in expanded mode. after the user has erased the flash, the mcu can be reset into special single chip mode. this invokes a program that veri?s the erasure of the internal flash. after this program completes, the user can erase and program the flash security bits to the unsecured state. this is generally performed through the bdm, but the user could also change to expanded mode (by writing the mode bits through the bdm) and jumping to an external program (again through bdm commands). note that if the mcu goes through a reset before the security bits are reprogrammed to the unsecure state, the mcu will be secured again. 1.5 low-power modes the microcontroller features three main low-power modes. see the respective block description chapter for information on the module behavior in stop, pseudo stop, and wait mode. an important source of information about the clock system is the clock and reset generator (crg) block description chapter. 1.5.1 stop executing the cpu stop instruction stops all clocks and the oscillator thus putting the chip in fully static mode. wakeup from this mode can be performed via reset or external interrupts. 1.5.2 pseudo stop this mode is entered by executing the cpu stop instruction. in this mode, the oscillator stays running and the real-time interrupt (rti) or watchdog (cop) sub module can stay active. other peripherals are turned off. this mode consumes more current than the full stop mode, but the wakeup time from this mode is signi?antly shorter. chapter 1 mc9s12ne64 device overview mc9s12ne64 data sheet, rev 1.0 62 freescale semiconductor 1.5.3 wait this mode is entered by executing the cpu wai instruction. in this mode, the cpu will not execute instructions. the internal cpu signals (address and databus) will be fully static. all peripherals stay active. for further power consumption, the peripherals can individually turn off their local clocks. 1.5.4 run although this is not a low-power mode, unused peripheral modules must not be enabled in order to save power. 1.6 resets and interrupts see the exception processing section of the cpu12 reference manual for information on resets and interrupts. system resets can be generated through external control of the reset pin, through the clock and reset generator module (crg), or through the low-voltage reset (lvr) generator of the voltage regulator module. see the crg and vreg_phy block description sections for detailed information on reset generation. 1.6.1 vectors table 1-7 lists interrupt sources and vectors in default order of priority. table 1-7. interrupt vector locations vector no. vector address vector name interrupt source ccr mask local enable hprio value to elevate 0 $fffe, $ffff vreset external reset, power on reset or low voltage reset (see crg ?gs register to determine reset source) none none 1 $fffc, $fffd vclkmon clock monitor fail reset none copctl (cme, fcme) 2 $fffa, $fffb vcop cop failure reset none cop rate select 3 $fff8, $fff9 vtrap unimplemented instruction trap none none 4 $fff6, $fff7 vswi swi none none 5 $fff4, $fff5 vxirq xirq x-bit none 6 $fff2, $fff3 virq irq i-bit intcr (irqen) $f2 7 $fff0, $fff1 vrti real-time interrupt i-bit crgint (rtie) $f0 8 through 11 $ffe8 to $ffef reserved 12 $ffe6, $ffe7 vtimch4 standard timer channel 4 i-bit t0ie (t0c4i) $e6 13 $ffe4, $ffe5 vtimch5 standard timer channel 5 i-bit t0ie (t0c5i) $e4 14 $ffe2, $ffe3 vtimch6 standard timer channel 6 i-bit t0ie (t0c6i) $e2 15 $ffe0, $ffe1 vtimch7 standard timer channel 7 i-bit t0ie (t0c7i) $e0 resets and interrupts mc9s12ne64 data sheet, rev 1.0 freescale semiconductor 63 16 $ffde, $ffdf vtimovf standard timer over?w i-bit t0msk2 (t0oi) $de 17 $ffdc, $ffdd vtimpaovf pulse accumulator over?w i-bit pactl0 (paovi0) $dc 18 $ffda, $ffdb vtimpaie pulse accumulator input edge i-bit pactl0 (pai0) $da 19 $ffd8, $ffd9 vspi spi i-bit spcr1 (spie, sptie) $d8 20 $ffd6, $ffd7 vsci0 sci0 i-bit sc0cr2 (tie, tcie, rie, ilie) $d6 21 $ffd4, $ffd5 vsci1 sci1 i-bit sc1cr2 (tie, tcie, rie, ilie) $d4 22 $ffd2, $ffd3 vatd atd i-bit atdctl2 (ascie) $d2 23 $ffd0, $ffd1 reserved 24 $ffce, $ffcf vportj port j i-bit ptjif (ptjie) $ce 25 $ffcc, $ffcd vporth port h i-bit pthif (pthie) $cc 26 $ffca, $ffcb vportg port g i-bit ptgif (ptgie) $ca 27 $ffc8, $ffc9 reserved 28 $ffc6, $ffc7 vcrgplllck crg pll lock i-bit pllcr (lockie) $c6 29 $ffc4, $ffc5 vcrgscm crg self clock mode i-bit pllcr (scmie) $c4 30 $ffc2, $ffc3 reserved 31 $ffc0, $ffc1 viic iic bus i-bit ibcr (ibie) $c0 32 through 34 $ffba to $ffbf reserved 35 $ffb8, $ffb9 v?sh flash i-bit fcnfg (ccie, cbeie) $b8 36 $ffb6, $ffb7 vephy ephy interrupt i-bit ephyctl0 (ephyie) $b6 37 $ffb4, $ffb5 vemacrxbac emac receive buffer a complete i-bit imask (rxacie) $b4 38 $ffb2, $ffb3 vemacrxbbc emac receive buffer b complete i-bit imask (rxbcie) $b2 39 $ffb0, $ffb1 vemactxc emac frame transmission complete i-bit imask (txcie) $b0 40 $ffae, $ffaf vemacrxfc emac receive ?w control i-bit imask (rfcie) $ae 41 $ffac, $ffad vemacmii emac mii management transfer complete i-bit imask (mmcie) $ac 42 $ffaa, $ffab vemacrxerr emac receive error i-bit imask (rxaie) $aa 43 $ffa8, $ffa9 vemacrxbao emac receive buffer a overrun i-bit imask (rxaoie) $a8 44 $ffa6, $ffa7 vemacrxbbo emac receive buffer b overrun i-bit imask (rxboie) $a6 45 $ffa4, $ffa5 vemacbrxerr emac babbling receive error i-bit imask (breie) $a4 46 $ffa2, $ffa3 vemaclc emac late collision i-bit imask (lcie) $a2 47 $ffa0, $ffa1 vemacec emac excessive collision i-bit imask (ecie) $a0 48 through 63 $ff80 to $ff9f reserved table 1-7. interrupt vector locations (continued) vector no. vector address vector name interrupt source ccr mask local enable hprio value to elevate chapter 1 mc9s12ne64 device overview mc9s12ne64 data sheet, rev 1.0 64 freescale semiconductor 1.6.2 resets resets are a subset of the interrupts featured in table 1-7 . the different sources capable of generating a system reset are summarized in table 1-8 . 1.6.2.1 reset summary table 1.6.2.2 effects of reset when a reset occurs, mcu registers and control bits are changed to known start-up states. see the respective module block description chapter for register reset states. see the mebi block description chapter for mode-dependent pin con?uration of port a, b, e, and k out of reset. see the pim block description chapter for reset con?urations of all peripheral module ports. see table 1-1 for locations of the memories depending on the operating mode after reset. the ram array is not automatically initialized out of reset. 1.7 block con?uration for mc9s12ne64 this section contains information regarding how the modules are implemented on the mc9s12ne64 device. 1.7.1 v ddr /v regen on the mc9s12ne64, the v ddr /v regen pin is used to enable or disable the internal voltage 3.3v to 2.5v regulator. if this pin is tied low, then v dd1 , v dd2 , v ddpll , phy_vddrx, phy_vddtx, and phy_vdda must be supplied externally. 1.7.2 v dd1 , v dd2 , v ss1 , v ss2 in both the 112-pin lqfp and the 80-pin tqfp-ep package versions, both internal v dd and v ss of the 2.5 v domain are bonded out on two sides of the device as two pin pairs (v dd1 /v ss1 and v dd2 /v ss2 ). v dd1 and v dd2 are connected together internally. v ss1 and v ss2 are connected together internally. this allows systems to employ better supply routing and further decoupling. table 1-8. reset summary reset priority source vector power-on reset 1 crg module $fffe, $ffff external reset 1 reset pin $fffe, $ffff low-voltage reset 1 vreg_phy module $fffe, $ffff clock monitor reset 2 crg module $fffc, $fffd cop watchdog reset 3 crg module $fffa, $fffb block con?uration for mc9s12ne64 mc9s12ne64 data sheet, rev 1.0 freescale semiconductor 65 1.7.3 clock reset generator (crg) see the crg chapter for information about the clock and reset generator module. for the mc9s12ne64, only the pierce circuitry is available for the oscillator. the low-voltage reset feature uses the low-voltage reset signal from the vreg_phy module as an input to the crg module. when the regulator output voltage supply to the internal chip logic falls below a speci?d threshold, the lvr signal from the vreg_phy module causes the crg module to generate a reset. see the vreg_phy block description chapter for voltage level speci?ations. 1.7.4 oscillator (osc) see the osc chapter for information about the oscillator module. the xclks input signal is not available on the mc9s12ne64. the signal is internally tied low to select the pierce oscillator or external clock con?uration. 1.7.5 ethernet media access controller (emac) see the emac chapter for information about the ethernet media access controller module. the emac is part of the ipbus domain. 1.7.5.1 emac mii external pin con?uration when the emac is con?ured for and external ethernet physical transceiver internal pull-ups and pull-downs are not automatically con?ured on the mii inputs. any internal pull-up or pull-down resistors, which may be required, must be con?ured by setting the appropriate pull control registers in the port integration module (pim). this implementation allows the use of external pull-up and pull-down resistors. 1.7.5.2 emac internal phy con?uration when the extphy bit (in the emac netctl register) is set to 1, the emac is con?ured to work with the internal ephy block. please see 1.7.6, ?thernet physical transceiver (ephy) , for more information regarding the ephy block. 1.7.5.3 low-power operation special care must be taken when executing stop and wait instructions while using the emac, or undesired operation may result. 1.7.5.3.1 wait transmit and receive operations are not possible in wait mode if the cwai bit is set in the clksel register because the clocks to the transmit and receive buffers are stopped. it is recommended that the emac eswai bit be set if wait mode is entered with the cwai set. chapter 1 mc9s12ne64 device overview mc9s12ne64 data sheet, rev 1.0 66 freescale semiconductor 1.7.5.3.2 stop during system low-power stop mode, the emac is immediately disabled. any receive in progress is dropped and any pause time-out is cleared. the user must not to enter low-power stop mode when txact or busy are set. 1.7.6 ethernet physical transceiver (ephy) see the ephy chapter for information about the ethernet physical transceiver module. the ephy also has mii register space which is not part of the mcu address space and not accessible via the ip bus. the mii registers can be accessed using the mdio functions of the emac when the emac is con?ured for internal phy operation. the mii pins of the ephy are not externally accessible. all communication and management of the ephy must be performed using the emac. the organization unique identi?r (oui) for the mc9s12ne64 is 00-60-11 (hex). 1.7.6.1 low-power operation special care must be taken when executing stop and wait instructions while using the ephy or undesired operation may result. 1.7.6.1.1 wait transmit and receive operations are not possible in wait mode if the cwai bit is set in the clksel register because the clocks to the internal mii interface are stopped. 1.7.6.1.2 stop during system low-power stop mode, the ephy is immediately reset and powered down. upon exiting stop mode, the a start-up delay is required prior to initiating mdio communications with the ephy. see a.14, ?phy electrical characteristics ?for details. it is not possible to use an ephy interrupt to wake the system from stop mode. 1.7.7 ram 8k block description this module supports single-cycle misaligned word accesses without wait states. in addition to operating as the cpu storage, the 8k system ram also functions as the ethernet buffer while the emac module is enabled. while the emac is enabled, the ethernet buffer will occupy 0.375k to 4.5k of ram with physical addresses starting at $0000 and ending at $017f up to $11ff, depending on the setting of the bufmap bits in the emac ethernet buffer con?uration register (bufcfg). the relative ram address, which are controlled by settings in the internal ram position register (intrm), must be tracked in software. the ethernet buffer operation of the ram is independent of the cpu and allows same cycle read/write access from the cpu and the emac. no hardware blocking mechanism is implemented to prevent the cpu from accessing the ethernet ram space, so care must be taken to ensure that the cpu does not corrupt the ram ethernet contents. mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 67 chapter 2 64 kbyte flash module (s12fts64kv3) 2.1 introduction this document describes the fts64k module that includes a 64kbyte flash (nonvolatile) memory. the flash memory may be read as either 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. the flash memory is ideal for program and data storage for single-supply applications allowing for ?ld reprogramming without requiring external voltage sources for program or erase. program and erase functions are controlled by a command driven interface. the flash module supports both block erase and sector erase. an erased bit reads 1 and a programmed bit reads 0. the high voltage required to program and erase the flash memory is generated internally. it is not possible to read from a flash block while it is being erased or programmed. caution a flash word must be in the erased state before being programmed. cumulative programming of bits within a flash word is not allowed. 2.1.1 glossary command write sequence ?a three-step mcu instruction sequence to execute built-in algorithms (including program and erase) on the flash memory. 2.1.2 features 64 kbytes of flash memory comprised of one 64 kbyte block divided into 128 sectors of 512 bytes automated program and erase algorithm interrupts on flash command completion, command buffer empty fast sector erase and word program operation 2-stage command pipeline for faster multi-word program times sector erase abort feature for critical interrupt response flexible protection scheme to prevent accidental program or erase single power supply for all flash operations including program and erase security feature to prevent unauthorized access to the flash memory code integrity check using built-in data compression 2.1.3 modes of operation program, erase, erase verify, and data compress operations (please refer to section 2.4.1 for details). chapter 2 64 kbyte flash module (s12fts64kv3) mc9s12ne64 data sheet, rev. 1.1 68 freescale semiconductor 2.1.4 block diagram a block diagram of the flash module is shown in figure 2-1 . figure 2-1. fts64k block diagram 2.2 external signal description the flash module contains no signals that connect off-chip. 2.3 memory map and register de?ition this subsection describes the memory map and registers for the flash module. 2.3.1 module memory map the flash memory map is shown in figure 2-2 . the hcs12 architecture places the flash memory addresses between 0x4000 and 0xffff which corresponds to three 16-kbyte pages. the content of the fts64k flash block 32k * 16 bits oscillator clock divider clock command interface command pipeline comm2 command interrupt request fclk addr2 data2 comm1 addr1 data1 protection security sector 0 sector 1 sector 127 memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 69 hcs12 core ppage register is used to map the logical middle page ranging from address 0x8000 to 0xbfff to any physical 16 kbyte page in the flash memory. by placing 0x3e or 0x3f in the hcs12 core ppage register, the associated 16 kbyte pages appear twice in the mcu memory map. the fprot register, described in section 2.3.2.5, ?lash protection register (fprot) , can be set to globally protect a flash block. however, three separate memory regions, one growing upward from the ?st address in the next-to-last page in the flash block (called the lower region), one growing downward from the last address in the last page in the flash block (called the higher region), and the remaining addresses in the flash block, can be activated for protection. the flash locations of these protectable regions are shown in table 2-2 . the higher address region is mainly targeted to hold the boot loader code because it covers the vector space. the lower address region can be used for eeprom emulation in an mcu without an eeprom module because it can remain unprotected while the remaining addresses are protected from program or erase. security information that allows the mcu to restrict access to the flash module is stored in the flash con?uration ?ld, described in table 2-1 . table 2-1. flash con?uration field unpaged flash address paged flash address (ppage 0x3f) size (bytes) description 0xff00 - 0xff07 0xbf00-0xbf07 8 backdoor comparison key refer to section section 2.6.1, ?nsecuring the mcu using backdoor key access 0xff08 - 0xff0c 0xbf08-0xbf0c 5 reserved 0xff0d 0xbf0d 1 flash protection byte refer to section 2.3.2.5, ?lash protection register (fprot) 0xff0e 0xbf0e 1 flash nonvolatile byte refer to section 2.3.2.9, ?lash control register (fctl) 0xff0f 0xbf0f 1 flash security byte refer to section 2.3.2.2, ?lash security register (fsec) chapter 2 64 kbyte flash module (s12fts64kv3) mc9s12ne64 data sheet, rev. 1.1 70 freescale semiconductor figure 2-2. flash memory map 0xff00 - 0xff0f, flash con?uration field 0x8000 flash protected low sectors 0.5, 1, 2, 4 kbytes flash_start = 0x4000 0x4800 0x4200 0x4400 0x5000 16k paged memory 0x3c 0x3d 0x3e 0x3f 0x3e note: 0x3c-0x3f correspond to the ppage register content flash_end = 0xffff 0xf800 0xf000 0xc000 0xe000 flash protected high sectors 2, 4, 8, 16 kbytes 0x3f flash registers module base + 0x0000 module base + 0x000f (16 bytes) flash block memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 71 the flash module also contains a set of 16 control and status registers located in address space module base + 0x0000 to module base + 0x000f. a summary of these registers is given in table 2-3 while their accessibility in normal and special modes is detailed in section 2.3.2, ?egister descriptions . table 2-2. detailed flash memory map summary mcu address range ppage protectable lower range protectable higher range block relative address 1 1 block relative address for 64 kbyte flash block consists of 16 address bits. 0x4000-0x7fff unpaged (0x3e) 0x4000-0x41ff n.a. 0x8000-0xbfff 0x4000-0x43ff 0x4000-0x47ff 0x4000-0x4fff 0x8000-0xbfff 0x3c n.a. n.a. 0x0000-0x3fff 0x3d n.a. n.a. 0x4000-0x7fff 0x3e 0x8000-0x81ff n.a. 0x8000-0xbfff 0x8000-0x83ff 0x8000-0x87ff 0x8000-0x8fff 0x3f n.a. 0xb800-0xbfff 0xc000-0xffff 0xb000-0xbfff 0xa000-0xbfff 0x8000-0xbfff 0xc000-0xffff unpaged (0x3f) n.a. 0xf800-0xffff 0xc000-0xffff 0xf000-0xffff 0xe000-0xffff 0xc000-0xffff table 2-3. flash register map module base + register name normal mode access 0x0000 flash clock divider register (fclkdiv) r/w 0x0001 flash security register (fsec) r 0x0002 reserved1 1 r 0x0003 flash con?uration register (fcnfg) r/w 0x0004 flash protection register (fprot) r/w 0x0005 flash status register (fstat) r/w 0x0006 flash command register (fcmd) r/w 0x0007 flash control register (fctl) r 0x0008 flash high address register (faddrhi) 1 r 0x0009 flash low address register (faddrlo) 1 r chapter 2 64 kbyte flash module (s12fts64kv3) mc9s12ne64 data sheet, rev. 1.1 72 freescale semiconductor 0x000a flash high data register (fdatahi) r 0x000b flash low data register (fdatalo) r 0x000c reserved2 1 r 0x000d reserved3 1 r 0x000e reserved4 1 r 0x000f reserved5 1 r 1 intended for factory test purposes only. table 2-3. flash register map memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 73 2.3.2 register descriptions register name bit 7 654321 bit 0 fclkdiv r fdivld prdiv8 fdiv5 fdiv4 fdiv3 fdiv2 fdiv1 fdiv0 w fsec r keyen rnv5 rnv4 rnv3 rnv2 sec w ftstmod r 00000000 w fcnfg r cbeie ccie keyacc 00000 w fprot r fpopen rnv6 fphdis fphs fpldis fpls w fstat r cbeif ccif pviol accerr 0 blank 0 0 w fcmd r 0 cmdb w fctl r nv7 nv6 nv5 nv4 nv3 nv2 nv1 nv0 w faddrhi r 0 faddrhi w faddrlo r faddrlo w fdatahi r fdatahi w fdatalo r fdatalo w reserved1 r 00000000 w = unimplemented or reserved figure 2-3. fts64k register summary chapter 2 64 kbyte flash module (s12fts64kv3) mc9s12ne64 data sheet, rev. 1.1 74 freescale semiconductor 2.3.2.1 flash clock divider register (fclkdiv) the fclkdiv register is used to control timed events in program and erase algorithms. all bits in the fclkdiv register are readable, bits 6-0 are write once and bit 7 is not writable. 2.3.2.2 flash security register (fsec) the fsec register holds all bits associated with the security of the mcu and flash module. reserved2 r 00000000 w reserved3 r 00000000 w reserved4 r 00000000 w 76543210 r fdivld prdiv8 fdiv5 fdiv4 fdiv3 fdiv2 fdiv1 fdiv0 w reset 00000000 = unimplemented or reserved figure 2-4. flash clock divider register (fclkdiv) table 2-4. fclkdiv field descriptions field description 7 fdivld clock divider loaded. 0 register has not been written. 1 register has been written to since the last reset. 6 prdiv8 enable prescalar by 8 . 0 the oscillator clock is directly fed into the clock divider . 1 the oscillator clock is divided by 8 before feeding into the clock divider. 5-0 fdiv[5:0] clock divider bits ?the combination of prdiv8 and fdiv[5:0] must divide the oscillator clock down to a frequency of 150 khz?00 khz. the maximum divide ratio is 512. please refer to section 2.4.1.1, ?riting the fclkdiv register for more information. register name bit 7 654321 bit 0 = unimplemented or reserved figure 2-3. fts64k register summary (continued) memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 75 all bits in the fsec register are readable but are not writable. the fsec register is loaded from the flash configuration field at address $ff0f during the reset sequence, indicated by f in figure 2-5 . the security function in the flash module is described in section 2.6, ?lash module security . 76543210 r keyen rnv5 rnv4 rnv3 rnv2 sec w reset f f ffffff = unimplemented or reserved figure 2-5. flash security register (fsec) table 2-5. fsec field descriptions field description 1-0 keyen[1:0] backdoor key security enable bits ?he keyen[1:0] bits de?e the enabling of backdoor key access to the flash module as shown in table 2-6 . 5-2 rnv[5:2] reserved nonvolatile bits ?the rnv[5:2] bits must remain in the erased 1 state for future enhancements. 1-0 sec[1:0] flash security bits the sec[1:0] bits de?e the security state of the mcu as shown in table 2-7 . if the flash module is unsecured using backdoor key access, the sec bits are forced to 10. table 2-6. flash keyen states keyen[1:0] status of backdoor key access 00 disabled 01 1 1 preferred keyen state to disable backdoor key access. disabled 10 enabled 11 disabled table 2-7. flash security states sec[1:0] status of security 00 secured 01 1 1 preferred sec state to set mcu to secured state. secured 10 unsecured 11 secured chapter 2 64 kbyte flash module (s12fts64kv3) mc9s12ne64 data sheet, rev. 1.1 76 freescale semiconductor 2.3.2.3 reserved1 this register is reserved for factory testing and is not accessible. all bits read 0 and are not writable in normal mode. 2.3.2.4 flash con?uration register (fcnfg) the fcnfg register enables the flash interrupts and gates the security backdoor writes. cbeie, ccie and keyacc bits are readable and writable while all remaining bits read 0 and are not writable. keyacc is only writable if keyen (see section 2.3.2.2 ) is set to the enabled state. 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 2-6. reserved1 76543210 r cbeie ccie keyacc 0000 bksel w reset 00000000 = unimplemented or reserved figure 2-7. flash con?uration register (fcnfg) table 2-8. fcnfg field descriptions field description 7 cbeie command buffer empty interrupt enable the cbeie bit enables an interrupt in case of an empty command buffer in the flash module. 0 command buffer empty interrupt disabled. 1 an interrupt will be requested whenever the cbeif ?g (see section 2.3.2.7, ?lash status register (fstat)? is set. memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 77 2.3.2.5 flash protection register (fprot) the fprot register defines which flash sectors are protected against program or erase operations. all bits in the fprot register are readable and writable with restrictions except for rnv[6] which is only readable (see section 2.3.2.6, ?lash protection restrictions ). during reset, the fprot register is loaded from the flash con?uration field at address 0xff0d. to change the flash protection that will be loaded during the reset sequence, the upper sector of the flash memory must be unprotected, then the flash protect/security byte located as described in table 2-1 must be reprogrammed. trying to alter data in any of the protected areas in the flash block will result in a protection violation error and the pviol flag will be set in the fstat register. a mass erase of the flash block is not possible if any of the contained flash sectors are protected. 6 ccie command complete interrupt enable the ccie bit enables an interrupt in case all commands have been completed in the flash module. 0 command complete interrupt disabled. 1 an interrupt will be requested whenever the ccif ?g (see section 2.3.2.7, ?lash status register (fstat) ) is set. 5 keyacc enable security key writing 0 flash writes are interpreted as the start of a command write sequence. 1 writes to flash array are interpreted as keys to open the backdoor. reads of the flash array return invalid data. table 2-9. fprot field descriptions field description 7 fpopen protection function bit the fpopen bit determines the protection function for program or erase as shown in table 2-10 . 0 fphdis and fpldis bits de?e unprotected address ranges as speci?d by the corresponding fphs[1:0] and fpls[1:0] bits. for an mcu without an eeprom module, the fpopen clear state allows the main part of the flash block to be protected while a small address range can remain unprotected for eeprom emulation. 1 fphdis and fpldis bits enable protection for the address range speci?d by the corresponding fphs[1:0] and fpls[1:0] bits. 6 rnv[6] reserved nonvolatile bit ?the rnv[6] bit must remain in the erased state 1 for future enhancements. 5 fphdis flash protection higher address range disable ?the fphdis bit determines whether there is a protected/unprotected area in the higher address space of the flash block. 0 protection/unprotection enabled 1 protection/unprotection disabled 4:3 fphs[1:0] flash protection higher address size the fphs[1:0] bits determine the size of the protected/unprotected area as shown in table 2-11 . the fphs[1:0] bits can only be written to while the fphdis bit is set. table 2-8. fcnfg field descriptions (continued) field description chapter 2 64 kbyte flash module (s12fts64kv3) mc9s12ne64 data sheet, rev. 1.1 78 freescale semiconductor 2 fpldis flash protection lower address range disable ?the fpldis bit determines whether there is a protected/unprotected area in the lower address space of the flash block. 0 protection/unprotection enabled 1 protection/unprotection disabled 1:0 fpls[1:0] flash protection lower address size the fpls[1:0] bits determine the size of the protected/unprotected area as shown in table 2-12 . the fpls[1:0] bits can only be written to while the fpldis bit is set. table 2-10. flash protection function fpopen fphdis fpldis function 1 1 for range sizes, refer to and . 1 1 1 no protection 1 1 0 protected low range 1 0 1 protected high range 1 0 0 protected high and low ranges 0 1 1 full block protected 0 1 0 unprotected low range 0 0 1 unprotected high range 0 0 0 unprotected high and low ranges table 2-11. flash protection higher address range fphs[1:0] unpaged address range paged address range protected size 00 0xf800-0xffff 0x3f: 0xc800-0xcfff 2 kbytes 01 0xf000-0xffff 0x3f: 0xc000-0xcfff 4 kbytes 10 0xe000-0xffff 0x3f: 0xb000-0xcfff 8 kbytes 11 0xc000-0xffff 0x3f: 0x8000-0xcfff 16 kbytes table 2-12. flash protection lower address range fpls[1:0] unpaged address range paged address range protected size 00 0x4000-0x41ff 0x3e: 0x8000-0x81ff 512 bytes 01 0x4000-0x43ff 0x3e: 0x8000-0x83ff 1 kbyte 10 0x4000-0x47ff 0x3e: 0x8000-0x87ff 2 kbytes 11 0x4000-0x4fff 0x3e: 0x8000-0x8fff 4 kbytes table 2-9. fprot field descriptions field description memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 79 all possible flash protection scenarios are illustrated in figure 2-8 . although the protection scheme is loaded from the flash array after reset, it can be changed by the user. this protection scheme can be used by applications requiring re-programming in single-chip mode while providing as much protection as possible if re-programming is not required. chapter 2 64 kbyte flash module (s12fts64kv3) mc9s12ne64 data sheet, rev. 1.1 80 freescale semiconductor figure 2-8. flash protection scenarios 7 6 5 4 fphs[1:0] fpls[1:0] 3 2 1 0 fphs[1:0] fpls[1:0] fphdis=1 fpldis=1 fphdis=1 fpldis=0 fphdis=0 fpldis=1 fphdis=0 fpldis=0 scenario scenario unprotected region protected region with size protected region protected region with size defined by fpls defined by fphs not defined by fpls, fphs fpopen=1 fpopen=0 ppage 0x3c-0x3d ppage 0x3e-0x3f ppage 0x3c-0x3d ppage 0x3e-0x3f memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 81 2.3.2.6 flash protection restrictions the general guideline is that flash protection can only be added and not removed. table 2-13 speci?s all valid transitions between flash protection scenarios. any attempt to write an invalid scenario to the fprot register will be ignored and the fprot register will remain unchanged. the contents of the fprot register re?ct the active protection scenario. see the fphs and fpls descriptions for additional restrictions. 2.3.2.7 flash status register (fstat) the fstat register defines the operational status of the module. table 2-13. flash protection scenario transitions from protection scenario to protection scenario 1 1 allowed transitions marked with x. 01234567 0 xxxx 1xx 2xx 3x 4xx 5 xxxx 6xxxx 7 xxxxxxxx 76543210 r cbeif ccif pviol accerr 0 blank 0 0 w reset 11000000 = unimplemented or reserved figure 2-9. flash status register (fstat - normal mode) 76543210 r cbeif ccif pviol accerr 0 blank fail 0 w reset 11000000 = unimplemented or reserved figure 2-10. flash status register (fstat - special mode) chapter 2 64 kbyte flash module (s12fts64kv3) mc9s12ne64 data sheet, rev. 1.1 82 freescale semiconductor cbeif, pviol, and accerr are readable and writable, ccif and blank are readable and not writable, remaining bits read 0and are not writable in normal mode. fail is readable and writable in special mode. fail must be clear when starting a command write sequence. table 2-14. fstat field descriptions field description 7 cbeif command buffer empty interrupt flag ?the cbeif ?g indicates that the address, data and command buffers are empty so that a new command write sequence can be started. the cbeif ?g is cleared by writing a 1 to cbeif. writing a 0 to the cbeif ?g has no effect on cbeif. writing a 0 to cbeif after writing an aligned word to the flash address space but before cbeif is cleared will abort a command write sequence and cause the accerr ?g to be set. writing a 0 to cbeif outside of a command write sequence will not set the accerr ?g. the cbeif ?g is used together with the cbeie bit in the fcnfg register to generate an interrupt request (see figure 2-28 ) . 0 buffers are full. 1 buffers are ready to accept a new command. 6 ccif command complete interrupt flag the ccif ?g indicates that there are no more commands pending. the ccif ?g is cleared when cbeif is clear and sets automatically upon completion of all active and pending commands. the ccif ?g does not set when an active commands completes and a pending command is fetched from the command buffer. writing to the ccif ?g has no effect on ccif. the ccif ?g is used together with the ccie bit in the fcnfg register to generate an interrupt request (see figure 2-28 ). 0 command in progress. 1 all commands are completed. 5 pviol protection violation flag ?the pviol ?g indicates an attempt was made to program or erase an address in a protected area of the flash block during a command write sequence. the pviol ?g is cleared by writing a 1 to pviol. writing a 0 to the pviol ?g has no effect on pviol. while pviol is set, it is not possible to launch a command or start a command write sequence. 0 no failure. 1 a protection violation has occurred. 4 accerr access error flag ?the accerr ?g indicates an illegal access to the flash array caused by either a violation of the command write sequence, issuing an illegal command (illegal combination of the cmdbx bits in the fcmd register), launching the sector erase abort command terminating a sector erase operation early or the execution of a cpu stop instruction while a command is executing (ccif = 0). the accerr ?g is cleared by writing a 1 to accerr. writing a 0 to the accerr ?g has no effect on accerr. while accerr is set, it is not possible to launch a command or start a command write sequence. if accerr is set by an erase verify operation or a data compress operation, any buffered command will not launch. 0 no access error detected. 1 access error has occurred. 2 blank erase verify operation status flag when the ccif ?g is set after completion of an erase verify command, the blank ?g indicates the result of the erase verify operation. the blank ?g is cleared by the flash module when cbeif is cleared as part of a new valid command write sequence. writing to the blank ?g has no effect on blank. 0 flash block veri?d as not erased. 1 flash block veri?d as erased. 1 fail flag indicating a failed flash operation the fail ?g will set if the erase verify operation fails (flash block veri?d as not erased). the fail ?g is cleared by writing a 1 to fail. writing a 0 to the fail ?g has no effect on fail. 0 flash operation completed without error. 1 flash operation failed. memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 83 2.3.2.8 flash command register (fcmd) the fcmd register is the flash command register. all cmdb bits are readable and writable during a command write sequence while bit 7 reads 0 and is not writable. 2.3.2.9 flash control register (fctl) the fctl register is the flash control register. all bits in the fctl register are readable but are not writable. the fctl register is loaded from the flash con?uration field byte at $ff0e during the reset sequence, indicated by f in figure 2-12 . 76543210 r0 cmdb w reset 00000000 = unimplemented or reserved figure 2-11. flash command register (fcmd - nvm user mode) table 2-15. fcmd field descriptions field description 6-0 cmdb[6:0] flash command ?valid flash commands are shown in table 2-16 . writing any command other than those listed in table 2-16 sets the accerr ?g in the fstat register. table 2-16. valid flash command list cmdb[6:0] nvm command 0x05 erase verify 0x06 data compress 0x20 word program 0x40 sector erase 0x41 mass erase 0x47 sector erase abort 76543210 r nv7 nv6 nv5 nv4 nv3 nv2 nv1 nv0 w reset f f ffffff = unimplemented or reserved figure 2-12. flash control register (fctl) chapter 2 64 kbyte flash module (s12fts64kv3) mc9s12ne64 data sheet, rev. 1.1 84 freescale semiconductor 2.3.2.10 flash address registers (faddr) the faddrhi and faddrlo registers are the flash address registers. all faddrhi and faddrlo bits are readable but are not writable. after an array write as part of a command write sequence, the faddr registers will contain the mapped mcu address written. 2.3.2.11 flash data registers (fdata) the fdatahi and fdatalo registers are the flash data registers. table 2-17. fctl field descriptions field description 7-0 nv[7:0] 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. 76543210 r 0 faddrhi w reset 00000000 = unimplemented or reserved figure 2-13. flash address high register (faddrhi) 76543210 r faddrlo w reset 00000000 = unimplemented or reserved figure 2-14. flash address low register (faddrlo) 76543210 r fdatahi w reset 00000000 = unimplemented or reserved figure 2-15. flash data high register (fdatahi) memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 85 all fdatahi and fdatalo bits are readable but are not writable. after an array write as part of a command write sequence, the fdata registers will contain the data written. at the completion of a data compress operation, the resulting 16-bit signature is stored in the fdata registers. the data compression signature is readable in the fdata registers until a new command write sequence is started . 2.3.2.12 reserved2 this register is reserved for factory testing and is not accessible. all bits read 0 and are not writable. 2.3.2.13 reserved3 this register is reserved for factory testing and is not accessible. all bits read 0 and are not writable. 2.3.2.14 reserved4 this register is reserved for factory testing and is not accessible. 76543210 r fdatalo w reset 00000000 = unimplemented or reserved figure 2-16. flash data low register (fdatalo) 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 2-17. reserved2 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 2-18. reserved3 chapter 2 64 kbyte flash module (s12fts64kv3) mc9s12ne64 data sheet, rev. 1.1 86 freescale semiconductor all bits read 0 and are not writable. 2.3.2.15 reserved5 this register is reserved for factory testing and is not accessible. all bits read 0 and are not writable. 2.4 functional description 2.4.1 flash command operations write and read operations are both used for the program, erase, erase verify, and data compress algorithms described in this subsection. the program and erase algorithms are time controlled by a state machine whose timebase, fclk, is derived from the oscillator clock via a programmable divider. the command register as well as the associated address and data registers operate as a buffer and a register (2-stage fifo) so that a second command along with the necessary data and address can be stored to the buffer while the ?st command remains in progress. this pipelined operation allows a time optimization when programming more than one word on a speci? row in the flash block as the high voltage generation can be kept active in between two programming commands. the pipelined operation also allows a simpli?ation of command launching. buffer empty as well as command completion are signalled by ?gs in the flash status register with interrupts generated, if enabled. the next paragraphs describe: 1. how to write the fclkdiv register. 2. command write sequences used to program, erase, and verify the flash memory. 3. valid flash commands. 4. effects resulting from illegal flash command write sequences or aborting flash operations. 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 2-19. reserved4 76543210 r00000000 w reset 00000000 = unimplemented or reserved figure 2-20. reserved5 functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 87 2.4.1.1 writing the fclkdiv register prior to issuing any program, erase, erase verify, or data compress command, it is first necessary to write the fclkdiv register to divide the oscillator clock down to within the 150 khz to 200 khz range. because the program and erase timings are also a function of the bus clock, the fclkdiv determination must take this information into account. if we de?e: fclk as the clock of the flash timing control block, tbus as the period of the bus clock, and int(x) as taking the integer part of x (e.g. int(4.323)=4). then, fclkdiv register bits prdiv8 and fdiv[5:0] are to be set as described in figure 2-21 . for example, if the oscillator clock frequency is 950 khz and the bus clock frequency is 10 mhz, fclkdiv bits fdiv[5:0] must be set to 4 (000100) and bit prdiv8 set to 0. the resulting fclk frequency is then 190 khz. as a result, the flash program and erase algorithm timings are increased over the optimum target by: caution program and erase command execution time will increase proportionally with the period of fclk. because of the impact of clock synchronization on the accuracy of the functional timings, programming or erasing the flash memory cannot be performed if the bus clock runs at less than 1 mhz. programming or erasing the flash memory with fclk < 150 khz must be avoided. setting fclkdiv to a value such that fclk < 150 khz can destroy the flash memory due to overstress. setting fclkdiv to a value such that (1/fclk + tbus) < 5 s can result in incomplete programming or erasure of the flash memory cells. if 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. flash commands will not be executed if the fclkdiv register has not been written to. 200 190 () 200 ? 100 5% = chapter 2 64 kbyte flash module (s12fts64kv3) mc9s12ne64 data sheet, rev. 1.1 88 freescale semiconductor figure 2-21. determination procedure for prdiv8 and fdiv bits prdiv8=1 yes no prdiv8=0 (reset) fclk=(prdclk)/(1+fdiv[5:0]) prdclk=oscillator_clock prdclk=oscillator_clock/8 prdclk[mhz]*(5+tbus[ s]) no fdiv[5:0]=prdclk[mhz]*(5+tbus[ s])-1 yes start tbus < 1 s? an integer? fdiv[5:0]=int(prdclk[mhz]*(5+tbus[ s])) 1/fclk[mhz] + tbus[ s] > 5 and fclk > 0.15 mhz ? end yes no fdiv[5:0] > 4? all commands impossible yes no all commands impossible no try to decrease tbus yes oscillator clock > 12.8 mhz? functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 89 2.4.1.2 command write sequence the flash command controller is used to supervise the command write sequence to execute program, erase, erase verify, and data compress algorithms. before starting a command write sequence, the accerr and pviol flags in the fstat register must be clear (see section 2.3.2.7, ?lash status register (fstat) ) and the cbeif flag must be tested to determine the state of the address, data, and command buffers. if the cbeif flag is set, indicating the buffers are empty, a new command write sequence can be started. if the cbeif flag is clear, indicating the buffers are not available, a new command write sequence will overwrite the contents of the address, data, and command buffers. a command write sequence consists of three steps which must be strictly adhered to with writes to the flash module not permitted between the steps. however, flash register and array reads are allowed during a command write sequence. a command write sequence consists of the following steps: 1. write an aligned data word to a valid flash array address. the address and data will be stored in the address and data buffers, respectively. if the cbeif ?g is clear when the flash array write occurs, the contents of the address and data buffers will be overwritten and the cbeif ?g will be set. 2. write a valid command to the fcmd register. a) for the erase verify command (see section 2.4.1.3.1, ?rase verify command ), the contents of the data buffer are ignored and all address bits in the address buffer are ignored. b) for the data compress command (see section 2.4.1.3.2, ?ata compress command ), the contents of the data buffer represents the number of consecutive words to read for data compression and the contents of the address buffer represents the starting address. c) for the program command (see section 2.4.1.3.3, ?rogram command ), the contents of the data buffer will be programmed to the address speci?d in the address buffer with all address bits valid. d) for the sector erase command (see section 2.4.1.3.4, ?ector erase command ), the contents of the data buffer are ignored and address bits [9:0] contained in the address buffer are ignored. e) for the mass erase command (see section 2.4.1.3.5, ?ass erase command ), the contents of the data buffer and address buffer are ignored. f) for the sector erase abort command (see section 2.4.1.3.6, ?ector erase abort command ), the contents of the data buffer and address buffer are ignored. 3. clear the cbeif ?g by writing a 1 to cbeif to launch the command. when the cbeif ?g is cleared, the ccif ?g is cleared on the same bus cycle by internal hardware indicating that the command was successfully launched. for all command write sequences except data compress and sector erase abort, the cbeif ?g will set four bus cycles after the ccif ?g is cleared indicating that the address, data, and command buffers are ready for a new command write sequence to begin. for data compress and sector erase abort operations, the cbeif ?g will remain clear until the operation completes. a command write sequence can be aborted prior to clearing the cbeif ?g by writing a 0 to the cbeif ?g and will result in the accerr ?g being set. chapter 2 64 kbyte flash module (s12fts64kv3) mc9s12ne64 data sheet, rev. 1.1 90 freescale semiconductor except for the sector erase abort command, a buffered command will wait for the active operation to be completed before being launched. the sector erase abort command is launched when the cbeif ?g is cleared as part of a sector erase abort command write sequence. after a command is launched, the completion of the command operation is indicated by the setting of the ccif ?g. the ccif ?g only sets when all active and buffered commands have been completed. 2.4.1.3 valid flash commands table 2-18 summarizes the valid flash commands along with the effects of the commands on the flash block. 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 2-18. valid flash command description fcmdb nvm command function on flash memory 0x05 erase verify verify all memory bytes in the flash block are erased. if the flash block is erased, the blank ?g in the fstat register will set upon command completion. 0x06 data compress compress data from a selected portion of the flash block. the resulting signature is stored in the fdata register. 0x20 program program a word (two bytes) in the flash block. 0x40 sector erase erase all memory bytes in a sector of the flash block. 0x41 mass erase erase all memory bytes in the flash block. a mass erase of the full flash block is only possible when fpldis, fphdis, and fpopen bits in the fprot register are set prior to launching the command. 0x47 sector erase abort abort the sector erase operation. the sector erase operation will terminate according to a set procedure. the flash sector must not be considered erased if the accerr ?g is set upon command completion. functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 91 2.4.1.3.1 erase verify command the erase verify operation is used to confirm that a flash block is erased. after launching the erase verify command, the ccif flag in the fstat register will set after the operation has completed unless a second command has been buffered. the number of bus cycles required to execute the erase verify operation is equal to the number of addresses in the flash block plus 12 bus cycles as measured from the time the cbeif flag is cleared until the ccif flag is set. the result of the erase verify operation is reflected in the state of the blank flag in the fstat register. if the blank flag is set in the fstat register, the flash memory is erased. figure 2-22. example erase verify command flow write: register fclkdiv read: register fclkdiv bit fdivld set? write: flash block address write: register fcmd erase verify command 0x05 write: register fstat yes no clear bit cbeif 0x80 clock register loaded check 1. 2. 3. clear bit accerr 0x10 write: register fstat yes access error check read: register fstat no no and dummy data bit polling for command completion check read: register fstat note: command write sequence aborted by writing 0x00 to fstat register. note: command write sequence aborted by writing 0x00 to fstat register. ccif set? bit accerr set? bit exit yes blank set? bit yes no flash block not erased; mass erase flash block chapter 2 64 kbyte flash module (s12fts64kv3) mc9s12ne64 data sheet, rev. 1.1 92 freescale semiconductor 2.4.1.3.2 data compress command the data compress command is used to check flash code integrity by compressing data from a selected portion of the flash block into a signature analyzer. the starting address for the data compress operation is defined by the address written during the command write sequence. the number of consecutive word addresses compressed is defined by the data written during the command write sequence. the number of words that can be compressed in a single data compress operation ranges from 1 to 16,384. after launching the data compress command, the ccif flag in the fstat register will set after the data compress operation has completed. the number of bus cycles required to execute the data compress operation is equal to two times the number of addresses read plus 20 bus cycles as measured from the time the cbeif flag is cleared until the ccif flag is set. after the ccif flag is set, the signature generated by the data compress operation is available in the fdata register. the signature in the fdata register can be compared to the expected signature to determine the integrity of the selected data stored in the flash block. if the last address of the flash block is reached during the data compress operation, data compression will continue with the starting address of the flash block. note since the fdata register (or data buffer) is written to as part of the data compress operation, a command write sequence is not allowed to be buffered behind a data compress command write sequence. the cbeif ?g will not set after launching the data compress command to indicate that a command must not be buffered behind it. if an attempt is made to start a new command write sequence with a data compress operation active, the accerr ?g in the fstat register will be set. a new command write sequence must only be started after reading the signature stored in the fdata register. in order to take corrective action, it is recommended that the data compress command be executed on a flash sector or subset of a flash sector. if the data compress operation on a flash sector returns an invalid signature, the flash sector must be erased using the sector erase command and then reprogrammed using the program command. the data compress command can be used to verify that a sector or sequential set of sectors are erased. functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 93 figure 2-23. example data compress command flow write: register fclkdiv read: register fclkdiv bit fdivld set? write: flash address to start write: register fcmd data compress command 0x06 write: register fstat yes no clear bit cbeif 0x80 clock register loaded check 1. 2. 3. clear bit accerr 0x10 write: register fstat yes no access error check read: register fstat no exit compression and number of bit polling for command completion check read: register fstat yes note: command write sequence aborted by writing 0x00 to fstat register. note: command write sequence aborted by writing 0x00 to fstat register. ccif set? bit accerr set? bit word addresses to compress (max 16,384) read: register fdata data compress signature no erase and reprogram yes signature valid? signature flash region compressed compared to known value chapter 2 64 kbyte flash module (s12fts64kv3) mc9s12ne64 data sheet, rev. 1.1 94 freescale semiconductor 2.4.1.3.3 program command the program command is used to program a previously erased word in the flash memory using an embedded algorithm. if the word to be programmed is in a protected area of the flash block, the pviol flag in the fstat register will set and the program command will not launch. after the program command has successfully launched, the ccif flag in the fstat register will set after the program operation has completed unless a second command has been buffered. a summary of the launching of a program operation is shown in figure 2-24 . figure 2-24. example program command flow write: register fclkdiv read: register fclkdiv bit fdivld set? write: flash address and write: register fcmd program command 0x20 write: register fstat yes no clear bit cbeif 0x80 yes clock register loaded check 1. 2. 3. clear bit accerr 0x10 write: register fstat no yes no protection violation check access error check read: register fstat no no address, data, command buffer empty check next write? yes exit no program data clear bit pviol 0x20 write: register fstat yes bit polling for command completion check read: register fstat yes note: command write sequence aborted by writing 0x00 to fstat register. note: command write sequence aborted by writing 0x00 to fstat register. ccif set? bit cbeif set? bit accerr set? bit pviol set? bit functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 95 2.4.1.3.4 sector erase command the sector erase command is used to erase the addressed sector in the flash memory using an embedded algorithm. if the flash sector to be erased is in a protected area of the flash block, the pviol flag in the fstat register will set and the sector erase command will not launch. after the sector erase command has successfully launched, the ccif flag in the fstat register will set after the sector erase operation has completed unless a second command has been buffered. figure 2-25. example sector erase command flow write: register fclkdiv read: register fclkdiv bit fdivld set? write: flash sector address write: register fcmd sector erase command 0x40 write: register fstat yes no clear bit cbeif 0x80 yes clock register loaded check 1. 2. 3. clear bit accerr 0x10 write: register fstat no yes no protection violation check access error check read: register fstat no no address, data, command buffer empty check next write? yes exit no and dummy data clear bit pviol 0x20 write: register fstat yes bit polling for command completion check read: register fstat yes note: command write sequence aborted by writing 0x00 to fstat register. note: command write sequence aborted by writing 0x00 to fstat register. ccif set? bit pviol set? bit accerr set? bit cbeif set? bit chapter 2 64 kbyte flash module (s12fts64kv3) mc9s12ne64 data sheet, rev. 1.1 96 freescale semiconductor 2.4.1.3.5 mass erase command the mass erase command is used to erase a flash memory block using an embedded algorithm. if the flash block to be erased contains any protected area, the pviol flag in the fstat register will set and the mass erase command will not launch. after the mass erase command has successfully launched, the ccif flag in the fstat register will set after the mass erase operation has completed unless a second command has been buffered. figure 2-26. example mass erase command flow write: register fclkdiv read: register fclkdiv bit fdivld set? write: flash block address write: register fcmd mass erase command 0x41 write: register fstat yes no clear bit cbeif 0x80 yes clock register loaded check 1. 2. 3. clear bit accerr 0x10 write: register fstat no yes no protection violation check access error check read: register fstat ccif set? bit no no address, data, command buffer empty check next write? yes exit no and dummy data clear bit pviol 0x20 write: register fstat yes bit polling for command completion check read: register fstat yes note: command write sequence aborted by writing 0x00 to fstat register. note: command write sequence aborted by writing 0x00 to fstat register. pviol set? bit accerr set? bit cbeif set? bit functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 97 2.4.1.3.6 sector erase abort command the sector erase abort command is used to terminate the sector erase operation so that other sectors in the flash block are available for read and program operations without waiting for the sector erase operation to complete. if the sector erase abort command is launched resulting in the early termination of an active sector erase operation, the accerr flag will set after the operation completes as indicated by the ccif flag being set. the accerr flag sets to inform the user that the sector may not be fully erased and a new sector erase command must be launched before programming any location in that specific sector. if the sector erase abort command is launched but the active sector erase operation completes normally, the accerr flag will not set upon completion of the operation as indicated by the ccif flag being set. therefore, if the accerr flag is not set after the sector erase abort command has completed, the sector being erased when the abort command was launched is fully erased. the maximum number of cycles required to abort a sector erase operation is equal to four fclk periods (see section 2.4.1.1, ?riting the fclkdiv register ) plus five bus cycles as measured from the time the cbeif flag is cleared until the ccif flag is set. note since the accerr bit in the fstat register may be set at the completion of the sector erase abort operation, a command write sequence is not allowed to be buffered behind a sector erase abort command write sequence. the cbeif ?g will not set after launching the sector erase abort command to indicate that a command must not be buffered behind it. if an attempt is made to start a new command write sequence with a sector erase abort operation active, the accerr ?g in the fstat register will be set. a new command write sequence may be started after clearing the accerr ?g, if set. note the sector erase abort command must be used sparingly because a sector erase operation that is aborted counts as a complete program/erase cycle. chapter 2 64 kbyte flash module (s12fts64kv3) mc9s12ne64 data sheet, rev. 1.1 98 freescale semiconductor figure 2-27. example sector erase abort command flow write: dummy flash address write: register fcmd sector erase abort cmd 0x47 write: register fstat clear bit cbeif 0x80 1. 2. 3. read: register fstat no exit and dummy data bit polling for command completion check read: register fstat yes note: command write sequence aborted by writing 0x00 to fstat register. note: command write sequence aborted by writing 0x00 to fstat register. ccif set? bit execute sector erase command flow no bit polling for command completion check read: register fstat yes ccif set? bit no yes abort needed? erase exit clear bit accerr 0x10 write: register fstat yes no access error check accerr set? bit exit sector erase completed sector erase aborted functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 99 2.4.1.4 illegal flash operations the accerr flag will be set during the command write sequence if any of the following illegal steps are performed, causing the command write sequence to immediately abort: 1. writing to a flash address before initializing the fclkdiv register. 2. writing a byte or misaligned word to a valid flash address. 3. starting a command write sequence while a data compress operation is active. 4. starting a command write sequence while a sector erase abort operation is active. 5. writing a second word to a flash address in the same command write sequence. 6. writing to any flash register other than fcmd after writing a word to a flash address. 7. writing a second command to the fcmd register in the same command write sequence. 8. writing an invalid command to the fcmd register. 9. when security is enabled, writing a command other than mass erase to the fcmd register when the write originates from a non-secure memory location or from the background debug mode. 10. writing to any flash register other than fstat (to clear cbeif) after writing to the fcmd register. 11. writing a 0 to the cbeif ?g in the fstat register to abort a command write sequence. the accerr flag will not be set if any flash register is read during a valid command write sequence. the accerr ?g will also be set if any of the following events occur: 1. launching the sector erase abort command while a sector erase operation is active which results in the early termination of the sector erase operation (see section 2.4.1.3.6, ?ector erase abort command ) 2. the mcu enters stop mode and a program or erase operation is in progress. the operation is aborted immediately and any pending command is purged (see section 2.5.2, ?top mode ). if the flash memory is read during execution of an algorithm (i.e., ccif flag in the fstat register is low), the read operation will return invalid data and the accerr flag will not be set. if the accerr flag is set in the fstat register, the user must clear the accerr flag before starting another command write sequence (see section 2.3.2.7, ?lash status register (fstat) ). the pviol flag will be set after the command is written to the fcmd register during a command write sequence if any of the following illegal operations are attempted, causing the command write sequence to immediately abort: 1. writing the program command if the address written in the command write sequence was in a protected area of the flash memory. 2. writing the sector erase command if the address written in the command write sequence was in a protected area of the flash memory. 3. writing the mass erase command while any flash protection is enabled. if the pviol flag is set in the fstat register, the user must clear the pviol flag before starting another command write sequence (see section 2.3.2.7, ?lash status register (fstat) ). chapter 2 64 kbyte flash module (s12fts64kv3) mc9s12ne64 data sheet, rev. 1.1 100 freescale semiconductor 2.5 operating modes 2.5.1 wait mode if a command is active (ccif = 0) when the mcu enters wait mode, the active command and any buffered command will be completed. the flash module can recover the mcu from wait mode if the cbeif and ccif interrupts are enabled ( section 2.8, ?nterrupts ). 2.5.2 stop mode if a command is active (ccif = 0) when the mcu enters stop mode, the operation will be aborted and, if the operation is program or erase, the flash array data being programmed or erased may be corrupted and the ccif and accerr flags will be set. if active, the high voltage circuitry to the flash memory will immediately be switched off when entering stop mode. upon exit from stop mode, the cbeif flag is set and any buffered command will not be launched. the accerr flag must be cleared before starting a command write sequence (see section 2.4.1.2, ?ommand write sequence ). note as active commands are immediately aborted when the mcu enters stop mode, it is strongly recommended that the user does not use the stop instruction during program or erase operations. 2.5.3 background debug mode in background debug mode (bdm), the fprot register is writable. if the mcu is unsecured, then all flash commands listed in table 2-18 can be executed. 2.6 flash module security the flash module provides the necessary security information to the mcu. after each reset, the flash module determines the security state of the mcu as de?ed in section 2.3.2.2, ?lash security register (fsec) . the contents of the flash security byte at 0xff0f in the flash con?uration ?ld must be changed directly by programming 0xff0f when the mcu is unsecured and the higher address sector is unprotected. if the flash security byte remains in a secured state, any reset will cause the mcu to initialize to a secure operating mode. 2.6.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 0xff00?xff07). if the keyen[1:0] bits are in the enabled state (see section 2.3.2.2, ?lash security register (fsec) ) and the flash module security mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 101 keyacc bit is set, a write to a backdoor key address in the flash memory triggers a comparison between the written data and the backdoor key data stored in the flash memory. if all four words of data are written to the correct addresses in the correct order and the data matches the backdoor keys stored in the flash memory, the mcu will be unsecured. the data must be written to the backdoor keys sequentially starting with 0xff00?xff01 and ending with 0xff06?xff07. 0x0000 and 0xffff are not permitted as backdoor keys. while the keyacc bit is set, reads of the flash memory will return invalid data. the user code stored in the flash memory must have a method of receiving the backdoor key 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 2.3.2.2, ?lash security register (fsec) ), the mcu can be unsecured by the backdoor access sequence described below: 1. set the keyacc bit in the flash con?uration register (fcnfg). 2. write the correct four 16-bit words to flash addresses 0xff00?xff07 sequentially starting with 0xff00. 3. clear the keyacc bit. 4. if all four 16-bit words match the backdoor keys stored in flash addresses 0xff00?xff07, the mcu is unsecured and the sec[1:0] bits in the fsec register are forced to the unsecure state of 1:0. the backdoor key access sequence is monitored by an internal security state machine. an illegal operation during the backdoor key access sequence will cause the security state machine to lock, leaving the mcu in the secured state. a reset of the mcu will cause the security state machine to exit the lock state and allow a new backdoor key access sequence to be attempted. the following operations during the backdoor key access sequence will lock the security state machine: 1. if any of the four 16-bit words does not match the backdoor keys programmed in the flash array. 2. if the four 16-bit words are written in the wrong sequence. 3. if more than four 16-bit words are written. 4. if any of the four 16-bit words written are 0x0000 or 0xffff. 5. if the keyacc bit does not remain set while the four 16-bit words are written. 6. if any two of the four 16-bit words are written on successive mcu clock cycles. after the backdoor keys have been correctly matched, the mcu will be unsecured. after the mcu is unsecured, the flash security byte can be programmed 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 0xff00?xff07 in the flash con?uration ?ld. the security as de?ed in the flash security byte (0xff0f) is not changed by using the backdoor key access sequence to unsecure. the backdoor keys stored in addresses 0xff00?xff07 are unaffected by the backdoor key access sequence. after the next reset of the mcu, the security state of the flash module is determined by the flash security byte (0xff0f). the backdoor key access sequence has no effect on the program and erase protections de?ed in the flash protection register. it is not possible to unsecure the mcu in special single-chip mode by using the backdoor key access sequence via the background debug mode (bdm). chapter 2 64 kbyte flash module (s12fts64kv3) mc9s12ne64 data sheet, rev. 1.1 102 freescale semiconductor 2.6.2 unsecuring the flash module in special single-chip mode using bdm the mcu can be unsecured in special single-chip mode by erasing the flash module by the following method : reset the mcu into special single-chip mode, delay while the erase test is performed by the bdm secure rom, send bdm commands to disable protection in the flash module, and execute a mass erase command write sequence to erase the flash memory. after the ccif ?g sets to indicate that the mass operation has completed, reset the mcu into special single-chip mode. the bdm secure rom will verify that the flash memory is erased and will assert the unsec bit in the bdm status register. this bdm action will cause the mcu to override the flash security state and 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 word program sequence to program the flash security byte to the unsecured state and reset the mcu. 2.7 resets 2.7.1 flash reset sequence on each reset, the flash module executes a reset sequence to hold cpu activity while loading the following registers from the flash memory according to table 2-1 : fprot ?flash protection register (see section 2.3.2.5 ). fctl ?flash control register (see section 2.3.2.9 ). fsec ?flash security register (see section 2.3.2.2 ). 2.7.2 reset while flash command active 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. 2.8 interrupts the flash module can generate an interrupt when all flash command operations have completed, when the flash address, data, and command buffers are empty. table 2-19. flash interrupt sources interrupt source interrupt flag local enable global (ccr) mask flash address, data and command buffers empty cbeif (fstat register) cbeie (fcnfg register) i bit all flash commands completed ccif (fstat register) ccie (fcnfg register) i bit interrupts mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 103 note vector addresses and their relative interrupt priority are determined at the mcu level. 2.8.1 description of flash interrupt operation the logic used for generating interrupts is shown in figure 2-28 . the flash module uses the cbeif and ccif ?gs in combination with the cbie and ccie enable bits to generate the flash command interrupt request. figure 2-28. flash interrupt implementation for a detailed description of the register bits, refer to section 2.3.2.4, ?lash con?uration register (fcnfg) and section 2.3.2.7, ?lash status register (fstat) . flash command interrupt request cbeie cbeif ccie ccif chapter 2 64 kbyte flash module (s12fts64kv3) mc9s12ne64 data sheet, rev. 1.1 104 freescale semiconductor mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 105 chapter 3 port integration module (pim9ne64v1) 3.1 introduction figure 3-1 is a block diagram of the pim_9ne64. the port integration module establishes the interface between the peripheral modules and the i/o pins for all ports. this section covers: port a, b, e, and k related to the core logic and multiplexed bus interface port t connected to the timer module port s associated with 2 sci and 1 spi modules port g, h, and j connected to emac module, each of them also can be used as an external interrupt source. port l connected to ephy module each i/o pin can be con?ured by several registers: input/output selection, drive strength reduction, enable and select of pull resistors, interrupt enable and status ?gs. the implementation of the port integration module is device dependent. chapter 3 port integration module (pim9ne64v1) mc9s12ne64 data sheet, rev. 1.1 106 freescale semiconductor figure 3-1. pim_9ne64 block diagram 3.1.1 features a standard port has the following minimum features: input/output selection port t pt4 pt5 pt6 pt7 tim tim_ioc4 tim_ioc5 tim_ioc6 tim_ioc7 port s ps0 ps1 ps2 ps3 ps4 ps5 ps6 ps7 scio_rxd scio_txd sci1_rxd sci1_txd spi_miso spi_mosi spi_sck spi_ ss sci0 sci1 spi pb0 pb1 pb2 pb3 pb4 pb5 pb6 pb7 pa 0 pa 1 pa 2 pa 3 pa 4 pa 5 pa 6 pa 7 port e pe0 pe1 pe2 pe3 pe4 pe5 pe6 pe7 port k pk0 pk1 pk2 pk3 pk7 pk4 pk5 addr8/data8 addr9/data9 addr10/data10 addr11/data11 addr12/data12 addr13/data13 addr14/data14 addr15/data15 addr0/data0 addr1/data1 addr2/data2 addr3/data3 addr4/data4 addr5/data5 addr6/data6 addr7/data7 xirq irq r/ w lstrb/ t a glo eclk ipipe0/moda noacc ipipe1/modb xaddr15 xaddr16 xaddr17 ecs/romctl xadrr18 xaddr19 core xaddr14 bkgd/modc/ t a ghi bkgd pk6 xcs 10base-t physical transceiver(ephy) spdled dupled lnkled port l pl0 pl1 pl2 pl3 kwh2 kwh6 kwh0 kwh1 kwh3 kwh4 kwh5 kwg2 kwg6 kwg0 kwg1 kwg3 kwg4 kwg5 kwj0 kwj1 kwj2 kwj3 port h port g port j mii pg4 pg5 pg6 pg0 pg1 pg2 pj2 pj3 pj0 pj1 pl4 colled actled pg7 pg3 kwg7 pj6 pj7 iic_sda iic_scl kwj6 kwj7 pl5 pl6 iic port b port a ph4 ph5 ph6 ph0 ph1 ph2 ph3 emac port integration module mii_rxd2 mii_rxer mii_rxd0 mii_rxd1 mii_rxd3 mii_rxclk mii_rxdv mii_crs mii_col mii_mdc mii_mdio ethernet media access controller mii_ txclk mii_ txen mii_ txer mii_ txd0 mii_ txd1 mii_ txd2 mii_ txd3 100base-tx external signal description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 107 3.3 v output drive with two selectable drive strength 3.3 v digital and analog input input with selectable pull-up or pull-down device optional features: open drain for wired-or connections interrupt inputs with glitch ?tering 3.2 external signal description this section lists and describes the signals that connect off-chip. table 3-1 shows all pins and their functions that are controlled by the pim_9ne64 module. if there is more than one function associated to a pin, the priority is indicated by the position in the table from top (highest priority) to bottom (lowest priority). table 3-1. pin functions and priorities (sheet 1 of 4) port pin name pin function description pin function after reset port a pa[7:0] addr[15:8]/ data[15:8]/ gpio refer the mebi block description chapter. port b pb[7:0] addr[7:0]/ data[7:0]/ gpio refer the mebi block description chapter. port e pe7 noacc/ gpio refer the mebi block description chapter. pe6 ipipe1/ modb/ gpio pe5 ipipe0/ moda/ gpio pe4 eclk/gpio pe3 lstrb/ t a glo/ gpio pe2 r/ w / gpio pe1 irq/gpi pe0 xirq/gpi chapter 3 port integration module (pim9ne64v1) mc9s12ne64 data sheet, rev. 1.1 108 freescale semiconductor port k pk7 ecs/ romctl/ gpio refer to the mebi block description chapters. pk6 xcs pk[5:0] xaddr[19:14]/ gpio bkgd bkgd/ modc/ t a ghi refer to the mebi and bdm block description chapters. port g pg[7] kwu/gpio key board wake up interrupt or general-purpose i/o gpio pg[6] mii_rxer mii receive coding error kwu/gpio key board wake up interrupt or general-purpose i/o pg[5] mii_rxdv mii receive data valid kwu/gpio key board wake up interrupt or general-purpose i/o pg[4] mii_rxclk mii receive clock kwu/gpio key board wake up interrupt or general-purpose i/o pg[3:0] mii_rxd[3:0] mii receive data kwu/gpio key board wake up interrupts or general-purpose i/o port h ph[6] mii_txer mii transmit coding error gpio kwu/gpio key board wake up interrupts or general-purpose i/o ph[5] mii_txen mii transmit enable kwu/gpio key board wake up interrupts or general-purpose i/o ph[4] mii_txclk mii transmit clock kwu/gpio key board wake up interrupts or general-purpose i/o ph[3:0] mii_txd[3:0] mii transmit data kwu/gpio key board wake up interrupts or general-purpose i/o table 3-1. pin functions and priorities (sheet 2 of 4) port pin name pin function description pin function after reset external signal description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 109 port j pj[7] iic_scl serial clock line bidirectional pin of iic module gpio kwu/gpio key board wake up interrupt or general-purpose i/o pj[6] iic_sda serial data line bidirectional pin of iic module kwu/gpio key board wake up interrupt or general-purpose i/o pj[3] mii_col mii collision kwu/gpio key board wake up interrupt or general-purpose i/o pj[2] mii_crs mii carrier sense kwu/gpio key board wake up interrupt or general-purpose i/o pj[1] mii_mdio mii management data input/output kwu/gpio key board wake up interrupt or general-purpose i/o pj[0] mii_mdc mii management data clock kwu/gpio key board wake up interrupt or general-purpose i/o port l pl[6] gpio general-purpose i/o gpio pl[5] gpio general-purpose i/o pl[4] colled ephy collision led gpio general-purpose i/o pl[3] dupled ephy duplex led gpio general-purpose i/o pl[2] spdled ephy speed led gpio general-purpose i/o pl[1] lnkled ephy link led gpio general-purpose i/o pl[0] actled ephy active led gpio general-purpose i/o table 3-1. pin functions and priorities (sheet 3 of 4) port pin name pin function description pin function after reset chapter 3 port integration module (pim9ne64v1) mc9s12ne64 data sheet, rev. 1.1 110 freescale semiconductor 3.3 memory map and register descriptions this section provides a detailed description of all registers. 3.3.1 module memory map table 3-2 shows the memory map of the port integration module. port s ps[7] spi_ ss serial peripheral interface slave select output in master mode, input in slave mode or master mode. gpio gpio general-purpose i/o ps[6] spi_sck serial peripheral interface serial clock pin gpio general-purpose i/o ps[5] spi_mosi serial peripheral interface master out/slave in pin gpio general-purpose i/o ps[4] spi_miso serial peripheral interface master in/slave out pin gpio general-purpose i/o ps[3] sci1_txd serial communication interface 1 transmit pin gpio general-purpose i/o ps[2] sci1_rxd serial communication interface 1 receive pin gpio general-purpose i/o ps[1] sci0_txd serial communication interface 0 transmit pin gpio general-purpose i/o ps[0] sci0_rxd serial communication interface 0 receive pin gpio general-purpose i/o port t pt[7:4] ioc[7:4] standard timer1 channels 7 to 4 gpio gpio general-purpose i/o table 3-2. pim module memory map address offset use access $00 port t i/o register (ptt) r/w $01 port t input register (ptit) r $02 port t data direction register (ddrt) r/w $03 port t reduced drive register (rdrt) r/w $04 port t pull device enable register (pert) r/w $05 port t polarity select register (ppst) r/w table 3-1. pin functions and priorities (sheet 4 of 4) port pin name pin function description pin function after reset memory map and register descriptions mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 111 $06-07 reserved $08 port s i/o register (pts) r/w $09 port s input register (ptis) r $0a port s data direction register (ddrs) r/w $0b port s reduced drive register (rdrs) r/w $0c port s pull device enable register (pers) r/w $0d port s polarity select register (ppss) r/w $0e port s wired-or mode register (woms) r/w $0f reserved $10 port g i/o register (ptg) r/w $11 port g input register (ptig) r $12 port g data direction register (ddrg) r/w $13 port g reduced drive register (rdrg) r/w $14 port g pull device enable register (perg) r/w $15 port g polarity select register (ppsg) r/w $16 port g interrupt enable register (pieg) r/w $17 port g interrupt flag register (pifg) r/w $18 port h i/o register (pth) r/w $19 port h input register (ptih) r $1a port h data direction register (ddrh) r/w $1b port h reduced drive register (rdrh) r/w $1c port h pull device enable register (perh) r/w $1d port h polarity select register (ppsh) r/w $1e port h interrupt enable register (pieh) r/w $1f port h interrupt flag register (pifh) r/w $20 port j i/o register (ptj) r/w $21 port j input register (ptij) r $22 port j data direction register (ddrj) r/w $23 port j reduced drive register (rdrj) rw $24 port j pull device enable register (perj) r/w $25 port j polarity select register (ppsj) r/w $26 port j interrupt enable register (piej) r/w $27 port j interrupt flag register (pifj) r/w $28 port l i/o register (ptl) r/w $29 port l input register (ptil) r $2a port l data direction register (ddrl) r/w $2b port l reduced drive register (rdrl) r/w $2c port l pull device enable register (perl) r/w $2d port l polarity select register (ppsl) r/w $2e port l wired-or mode register (woml) rw $2f-$3f reserved table 3-2. pim module memory map (continued) chapter 3 port integration module (pim9ne64v1) mc9s12ne64 data sheet, rev. 1.1 112 freescale semiconductor note register address = base address + address offset, where the base address is de?ed at the mcu level and the address offset is de?ed at the module level. 3.3.2 register descriptions the following table summarizes the effect on the various con?uration bits - data direction (ddr), input / output level (i/o), reduced drive (rdr), pull enable (pe), pull select (ps) and interrupt enable (ie) for the ports. the con?uration bit ps is used for two purposes: 1. con?ure the sensitive interrupt edge (rising or falling), if interrupt is enabled. 2. select either a pull-up or pull-down device if pe is active. note all bits of all registers in this module are completely synchronous to internal clocks during a register read. table 3-3. pin con?uration summary ddr io rdr pe ps ie 1 1 applicable only on ports g, h, and j. function pull device interrupt 0 x x 0 x 0 input disabled disabled 0 x x 1 0 0 input pull up disabled 0 x x 1 1 0 input pull down disabled 0 x x 0 0 1 input disabled falling edge 0 x x 0 1 1 input disabled rising edge 0 x x 1 0 1 input pull up falling edge 0 x x 1 1 1 input pull down rising edge 1 0 0 x x 0 output, full drive to 0 disabled disabled 1 1 0 x x 0 output, full drive to 1 disabled disabled 1 0 1 x x 0 output, reduced drive to 0 disabled disabled 1 1 1 x x 0 output, reduced drive to 1 disabled disabled 1 0 0 x 0 1 output, full drive to 0 disabled falling edge 1 1 0 x 1 1 output, full drive to 1 disabled rising edge 1 0 1 x 0 1 output, reduced drive to 0 disabled falling edge 1 1 1 x 1 1 output, reduced drive to 1 disabled rising edge memory map and register descriptions mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 113 3.3.2.1 port t registers 3.3.2.1.1 i/o register (ptt) figure 3-2. port t i/o register (ptt) read:anytime. write:anytime. if the data direction bits of the associated i/o pins are set to 1, a read returns the value of the port register, otherwise the value at the pins is read. the standard timer module (tim) can be con?ured to use the pt[7:4] as timer input capture/output compare pins. if ioc[7:4]-channel is de?ed as output, the related port t is assigned to ioc function. 3.3.2.1.2 input register (ptit) figure 3-3. port t input register (ptit) read:anytime. write:never, writes to this register have no effect. this register always reads back the status of the associated pins. this can also be used to detect overload or short circuit conditions on output pins. 3.3.2.1.3 data direction register (ddrt) figure 3-4. port t data direction register (ddrt) module base + $0 bit 7 6 5 4 3 2 1 bit 0 read: ptt7 ptt6 ptt5 ptt4 0 0 0 0 write tim ioc7 ioc6 ioc5 ioc4 reset: 0 0 0 0 = reserved or unimplemented module base + $1 bit 7 6 5 4 3 2 1 bit 0 read: ptit7 ptit6 ptit5 ptit4 0 0 0 0 write: reset: = reserved or unimplemented module base + $2 bit 7 6 5 4 3 2 1 bit 0 read: ddrt7 ddrt6 ddrt5 ddrt4 0 0 0 0 write: reset: 0 0 0 0 = reserved or unimplemented chapter 3 port integration module (pim9ne64v1) mc9s12ne64 data sheet, rev. 1.1 114 freescale semiconductor read:anytime. write:anytime. this register con?ures each port t pin as either input or output. the standard tim module forces the i/o state to be an output for each port pin associated with an enabled output compare. when the pin is con?ured as an output compare the corresponding data direction register (ddrt) bits do not have any effect on the i/o direction of the pin, and will maintain their previously latched value. the ddrt bits revert to controlling the i/o direction of a pin when the associated timer output compare is disabled. if a pin is being used as a timer input capture, the ddrt remains in control of the pin s i/o direction and the timer monitors the state of the pin. ddrt[7:4] ?data direction port t 1 = associated pin is configured as output. 0 = associated pin is configured as input. due to internal synchronization circuits, it can take up to 2 bus cycles until the correct value is read on ptt or ptit registers, when changing the ddrt register. 3.3.2.1.4 reduced drive register (rdrt) figure 3-5. port t reduced drive register (rdrt) read:anytime. write:anytime. this register con?ures the drive strength of each port t output pin as either full or reduced. if the port is used as input this bit is ignored. rdrt[7:4] ?reduced drive port t 1 = associated pin drives at about 1/3 of the full drive strength. 0 = full drive strength at output. module base + $3 bit 7 6 5 4 3 2 1 bit 0 read: rdrt7 rdrt6 rdrt5 rdrt4 0 0 0 0 write: reset: 0 0 0 0 = reserved or unimplemented memory map and register descriptions mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 115 3.3.2.1.5 pull device enable register (pert) figure 3-6. port t pull device enable register (pert) read:anytime. write:anytime. this register con?ures whether a pull-up or a pull-down device is activated, if the port is used as input. this bit has no effect if the port is used as output. out of reset no pull device is enabled. pert[7:4] ?pull device enable port t 1 = either a pull-up or pull-down device is enabled. 0 = pull-up or pull-down device is disabled. 3.3.2.1.6 polarity select register (ppst) figure 3-7. port t polarity select register (ppst) read:anytime. write:anytime. this register selects whether a pull-down or a pull-up device is connected to the pin. ppst[7:4] ?pull select port t 1 = a pull-down device is connected to the associated port t pin, if enabled by the associated bit in register pert and if the port is used as input. 0 = a pull-up device is connected to the associated port t pin, if enabled by the associated bit in register pert and if the port is used as input. module base + $4 bit 7 6 5 4 3 2 1 bit 0 read: pert7 pert6 pert5 pert4 0000 write: reset: 0 0 0 0 = reserved or unimplemented module base + $5 bit 7 6 5 4 3 2 1 bit 0 read: ppst7 ppst6 ppst5 ppst4 0000 write: reset: 0 0 0 0 = reserved or unimplemented chapter 3 port integration module (pim9ne64v1) mc9s12ne64 data sheet, rev. 1.1 116 freescale semiconductor 3.3.2.2 port s registers 3.3.2.2.1 i/o register (pts) figure 3-8. port s i/o register (pts) read:anytime. write:anytime. if the data direction bits of the associated i/o pins are set to 1, a read returns the value of the port register, otherwise the value at the pins is read. the spi function takes precedence over the general-purpose i/o function if the spi module is enabled. if the spi is enabled the ps[7:4] pins become spi_ ss, spi_sck, spi_mosi, and spi_miso, and their con?uration is determined by several status bits in the spi module. refer to the spi block description chapter for details. the sci1 and sci0 function take precedence over the general-purpose i/o function on pins ps[3:0]. if the sci1 or sci0 transmitters or receivers are enabled, the sci1 and sci0 transmit pins, sci1_txd and sci0_txd, are con?ured as outputs if the corresponding transmitter is enabled. the sci1 and sci0 receive pins, sci1_rxd and sci0_rxd, are con?ured as inputs if the corresponding receiver is enabled. refer to the sci block description chapter for details. 3.3.2.2.2 input register (ptis) figure 3-9. port s input register (ptis) read:anytime. write: writes to this register have no effect. this register always reads back the status of the associated pins. this also can be used to detect overload or short circuit conditions on output pins. module base + $8 bit 7 6 5 4 3 2 1 bit 0 read: pts7 pts6 pts5 pts4 pts3 pts2 pts1 pts0 write: spi ss sck mosi miso sci sci1_txd sci1_rxd sci0_txd sci0_rxd reset: 0 0 0 0 0 0 0 0 module base + $9 bit 7 6 5 4 3 2 1 bit 0 read: ptis7 ptis6 ptis5 ptis4 ptis3 ptis2 ptis1 ptis0 write: reset: = reserved or unimplemented memory map and register descriptions mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 117 3.3.2.2.3 data direction register (ddrs) figure 3-10. port s data direction register (ddrs) read:anytime. write:anytime. this register con?ures each port s pin as either input or output. if the spi is enabled, the spi controls the spi related pins (spi_ ss, spi_sck, spi_mosi, spi_miso) i/o direction, and the corresponding ddrs[7:4] bits have no effect on the spi pins i/o direction. refer to the spi block description chapter for details. when the sci0 or sci1 transmitters are enabled, the corresponding transmit pins, sci0_txd and sci0_txd, i/o direction is controlled by the sci0 and sci1 respectively, and the corresponding ddrs3 and ddrs1 bits have no effect on their i/o direction. when the sci0 or sci1 receivers are enabled, the corresponding receive pins, sci0_rxd and sci1_rxd, i/o direction is controlled by the sci0 and sci1 respectively, and the ddrs2 and ddrs0 bits have no effect on their i/o direction. refer to the sci block description chapter for further details. the ddrs[7:0] bits revert to controlling the i/o direction of the pins when the associated spi or sci function is disabled. ddrs[7:0] ?data direction port s 1 = associated pin is configured as output. 0 = associated pin is configured as input. due to internal synchronization circuits, it can take up to 2 bus cycles until the correct value is read on pts or ptis registers, when changing the ddrs register. 3.3.2.2.4 reduced drive register (rdrs) figure 3-11. port s reduced drive register (rdrs) read:anytime. write:anytime. this register con?ures the drive strength of each port s output pin as either full or reduced. if the port is used as input this bit is ignored. module base + $a bit 7 6 5 4 3 2 1 bit 0 read: ddrs7 ddrs6 ddrs5 ddrs4 ddrs3 ddrs2 ddrs1 ddrs0 write: reset: 0 0 0 0 0 0 0 0 module base + $b bit 7 6 5 4 3 2 1 bit 0 read: rdrs7 rdrs6 rdrs5 rdrs4 rdrs3 rdrs2 rdrs1 rdrs0 write: reset: 0 0 0 0 0 0 0 0 chapter 3 port integration module (pim9ne64v1) mc9s12ne64 data sheet, rev. 1.1 118 freescale semiconductor rdrs[7:0] ?reduced drive port s 1 = associated pin drives at about 1/3 of the full drive strength. 0 = full drive strength at output. 3.3.2.2.5 pull device enable register (pers) figure 3-12. port s pull device enable register (pers) read:anytime. write:anytime. this register con?ures whether a pull-up or a pull-down device is activated, if the port is used as input or as output in wired-or (open drain) mode. these bits have no effect if the port is used as push-pull output. out of reset a pull-up device is enabled. pers[7:0] ?pull device enable port s 1 = either a pull-up or pull-down device is enabled. 0 = pull-up or pull-down device is disabled. 3.3.2.2.6 polarity select register (ppss) figure 3-13. port s polarity select register (ppss) read:anytime. write:anytime. this register selects whether a pull-down or a pull-up device is connected to the pin. ppss[7:0] ?pull select port s 1 = a pull-down device is connected to the associated port s pin, if enabled by the associated bit in register pers and if the port is used as input. 0 = a pull-up device is connected to the associated port s pin, if enabled by the associated bit in pers register and if the port is used as input or as wired-or output. module base + $c bit 7 6 5 4 3 2 1 bit 0 read: pers7 pers6 pers5 pers4 pers3 pers2 pers1 pers0 write: reset: 1 1 1 1 1 1 1 1 module base + $d bit 7 6 5 4 3 2 1 bit 0 read: ppss7 ppss6 ppss5 ppss4 ppss3 ppss2 ppss1 ppss0 write: reset: 0 0 0 0 0 0 0 0 memory map and register descriptions mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 119 3.3.2.2.7 wired-or mode register (woms) figure 3-14. port s wired-or mode register (woms) read:anytime. write:anytime. this register con?ures the output pins as wired-or. if enabled the output is driven active low only (open-drain). a logic level of ??is not driven. it applies also to the spi and sci outputs and allows a multipoint connection of several serial modules. these bits have no in?ence on pins used as inputs. woms[7:0] ?wired-or mode port s 1 = open-drain mode enabled for output buffers. 0 = open-drain mode disabled for output buffers. 3.3.2.3 port g registers 3.3.2.3.1 i/o register (ptg) figure 3-15. port g i/o register (ptg) read:anytime. write:anytime. if the data direction bits of the associated i/o pins are set to 1, a read returns the value of the port register, otherwise the value at the pins is read. the emac mii external interface takes precedence over general-purpose i/o function if the emac module is enabled in external phy mode. if the emac is enabled pg[6:0] pins become inputs mii_rxer, mii_rxdv, mii_rxclk, mii_rxd[3:0]. please refer to the emac block description chapter for details. module base + $e bit 7 6 5 4 3 2 1 bit 0 read: woms7 woms6 woms5 woms4 woms3 woms2 woms1 woms0 write: reset: 0 0 0 0 0 0 0 0 module base + $10 bit 7 6 5 4 3 2 1 bit 0 read: ptg7 ptg6 ptg5 ptg4 ptg3 ptg2 ptg1 ptg0 write: emac mii_rxer mii_rxdv mii_rxclk mii_rxd3 mii_rxd2 mii_rxd1 mii_rxd0 kwu kwg reset: 0 0 0 0 0 0 0 chapter 3 port integration module (pim9ne64v1) mc9s12ne64 data sheet, rev. 1.1 120 freescale semiconductor 3.3.2.3.2 input register (ptig) figure 3-16. port g input register (ptig) read:anytime. write:never, writes to this register have no effect. this register always reads back the status of the associated pins. this also can be used to detect overload or short circuit conditions on output pins. 3.3.2.3.3 data direction register (ddrg) figure 3-17. port g data direction register (ddrg) read:anytime. write:anytime. this register con?ures each port g pin as either input or output. ddrg[7:0] ?data direction port g 1 = associated pin is configured as output. 0 = associated pin is configured as input. if the emac mii external interface is enabled, the pins g[6:0] are forced to be inputs and ddrg has no effect on the them. please refer to the emac block description chapter for details. the ddrg bits revert to controlling the i/o direction of a pin when the emac mii external interface is disabled. due to internal synchronization circuits, it can take up to 2 bus cycles until the correct value is read on ptg or ptig registers, when changing the ddrg register. module base + $11 bit 7 6 5 4 3 2 1 bit 0 read: ptig7 ptig6 ptig5 ptig4 ptig3 ptig2 ptig1 ptig0 write: reset: = reserved or unimplemented module base + $12 bit 7 6 5 4 3 2 1 bit 0 read: ddrg7 ddrg6 ddrg5 ddrg4 ddrg3 ddrg2 ddrg1 ddrg0 write: reset: 0 0 0 0 0 0 0 0 memory map and register descriptions mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 121 3.3.2.3.4 reduced drive register (rdrg) figure 3-18. port g reduced drive register (rdrg) read:anytime. write:anytime. this register con?ures the drive strength of each port g output pin as either full or reduced. if the port is used as input these bits are ignored. rdrg[7:0] ?reduced drive port g 1 = associated pin drives at about 1/3 of the full drive strength. 0 = full drive strength at output. 3.3.2.3.5 pull device enable register (perg) figure 3-19. port g pull device enable register (perg) read:anytime. write:anytime. this register con?ures whether a pull-up or a pull-down device is activated, if the port is used as input. these bits have no effect if the port is used as output. out of reset no pull device is enabled. perg[7:0] ?pull device enable port g 1 = either a pull-up or pull-down device is enabled. 0 = pull-up or pull-down device is disabled. 3.3.2.3.6 polarity select register (ppsg) figure 3-20. port g polarity select register (ppsg) module base + $13 bit 7 6 5 4 3 2 1 bit 0 read: rdrg7 rdrg6 rdrg5 rdrg4 rdrg3 rdrg2 rdrg1 rdrg0 write: reset: 0 0 0 0 0 0 0 0 module base + $14 bit 7 6 5 4 3 2 1 bit 0 read: perg7 perg6 perg5 perg4 perg3 perg2 perg1 perg0 write: reset: 0 0 0 0 0 0 0 0 module base + $15 bit 7 6 5 4 3 2 1 bit 0 read: ppsg7 ppsg6 ppsg5 ppsg4 ppsg3 ppsg2 ppsg1 ppsg0 write: reset: 0 0 0 0 0 0 0 0 chapter 3 port integration module (pim9ne64v1) mc9s12ne64 data sheet, rev. 1.1 122 freescale semiconductor read:anytime. write:anytime. this register selects whether a pull-down or a pull-up device is connected to the pin. ppsg[7:0] ?pull select port g 1 = rising edge on the associated port g pin sets the associated flag bit in the pifg register. a pull-down device is connected to the associated port g pin, if enabled by the associated bit in register perg and if the port is used as input. 0 = falling edge on the associated port g pin sets the associated flag bit in the pifg register. a pull-up device is connected to the associated port g pin, if enabled by the associated bit in register perg and if the port is used as input. 3.3.2.3.7 interrupt enable register (pieg) figure 3-21. port g interrupt enable register (pieg) read:anytime. write:anytime. this register disables or enables on a per pin basis the edge sensitive external interrupt associated with port g. pieg[7:0] ?interrupt enable port g 1 = interrupt is enabled. 0 = interrupt is disabled (interrupt flag masked). 3.3.2.3.8 interrupt flag register (pifg) figure 3-22. port g interrupt flag register (pifg) read:anytime. write:anytime. each ?g is set by an active edge on the associated input pin. this could be a rising or a falling edge based on the state of the ppsg register. to clear this ?g, write a ? to the corresponding bit in the pifg register. writing a ??has no effect. module base + $16 bit 7 6 5 4 3 2 1 bit 0 read: pieg7 pieg6 pieg5 pieg4 pieg3 pieg2 pieg1 pieg0 write: reset: 0 0 0 0 0 0 0 0 module base + $17 bit 7 6 5 4 3 2 1 bit 0 read: pifg7 pifg6 pifg5 pifg4 pifg3 pifg2 pifg1 pifg0 write: reset: 0 0 0 0 0 0 0 0 memory map and register descriptions mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 123 pifg[7:0] ?interrupt flags port g 1 = active edge on the associated bit has occurred (an interrupt will occur if the associated enable bit is set). writing a ??clears the associated flag. 0 = no active edge pending. writing a ??has no effect. 3.3.2.4 port h registers 3.3.2.4.1 i/o register (pth) figure 3-23. port h i/o register (pth) read:anytime. write:anytime. if the data direction bits of the associated i/o pins are set to 1, a read returns the value of the port register, otherwise the value at the pins is read . the emac mii external interface takes precedence over general-purpose i/o function if the emac module is enabled in external phy mode. if the emac mii external interface is enabled ph[6:0] pins become mii_txer, mii_txen, mii_txclk, mii_txd[3:0]. please refer to the emac block description chapter for details. 3.3.2.4.2 input register (ptih) figure 3-24. port h input register (ptih) read:anytime. write:never, writes to this register have no effect. module base + $18 bit 7 6 5 4 3 2 1 bit 0 read: 0 pth6 pth5 pth4 pth3 pth2 pth1 pth0 write: emac mii_txer mii_txen mii_txclk mii_txd3 mii_txd2 mii_txd1 mii_txd0 kwu kwh reset: 0 0 0 0 0 0 0 = reserved or unimplemented module base + $19 bit 7 6 5 4 3 2 1 bit 0 read: 0 ptih6 ptih5 ptih4 ptih3 ptih2 ptih1 ptih0 write: reset: = reserved or unimplemented chapter 3 port integration module (pim9ne64v1) mc9s12ne64 data sheet, rev. 1.1 124 freescale semiconductor this register always reads back the status of the associated pins. this can be also used to detect overload or short circuit conditions on output pins. 3.3.2.4.3 data direction register (ddrh) figure 3-25. port h data direction register (ddrh) read:anytime. write:anytime. this register con?ures each port h pin as either input or output. ddrh[6:0] ?data direction port h 1 = associated pin is configured as output. 0 = associated pin is configured as input. due to internal synchronization circuits, it can take up to 2 bus cycles until the correct value is read on pth or ptih registers, when changing the ddrh register. if the emac mii external interface is enabled, pins ph[6:0] become mii_txer, mii_txen, mii_txclk, mii_txd[3:0]. in that case, ddrh[6:0] bits have no effect on their i/o direction. 3.3.2.4.4 reduced drive register (rdrh) figure 3-26. port h reduced drive register (rdrh) read:anytime. write:anytime. this register con?ures the drive strength of each port h output pin as either full or reduced. if the port is used as input this bit is ignored. rdrh[6:0] ?reduced drive port h 1 = associated pin drives at about 1/3 of the full drive strength. 0 = full drive strength at output. module base + $1a bit 7 6 5 4 3 2 1 bit 0 read: 0 ddrh6 ddrh5 ddrh4 ddrh3 ddrh2 ddrh1 ddrh0 write: reset: 0 0 0 0 0 0 0 = reserved or unimplemented module base + $1b bit 7 6 5 4 3 2 1 bit 0 read: 0 rdrh6 rdrh5 rdrh4 rdrh3 rdrh2 rdrh1 rdrh0 write: reset: 0 0 0 0 0 0 0 = reserved or unimplemented memory map and register descriptions mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 125 3.3.2.4.5 pull device enable register (perh) figure 3-27. port h pull device enable register (perh) read:anytime. write:anytime. this register con?ures whether a pull-up or a pull-down device is activated, if the port is used as input. these bits have no effect if the port is used as output. out of reset no pull device is enabled. perh[6:0] ?pull device enable port h 1 = either a pull-up or pull-down device is enabled. 0 = pull-up or pull-down device is disabled. 3.3.2.4.6 polarity select register (ppsh) figure 3-28. port h polarity select register (ppsh) read:anytime. write:anytime. this register serves a dual purpose by selecting the polarity of the active interrupt edge as well as selecting a pull-up or pull-down device if enabled. ppsh[6:0] ?pull select port h 1 = rising edge on the associated port h pin sets the associated flag bit in the pifh register.a pull-down device is connected to the associated port h pin, if enabled by the associated bit in register perh and if the port is used as input. 0 = falling edge on the associated port h pin sets the associated flag bit in the pifh register.a pull-up device is connected to the associated port h pin, if enabled by the associated bit in register perh and if the port is used as input. module base + $1c bit 7 6 5 4 3 2 1 bit 0 read: 0 perh6 perh5 perh4 perh3 perh2 perh1 perh0 write: reset: 0 0 0 0 0 0 0 = reserved or unimplemented module base + $1d bit 7 6 5 4 3 2 1 bit 0 read: 0 ppsh6 ppsh5 ppsh4 ppsh3 ppsh2 ppsh1 ppsh0 write: reset: 0 0 0 0 0 0 0 = reserved or unimplemented chapter 3 port integration module (pim9ne64v1) mc9s12ne64 data sheet, rev. 1.1 126 freescale semiconductor 3.3.2.4.7 interrupt enable register (pieh) figure 3-29. port h interrupt enable register (pieh) read:anytime. write:anytime. this register disables or enables on a per pin basis the edge sensitive external interrupt associated with port h. pieh[6:0] ?interrupt enable port h 1 = interrupt is enabled. 0 = interrupt is disabled (interrupt flag masked). 3.3.2.4.8 interrupt flag register (pifh) figure 3-30. port h interrupt flag register (pifh) read:anytime. write:anytime. each ?g is set by an active edge on the associated input pin. this could be a rising or a falling edge based on the state of the ppsh register. to clear this ?g, write a ? to the corresponding bit in the pifh register. writing a ??has no effect. pifh[6:0] ?interrupt flags port h 1 = active edge on the associated bit has occurred (an interrupt will occur if the associated enable bit is set). writing a ??clears the associated flag. 0 = no active edge pending. writing a ??has no effect. module base + $1e bit 7 6 5 4 3 2 1 bit 0 read: 0 pieh6 pieh5 pieh4 pieh3 pieh2 pieh1 pieh0 write: reset: 0 0 0 0 0 0 0 = reserved or unimplemented module base + $1f bit 7 6 5 4 3 2 1 bit 0 read: 0 pifh6 pifh5 pifh4 pifh3 pifh2 pifh1 pifh0 write: reset: 0 0 0 0 0 0 0 = reserved or unimplemented memory map and register descriptions mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 127 3.3.2.5 port j registers 3.3.2.5.1 i/o register (ptj) figure 3-31. port j i/o register (ptj) read:anytime. write:anytime. if the data direction bits of the associated i/o pins are set to 1, a read returns the value of the port register, otherwise the value at the pins is read. the emac mii external interface and iic take precedence over general-purpose i/o function. if the emac mii external interface is enabled in external phy mode, pj[3:0] pins become mii_mdc, mii_mdio, mii_crs, mii_col. if iic is enabled, pj[7:6] pins become iic_sda and iic_scl. please refer to the emac and iic block description chapters for details. 3.3.2.5.2 input register (ptij) figure 3-32. port j input register (ptij) read:anytime. write: writes to this register have no effect. this register always reads back the status of the associated pins. this can be used to detect overload or short circuit conditions on output pins. module base + $20 bit 7 6 5 4 3 2 1 bit 0 read: ptj7 ptj6 0 0 ptj3 ptj2 ptj1 ptj0 write: emac mii_col mii_crs mii_mdio mii_mdc iic iic_scl iicsda kwu kwj kwj reset: 0 0 0 0 0 0 = reserved or unimplemented module base + $21 bit 7 6 5 4 3 2 1 bit 0 read: ptij7 ptij6 0 0 ptij3 ptij2 ptij1 ptij0 write: reset: = reserved or unimplemented chapter 3 port integration module (pim9ne64v1) mc9s12ne64 data sheet, rev. 1.1 128 freescale semiconductor 3.3.2.5.3 data direction register (ddrj) figure 3-33. port j data direction register (ddrj) read:anytime. write:anytime. this register con?ures port pins j[7:6]and pj[3:0] as either input or output. ddrj[7:6][3:0] ?data direction port j 1 = associated pin is configured as output. 0 = associated pin is configured as input. due to internal synchronization circuits, it can take up to 2 bus cycles until the correct value is read on ptj or ptij registers, when changing the ddrj register. if the iic is enabled, it controls the direction of scl and sda and the corresponding ddrj[7:6] bits have no effect on their i/o direction. refer to the iic block description chapter for details. if the emac mii external interface is enabled, it controls the direction of mdc, mdio, crs and col and the corresponding ddrj[3:0] bits have no effect on their i/o direction. refer to the emac block description chapter for details. 3.3.2.5.4 reduced drive register (rdrj) figure 3-34. port j reduced drive register (rdrj) read:anytime. write:anytime. this register con?ures the drive strength of each port j output pin as either full or reduced. if the port is used as input this bit is ignored. rdrj[7:6][3:0] ?reduced drive port j 1 = associated pin drives at about 1/3 of the full drive strength. 0 = full drive strength at output. module base + $22 bit 7 6 5 4 3 2 1 bit 0 read: ddrj7 ddrj6 0 0 ddrj3 ddrj2 ddrj1 ddrj0 write: reset: 0 0 0 0 0 0 = reserved or unimplemented module base + $23 bit 7 6 5 4 3 2 1 bit 0 read: rdrj7 rdrj6 0 0 rdrj3 rdrj2 rdrj1 rdrj0 write: reset: 0 0 0 0 0 0 = reserved or unimplemented memory map and register descriptions mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 129 3.3.2.5.5 pull device enable register (perj) figure 3-35. port j pull device enable register (perj) read:anytime. write:anytime. this register con?ures whether a pull-up or a pull-down device is activated, if the port is used as input. this bit has no effect if the port is used as output. out of reset pull-up device is enabled for bits pj[7:6] and disabled for bits pj[3:0]. perj[7:6][3:0] ?pull device enable port j 1 = either a pull-up or pull-down device is enabled. 0 = pull-up or pull-down device is disabled. 3.3.2.5.6 polarity select register (ppsj) figure 3-36. port j polarity select register (ppsj) read:anytime. write:anytime. this register serves a dual purpose by selecting the polarity of the active interrupt edge as well as selecting a pull-up or pull-down device if enabled. ppsj[7:6][3:0] ?polarity select port j 1 = rising edge on the associated port j pin sets the associated flag bit in the pifj register. a pull-down device is connected to the associated port j pin, if enabled by the associated bit in register perj and if the port is used as input. 0 = falling edge on the associated port j pin sets the associated flag bit in the pifj register. a pull-up device is connected to the associated port j pin, if enabled by the associated bit in register perj and if the port is used as input. module base + $24 bit 7 6 5 4 3 2 1 bit 0 read: perj7 perj6 0 0 perj3 perj2 perj1 perj0 write: reset: 1 1 0 0 0 0 = reserved or unimplemented module base + $25 bit 7 6 5 4 3 2 1 bit 0 read: ppsj7 ppsj6 0 0 ppsj3 ppsj2 ppsj1 ppsj0 write: reset: 0 0 0 0 0 0 = reserved or unimplemented chapter 3 port integration module (pim9ne64v1) mc9s12ne64 data sheet, rev. 1.1 130 freescale semiconductor 3.3.2.5.7 interrupt enable register (piej) figure 3-37. port j interrupt enable register (piej) read:anytime. write:anytime. this register disables or enables on a per pin basis the edge sensitive external interrupt associated with port j. piej[7:6][3:0]?interrupt enable port j 1 = interrupt is enabled. 0 = interrupt is disabled (interrupt flag masked). 3.3.2.5.8 interrupt flag register (pifj) figure 3-38. port j interrupt flag register (pifj) read:anytime. write:anytime. each ?g is set by an active edge on the associated input pin. this could be a rising or a falling edge based on the state of the ppsj register. to clear this ?g, write ? to the corresponding bit in the pifj register. writing a ??has no effect. pifj[7:6][3:0] ?interrupt flags port j 1 = active edge on the associated bit has occurred (an interrupt will occur if the associated enable bit is set). writing a ??clears the associated flag. 0 = no active edge pending. writing a ??has no effect. module base + $26 bit 7 6 5 4 3 2 1 bit 0 read: piej7 piej6 0 0 piej3 piej2 piej1 piej0 write: reset: 0 0 0 0 0 0 = reserved or unimplemented module base + $27 bit 7 6 5 4 3 2 1 bit 0 read: pifj7 pifj6 0 0 pifj3 pifj2 pifj1 pifj0 write: reset: 0 0 0 0 0 0 = reserved or unimplemented memory map and register descriptions mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 131 3.3.2.6 port l registers 3.3.2.6.1 i/o register (ptl) figure 3-39. port l i/o register (ptl) read:anytime. write:anytime. if the data direction bits of the associated i/o pins are set to 1, a read returns the value of the port register, otherwise the value at the pins is read. the ephy led drive takes precedence over general-purpose i/o function if the ephyctl0 leden bit is enabled. with the leden bit set, ptl[4:0] become colled, dupled, spdled, lnkled, and actled. refer to ephy block description chapter for more detail. 3.3.2.6.2 input register (ptil) figure 3-40. port l input register (ptil) read:anytime. write:never, writes to this register have no effect. this register always reads back the status of the associated pins. this also can be used to detect overload or short circuit conditions on output pins. module base + $28 bit 7 6 5 4 3 2 1 bit 0 read: 0 ptl6 ptl5 ptl4 ptl3 ptl2 ptl1 ptl0 write: phy colled dupled spdled lnkled actled reset: 0 0 0 0 0 0 0 = reserved or unimplemented module base + $29 bit 7 6 5 4 3 2 1 bit 0 read: 0 ptil6 ptil5 ptil4 ptil3 ptil2 ptil1 ptil0 write: reset: = reserved or unimplemented chapter 3 port integration module (pim9ne64v1) mc9s12ne64 data sheet, rev. 1.1 132 freescale semiconductor 3.3.2.6.3 data direction register (ddrl) figure 3-41. port l data direction register (ddrl) read:anytime. write:anytime. ddrl[6:0] ?data direction port l 1 = associated pin is configured as output. 0 = associated pin is configured as input. this register con?ures each port l pin as either input or output. if ephy port status leds are enabled, pins pl[4:0] are forced to be outputs and this register has no effect on their directions. refer to the ephy block description chapter for more information. due to internal synchronization circuits, it can take up to 2 bus cycles until the correct value is read on ptl or ptil registers, when changing the ddrl register. 3.3.2.6.4 reduced drive register (rdrl) figure 3-42. port l reduced drive register (rdrl) read:anytime. write:anytime. this register con?ures the drive strength of each port l output pin as either full or reduced. if the port is used as input this bit is ignored. rdrl[6:0] ?reduced drive port l 1 = associated pin drives at about 1/3 of the full drive strength. 0 = full drive strength at output. module base + $2a bit 7 6 5 4 3 2 1 bit 0 read: 0 ddrl6 ddrl5 ddrl4 ddrl3 ddrl2 ddrl1 ddrl0 write: reset: 0 0 0 0 0 0 0 = reserved or unimplemented module base + $2b bit 7 6 5 4 3 2 1 bit 0 read: 0 rdrl6 rdrl5 rdrl4 rdrl3 rdrl2 rdrl1 rdrl0 write: reset: 0 0 0 0 0 0 0 = reserved or unimplemented memory map and register descriptions mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 133 3.3.2.6.5 pull device enable register (perl) figure 3-43. port l pull device enable register (perl) read:anytime. write:anytime. this register con?ures whether a pull-up or a pull-down device is activated, if the port is used as input or as output in wired-or (open drain) mode. these bits have no effect if the port is used as push-pull output. out of reset a pull-up device is enabled. perl[6:0] ?pull device enable port l 1 = either a pull-up or pull-down device is enabled. 0 = pull-up or pull-down device is disabled. 3.3.2.6.6 polarity select register (ppsl) figure 3-44. port l polarity select register (ppsl) read:anytime. write:anytime. this register selects whether a pull-down or a pull-up device is connected to the pin. ppsl[6:0] ?pull select port l 1 = a pull-down device is connected to the associated port l pin, if enabled by the associated bit in register perl and if the port is used as input. 0 = a pull-up device is connected to the associated port l pin, if enabled by the associated bit in register perl and if the port is used as input or as wired-or output. module base + $2c bit 7 6 5 4 3 2 1 bit 0 read: 0 perl6 perl5 perl4 perl3 perl2 perl1 perl0 write: reset: 1 1 1 1 1 1 1 = reserved or unimplemented module base + $2d bit 7 6 5 4 3 2 1 bit 0 read: 0 ppsl6 ppsl5 ppsl4 ppsl3 ppsl2 ppsl1 ppsl0 write: reset: 0 0 0 0 0 0 0 = reserved or unimplemented chapter 3 port integration module (pim9ne64v1) mc9s12ne64 data sheet, rev. 1.1 134 freescale semiconductor 3.3.2.6.7 wired-or mode register (woml) figure 3-45. port l wired-or mode register (woml) read:anytime. write:anytime. this register con?ures the output pins as wired-or. if enabled the output is driven active low only (open-drain). a logic level of ??is not driven. this bit has no effect on pins used as inputs. woml[6:0] ?wired-or mode port l 1 = open-drain mode enabled for output buffers. 0 = open-drain mode disabled for output buffers. 3.4 functional description each pin can act as general-purpose i/o. in addition the pin can act as an output from a peripheral module or an input to a peripheral module. a set of con?uration registers is common to all ports. all registers can be written at any time, however a speci? con?uration might not become active. example: selecting a pull-up resistor. this resistor does not become active while the port is used as a push-pull output. 3.4.1 i/o register this register holds the value driven out to the pin if the port is used as a general-purpose i/o. writing to this register has only an effect on the pin if the port is used as general-purpose output. when reading this address, the value of the pins are returned if the data direction register bits are set to 0. if the data direction register bits are set to 1, the contents of the i/o register is returned. this is independent of any other con?uration ( figure 3-46 ). 3.4.2 input register this is a read-only register and always returns the value of the pin ( figure 3-46 ). data direction register address offset: $__2e bit 7 6 5 4 3 2 1 bit 0 read: 0 woml6 woml5 woml4 woml3 woml2 woml1 woml0 write: reset: 0 0 0 0 0 0 0 = reserved or unimplemented functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 135 this register de?es whether the pin is used as an input or an output. if a peripheral module controls the pin the contents of the data direction register is ignored ( figure 3-46 ). figure 3-46. illustration of i/o pin functionality 3.4.3 reduced drive register if the port is used as an output the register allows the con?uration of the drive strength. 3.4.4 pull device enable register this register turns on a pull-up or pull-down device. it becomes only active if the pin is used as an input or as a wired-or output. 3.4.5 polarity select register this register selects either a pull-up or pull-down device if enabled. it becomes only active if the pin is used as an input or wired-or output. a pull-up device can also be activated if the pin is used as a wired-or output. 3.4.6 port t this port is associated with the standard timer. in all modes, port t pins pt[7:4] can be used for either general-purpose i/o or standard timer i/o. during reset, port t pins are con?ured as high-impedance inputs. pt ddr output enable module enable 1 0 1 1 0 0 pad pti data out module chapter 3 port integration module (pim9ne64v1) mc9s12ne64 data sheet, rev. 1.1 136 freescale semiconductor 3.4.7 port s this port is associated with the serial sci and spi modules. port s pins ps[7:0] can be used either for general-purpose i/o, or with the sci0, sci1, and spi subsystems. during reset, port s pins are con?ured as inputs with pull-up. 3.4.8 port g this port is associated with the emac module. port g pins pg[7:0] can be used either for general-purpose i/o or with the emac subsystems. further the keypad wake-up function is implemented on pins g[7:0]. during reset, port g pins are con?ured as high-impedance inputs. 3.4.8.1 interrupts port g offers eight general-purpose i/o pins with edge triggered interrupt capability in wired-or fashion. the interrupt enable as well as the sensitivity to rising or falling edges can be individually con?ured on per pin basis. all eight bits/pins share the same interrupt vector. interrupts can be used with the pins con?ured as inputs or outputs. an interrupt is generated when a bit in the port interrupt ?g register and its corresponding port interrupt enable bit are both set. this external interrupt feature is capable to wake up the cpu when it is in stop or wait mode. a digital ?ter on each pin prevents pulses ( figure 3-48 ) shorter than a speci?d time from generating an interrupt. the minimum time varies over process conditions, temperature and voltage ( figure 3-47 and table 3-4 ). figure 3-47. interrupt glitch filter on port g, h, and j (pps=0) glitch, ?tered out, no interrupt ?g set valid pulse, interrupt ?g set t pign t pval functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 137 figure 3-48. pulse illustration a valid edge on input is detected if 4 consecutive samples of a passive level are followed by 4 consecutive samples of an active level directly or indirectly. the ?ters are continuously clocked by the bus clock in run and wait mode. in stop mode the clock is generated by a single rc oscillator in the port integration module. to maximize current saving the rc oscillator runs only if the following condition is true on any pin: sample count <= 4 and port interrupt enabled (pie=1) and port interrupt ?g not set (pif=0). 3.4.9 port h the emac module is connected to port h. port h pins ph[6:0] can be used either for general-purpose i/o or with the emac subsystems. further the keypad wake-up function is implemented on pins h[6:0]. port h offers the same interrupt features as on port g. during reset, port h pins are con?ured as high-impedance inputs. 3.4.10 port j the emac and iic modules are connected to port j. port j pins pj[7:6] can be used either for general-purpose i/o or with the iic subsystem. port j pins pj[3:0] can be used either for general-purpose i/o or with the emac subsystems. further the keypad wake-up function is implemented on pins h[6:0]. port j offers the same interrupt features as on port g. table 3-4. pulse detection criteria pulse mode stop stop 1 1 these values include the spread of the oscillator frequency over temperature, voltage and process. unit unit ignored t pign <= 3 bus clocks t pign <= 3.2 s uncertain 3 < t pulse < 4 bus clocks 3.2 < t pulse < 10 s valid t pval >= 4 bus clocks t pval >= 10 s t pulse chapter 3 port integration module (pim9ne64v1) mc9s12ne64 data sheet, rev. 1.1 138 freescale semiconductor if iic takes precedence thepj[7:6] pins become iic open drain output pins. during reset, pins pj[7:6] are con?ured as inputs with pull-ups and pins pj[3:0] are con?ured as high-impedance inputs. 3.4.11 port l in all modes, port l pins pl[6:0] can be used either for general-purpose i/o or with the ephy subsystem. during reset, port l pins are con?ured as inputs with pull-ups. 3.4.12 port a, b, e and bkgd pin all port and pin logic is located in the core module. please refer to mebi block description chapter for details. 3.4.13 external pin descriptions all ports start up as general-purpose inputs on reset. 3.4.14 low power options 3.4.14.1 run mode no low power options exist for this module in run mode. 3.4.14.2 wait mode no low power options exist for this module in wait mode. 3.4.14.3 stop mode all clocks are stopped. there are asynchronous paths to generate interrupts from stop on port g, h, and j. 3.5 initialization/application information the reset values of all registers are given in section 3.3, ?emory map and register descriptions . 3.5.1 reset initialization all registers including the data registers get set/reset asynchronously. table 3-5 summarizes the port properties after reset initialization. interrupts mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 139 3.6 interrupts port g, h, and j generate a separate edge sensitive interrupt if enabled. 3.6.1 interrupt sources note vector addresses and their relative interrupt priority are determined at the mcu level. 3.6.2 recovery from stop the pim_9ne64 can generate wake-up interrupts from stop on port g, h, and j. for other sources of external interrupts please refer to the respective block description chapter. table 3-5. port reset state summary port reset states data direction pull mode red. drive wired-or mode interrupt t input hiz disabled n/a n/a s input pull-up disabled disabled n/a g input hiz disabled n/a disabled h input hiz disabled n/a disabled j[7:6] input pull-up disabled n/a disabled j[3:0] input hiz disabled n/a disabled l input pull-up disabled disabled n/a a refer to the mebi block description chapter for details. b e k bkgd pin refer to the bdm block description chapter for details. table 3-6. port integration module interrupt sources interrupt source interrupt flag local enable global (ccr) mask port g pifg[7:0] pieg[7:0] i bit port h pifh[6:0] pieh[6:0] i bit port j pifj[7:6],[3:0] piej[7:6],[3:0] i bit chapter 3 port integration module (pim9ne64v1) mc9s12ne64 data sheet, rev. 1.1 140 freescale semiconductor mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 141 chapter 4 clocks and reset generator (crgv4) 4.1 introduction this speci?ation describes the function of the clocks and reset generator (crgv4). 4.1.1 features the main features of this block are: phase-locked loop (pll) frequency multiplier reference divider automatic bandwidth control mode for low-jitter operation automatic frequency lock detector cpu interrupt on entry or exit from locked condition self-clock mode in absence of reference clock system clock generator clock quality check clock switch for either oscillator- or pll-based system clocks user selectable disabling of clocks during wait mode for reduced power consumption computer operating properly (cop) watchdog timer with time-out clear window system reset generation from the following possible sources: power-on reset low voltage reset refer to the device overview section for availability of this feature. cop reset loss of clock reset external pin reset real-time interrupt (rti) chapter 4 clocks and reset generator (crgv4) mc9s12ne64 data sheet, rev. 1.1 142 freescale semiconductor 4.1.2 modes of operation this subsection lists and brie? describes all operating modes supported by the crg. run mode all functional parts of the crg 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 nonzero value. wait mode this mode allows to disable the system and core clocks depending on the con?uration of the individual bits in the clksel register. 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 crgv4 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. 4.1.3 block diagram figure 4-1 shows a block diagram of the crgv4. external signal description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 143 figure 4-1. crg block diagram 4.2 external signal description this section lists and describes the signals that connect off chip. 4.2.1 v ddpll , v sspll ?pll operating voltage, pll ground these pins provides operating voltage (v ddpll ) and ground (v sspll ) for the pll circuitry. this allows the supply voltage to the pll to be independently bypassed. even if pll usage is not required v ddpll and v sspll must be connected properly. 4.2.2 xfc ?pll loop filter pin a passive external loop ?ter must be placed on the xfc pin. the ?ter is a second-order, low-pass ?ter to eliminate the vco input ripple. the value of the external ?ter network and the reference frequency determines the speed of the corrections and the stability of the pll. refer to the device overview chapter for calculation of pll loop ?ter (xfc) components. if pll usage is not required the xfc pin must be tied to v ddpll . crg registers clock and reset cop reset rti pll xfc v ddpll v sspll oscil- extal xtal control bus clock system reset oscillator clock pllclk oscclk core clock clock monitor cm fail clock quality checker reset generator xclks power-on reset low voltage reset 1 cop timeout real-time interrupt pll lock interrupt self-clock mode interrupt lator voltage regulator 1 refer to the device overview section for availability of the low-voltage reset feature. chapter 4 clocks and reset generator (crgv4) mc9s12ne64 data sheet, rev. 1.1 144 freescale semiconductor figure 4-2. pll loop filter connections 4.2.3 reset ?reset pin 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. 4.3 memory map and register de?ition this section provides a detailed description of all registers accessible in the crgv4. 4.3.1 module memory map table 4-1 gives an overview on all crgv4 registers. table 4-1. crgv4 memory map address offset use access 0x0000 crg synthesizer register (synr) r/w 0x0001 crg reference divider register (refdv) r/w 0x0002 crg test flags register (ctflg) 1 1 ctflg is intended for factory test purposes only. r/w 0x0003 crg flags register (crgflg) r/w 0x0004 crg interrupt enable register (crgint) r/w 0x0005 crg clock select register (clksel) r/w 0x0006 crg pll control register (pllctl) r/w 0x0007 crg rti control register (rtictl) r/w 0x0008 crg cop control register (copctl) r/w 0x0009 crg force and bypass test register (forbyp) 2 2 forbyp is intended for factory test purposes only. r/w 0x000a crg test control register (ctctl) 3 3 ctctl is intended for factory test purposes only. r/w 0x000b crg cop arm/timer reset (armcop) r/w mcu xfc rs cs v ddpll cp memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 145 note register address = base address + address offset, where the base address is de?ed at the mcu level and the address offset is de?ed at the module level. 4.3.2 register descriptions this section describes in address order all the crgv4 registers and their individual bits. register name bit 7 654321 bit 0 synr r 0 0 syn5 syn4 syn3 syn2 syn1 syn0 w refdv r 0000 refdv3 refdv2 refdv1 refdv0 w ctflg r 00000000 w crgflg r rtif porf lvrf lockif lock track scmif scm w crgint r rtie 00 lockie 00 scmie 0 w clksel r pllsel pstp syswai roawai pllwai cwai rtiwai copwai w pllctl r cme pllon auto acq 0 pre pce scme w rtictl r 0 rtr6 rtr5 rtr4 rtr3 rtr2 rtr1 rtr0 w copctl r wcop rsbck 000 cr2 cr1 cr0 w forbyp r 00000000 w ctctl r 00000000 w = unimplemented or reserved figure 4-3. crg register summary chapter 4 clocks and reset generator (crgv4) mc9s12ne64 data sheet, rev. 1.1 146 freescale semiconductor 4.3.2.1 crg synthesizer register (synr) the synr register controls the multiplication factor of the pll. if the pll is on, the count in the loop divider (synr) register effectively multiplies up the pll clock (pllclk) from the reference frequency by 2 x (synr+1). pllclk will not be below the minimum vco frequency (f scm ). note if pll is selected (pllsel=1), bus clock = pllclk / 2 bus clock must not exceed the maximum operating system frequency. read: anytime write: anytime except if pllsel = 1 note write to this register initializes the lock detector bit and the track detector bit. armcop r 00000000 w bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 76543210 r0 0 syn5 synr syn3 syn2 syn1 syn0 w reset 0 0 0 00000 = unimplemented or reserved figure 4-4. crg synthesizer register (synr) register name bit 7 654321 bit 0 = unimplemented or reserved figure 4-3. crg register summary (continued) pllclk 2xoscclkx synr 1 + () refdv 1 + () ---------------------------------- - = memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 147 4.3.2.2 crg reference divider register (refdv) the refdv register provides a ?er granularity for the pll multiplier steps. the count in the reference divider divides oscclk frequency by refdv + 1. read: anytime write: anytime except when pllsel = 1 note write to this register initializes the lock detector bit and the track detector bit. 4.3.2.3 reserved register (ctflg) this register is reserved for factory testing of the crgv4 module and is not available in normal modes. read: always reads 0x0000 in normal modes write: unimplemented in normal modes note writing to this register when in special mode can alter the crgv4 functionality. 76543210 r0000 refdv3 refdv2 refdv1 refdv0 w reset 0 0 0 00000 = unimplemented or reserved figure 4-5. crg reference divider register (refdv) 76543210 r00000000 w reset 0 0 0 00000 = unimplemented or reserved figure 4-6. crg reserved register (ctflg) chapter 4 clocks and reset generator (crgv4) mc9s12ne64 data sheet, rev. 1.1 148 freescale semiconductor 4.3.2.4 crg flags register (crgflg) this register provides crg status bits and ?gs. read: anytime write: refer to each bit for individual write conditions 76543210 r rtif porf lvrf lockif lock track scmif scm w reset 0 note 1 note 2 00000 1. porf is set to 1 when a power-on reset occurs. unaffected by system reset. 2. lvrf is set to 1 when a low-voltage reset occurs. unaffected by system reset. = unimplemented or reserved figure 4-7. crg flag register (crgflg) table 4-2. crgflg field descriptions field description 7 rtif real-time interrupt flag rtif is set to 1 at the end of the rti period. this ?g can only be cleared by writing a 1. writing a 0 has no effect. if enabled (rtie = 1), rtif causes an interrupt request. 0 rti time-out has not yet occurred. 1 rti time-out has occurred. 6 porf power-on reset flag porf is set to 1 when a power-on reset occurs. this ?g can only be cleared by writing a 1. writing a 0 has no effect. 0 power-on reset has not occurred. 1 power-on reset has occurred. 5 lvrf low-voltage reset flag if low voltage reset feature is not available (see the device overview chapter), lvrf always reads 0. lvrf is set to 1 when a low voltage reset occurs. this ?g can only be cleared by writing a 1. writing a 0 has no effect. 0 low voltage reset has not occurred. 1 low voltage reset has occurred. 4 lockif pll lock interrupt flag lockif is set to 1 when lock status bit changes. this ?g can only be cleared by writing a 1. writing a 0 has no effect.if enabled (lockie = 1), lockif causes an interrupt request. 0 no change in lock bit. 1 lock bit has changed. 3 lock lock status bit lock re?cts the current state of pll lock condition. this bit is cleared in self-clock mode. writes have no effect. 0 pll vco is not within the desired tolerance of the target frequency. 1 pll vco is within the desired tolerance of the target frequency. 2 track track status bit track re?cts the current state of pll track condition. this bit is cleared in self-clock mode. writes have no effect. 0 acquisition mode status. 1 tracking mode status. memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 149 4.3.2.5 crg interrupt enable register (crgint) this register enables crg interrupt requests. read: anytime write: anytime 1 scmif self-clock mode interrupt flag ?scmif is set to 1 when scm status bit changes. this ?g can only be cleared by writing a 1. writing a 0 has no effect. if enabled (scmie=1), scmif causes an interrupt request. 0 no change in scm bit. 1 scm bit has changed. 0 scm self-clock mode status bit ?scm re?cts the current clocking mode. writes have no effect. 0 mcu is operating normally with oscclk available. 1 mcu is operating in self-clock mode with oscclk in an unknown state. all clocks are derived from pllclk running at its minimum frequency f scm . 76543210 r rtie 00 lockie 00 scmie 0 w reset 0 0 0 00000 = unimplemented or reserved figure 4-8. crg interrupt enable register (crgint) table 4-3. crgint field descriptions field description 7 rtie real-time interrupt enable bit 0 interrupt requests from rti are disabled. 1 interrupt will be requested whenever rtif is set. 4 lockie lock interrupt enable bit 0 lock interrupt requests are disabled. 1 interrupt will be requested whenever lockif is set. 1 scmie self-clock mode interrupt enable bit 0 scm interrupt requests are disabled. 1 interrupt will be requested whenever scmif is set. table 4-2. crgflg field descriptions (continued) field description chapter 4 clocks and reset generator (crgv4) mc9s12ne64 data sheet, rev. 1.1 150 freescale semiconductor 4.3.2.6 crg clock select register (clksel) this register controls crg clock selection. refer to figure 4-17 for details on the effect of each bit. read: anytime write: refer to each bit for individual write conditions 76543210 r pllsel pstp syswai roawai pllwai cwai rtiwai copwai w reset 0 0 0 00000 figure 4-9. crg clock select register (clksel) table 4-4. clksel field descriptions field description 7 pllsel pll select bit write anytime. writing a 1 when lock = 0 and auto = 1, or track = 0 and auto = 0 has no effect. this prevents the selection of an unstable pllclk as sysclk. pllsel bit is cleared when the mcu enters self-clock mode, stop mode or wait mode with pllwai bit set. 0 system clocks are derived from oscclk (bus clock = oscclk / 2). 1 system clocks are derived from pllclk (bus clock = pllclk / 2). 6 pstp pseudo-stop bit ?write: anytime ?this bit controls the functionality of the oscillator during stop mode. 0 oscillator is disabled in stop mode. 1 oscillator continues to run in stop mode (pseudo-stop). the oscillator amplitude is reduced. refer to oscillator block description for availability of a reduced oscillator amplitude. note: pseudo-stop allows for faster stop recovery and reduces the mechanical stress and aging of the resonator in case of frequent stop conditions at the expense of a slightly increased power consumption. note: lower oscillator amplitude exhibits lower power consumption but could have adverse effects during any electro-magnetic susceptibility (ems) tests. 5 syswai system clocks stop in wait mode bit ?write: anytime 0 in wait mode, the system clocks continue to run. 1 in wait mode, the system clocks stop. note: rti and cop are not affected by syswai bit. 4 roawai reduced oscillator amplitude in wait mode bit ?write: anytime ?refer to oscillator block description chapter for availability of a reduced oscillator amplitude. if no such feature exists in the oscillator block then setting this bit to 1 will not have any effect on power consumption. 0 normal oscillator amplitude in wait mode. 1 reduced oscillator amplitude in wait mode. note: lower oscillator amplitude exhibits lower power consumption but could have adverse effects during any electro-magnetic susceptibility (ems) tests. 3 pllwai pll stops in wait mode bit write: anytime if pllwai is set, the crgv4 will clear the pllsel bit before entering wait mode. the pllon bit remains set during wait mode but the pll is powered down. upon exiting wait mode, the pllsel bit has to be set manually if pll clock is required. while the pllwai bit is set the auto bit is set to 1 in order to allow the pll to automatically lock on the selected target frequency after exiting wait mode. 0 pll keeps running in wait mode. 1 pll stops in wait mode. 2 cwai core stops in wait mode bit ?write: anytime 0 core clock keeps running in wait mode. 1 core clock stops in wait mode. memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 151 4.3.2.7 crg pll control register (pllctl) this register controls the pll functionality. read: anytime write: refer to each bit for individual write conditions 1 rtiwai rti stops in wait mode bit ?write: anytime 0 rti keeps running in wait mode. 1 rti stops and initializes the rti dividers whenever the part goes into wait mode. 0 copwai cop stops in wait mode bit ?normal modes: write once ?pecial modes: write anytime 0 cop keeps running in wait mode. 1 cop stops and initializes the cop dividers whenever the part goes into wait mode. 76543210 r cme pllon auto acq 0 pre pce scme w reset 1 1 1 10001 = unimplemented or reserved figure 4-10. crg pll control register (pllctl) table 4-5. pllctl field descriptions field description 7 cme clock monitor enable bit ?cme enables the clock monitor. write anytime except when scm = 1. 0 clock monitor is disabled. 1 clock monitor is enabled. slow or stopped clocks will cause a clock monitor reset sequence or self-clock mode. note: operating with cme = 0 will not detect any loss of clock. in case of poor clock quality this could cause unpredictable operation of the mcu. note: in stop mode (pstp = 0) the clock monitor is disabled independently of the cme bit setting and any loss of clock will not be detected. 6 pllon phase lock loop on bit pllon turns on the pll circuitry. in self-clock mode, the pll is turned on, but the pllon bit reads the last latched value. write anytime except when pllsel = 1. 0 pll is turned off. 1 pll is turned on. if auto bit is set, the pll will lock automatically. 5 auto automatic bandwidth control bit ?auto selects either the high bandwidth (acquisition) mode or the low bandwidth (tracking) mode depending on how close to the desired frequency the vco is running. write anytime except when pllwai=1, because pllwai sets the auto bit to 1. 0 automatic mode control is disabled and the pll is under software control, using acq bit. 1 automatic mode control is enabled and acq bit has no effect. 4 acq acquisition bit ?write anytime. if auto=1 this bit has no effect. 0 low bandwidth ?ter is selected. 1 high bandwidth ?ter is selected. table 4-4. clksel field descriptions (continued) field description chapter 4 clocks and reset generator (crgv4) mc9s12ne64 data sheet, rev. 1.1 152 freescale semiconductor 4.3.2.8 crg rti control register (rtictl) this register selects the timeout period for the real-time interrupt. read: anytime write: anytime note a write to this register initializes the rti counter. 2 pre rti enable during pseudo-stop bit ?pre enables the rti during pseudo-stop mode. write anytime. 0 rti stops running during pseudo-stop mode. 1 rti continues running during pseudo-stop mode. note: if the pre bit is cleared the rti dividers will go static while pseudo-stop mode is active. the rti dividers will not initialize like in wait mode with rtiwai bit set. 1 pce cop enable during pseudo-stop bit ?pce enables the cop during pseudo-stop mode. write anytime. 0 cop stops running during pseudo-stop mode 1 cop continues running during pseudo-stop mode note: if the pce bit is cleared the cop dividers will go static while pseudo-stop mode is active. the cop dividers will not initialize like in wait mode with copwai bit set. 0 scme self-clock mode enable bit normal modes: write once ?pecial modes: write anytime scme can not be cleared while operating in self-clock mode (scm=1). 0 detection of crystal clock failure causes clock monitor reset (see section 4.5.1, ?lock monitor reset ?. 1 detection of crystal clock failure forces the mcu in self-clock mode (see section 4.4.7.2, ?elf-clock mode ?. 76543210 r0 rtr6 rtr5 rtr4 rtr3 rtr2 rtr1 rtr0 w reset 0 0 0 00000 = unimplemented or reserved figure 4-11. crg rti control register (rtictl) table 4-6. rtictl field descriptions field description 6:4 rtr[6:4] real-time interrupt prescale rate select bits these bits select the prescale rate for the rti. see table 4-7 . 3:0 rtr[3:0] real-time interrupt modulus counter select bits ?these bits select the modulus counter target value to provide additional granularity. table 4-7 shows all possible divide values selectable by the rtictl register. the source clock for the rti is oscclk. table 4-5. pllctl field descriptions (continued) field description memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 153 table 4-7. rti frequency divide rates rtr[3:0] rtr[6:4] = 000 (off) 001 (2 10 ) 010 (2 11 ) 011 (2 12 ) 100 (2 13 ) 101 (2 14 ) 110 (2 15 ) 111 (2 16 ) 0000 ( 1) off * 2 10 2 11 2 12 2 13 2 14 2 15 2 16 0001 ( 2) off * 2x2 10 2x2 11 2x2 12 2x2 13 2x2 14 2x2 15 2x2 16 0010 ( 3) off * 3x2 10 3x2 11 3x2 12 3x2 13 3x2 14 3x2 15 3x2 16 0011 ( 4) off * 4x2 10 4x2 11 4x2 12 4x2 13 4x2 14 4x2 15 4x2 16 0100 ( 5) off * 5x2 10 5x2 11 5x2 12 5x2 13 5x2 14 5x2 15 5x2 16 0101 ( 6) off * 6x2 10 6x2 11 6x2 12 6x2 13 6x2 14 6x2 15 6x2 16 0110 ( 7) off * 7x2 10 7x2 11 7x2 12 7x2 13 7x2 14 7x2 15 7x2 16 0111 ( 8) off * 8x2 10 8x2 11 8x2 12 8x2 13 8x2 14 8x2 15 8x2 16 1000 ( 9) off * 9x2 10 9x2 11 9x2 12 9x2 13 9x2 14 9x2 15 9x2 16 1001 ( 10) off * 10x2 10 10x2 11 10x2 12 10x2 13 10x2 14 10x2 15 10x2 16 1010 ( 11) off * 11x2 10 11x2 11 11x2 12 11x2 13 11x2 14 11x2 15 11x2 16 1011 ( 12) off * 12x2 10 12x2 11 12x2 12 12x2 13 12x2 14 12x2 15 12x2 16 1100 ( 13) off * 13x2 10 13x2 11 13x2 12 13x2 13 13x2 14 13x2 15 13x2 16 1101 ( 14) off * 14x2 10 14x2 11 14x2 12 14x2 13 14x2 14 14x2 15 14x2 16 1110 ( 15) off * 15x2 10 15x2 11 15x2 12 15x2 13 15x2 14 15x2 15 15x2 16 1111 ( 16) off * 16x2 10 16x2 11 16x2 12 16x2 13 16x2 14 16x2 15 16x2 16 * denotes the default value out of reset.this value should be used to disable the rti to ensure future backwards compatibility. chapter 4 clocks and reset generator (crgv4) mc9s12ne64 data sheet, rev. 1.1 154 freescale semiconductor 4.3.2.9 crg cop control register (copctl) this register controls the cop (computer operating properly) watchdog. read: anytime write: wcop, cr2, cr1, cr0: once in user mode, anytime in special mode write: rsbck: once 76543210 r wcop rsbck 000 cr2 cr1 cr0 w reset 0 0 0 00000 = unimplemented or reserved figure 4-12. crg cop control register (copctl) table 4-8. copctl field descriptions field description 7 wcop window cop mode bit when set, a write to the armcop register must occur in the last 25% of the selected period. a write during the ?st 75% of the selected period will reset the part. as long as all writes occur during this window, 0x0055 can be written as often as desired. as soon as 0x00aa is written after the 0x0055, the time-out logic restarts and the user must wait until the next window before writing to armcop. table 4-9 shows the exact duration of this window for the seven available cop rates. 0 normal cop operation 1 window cop operation 6 rsbck cop and rti stop in active bdm mode bit 0 allows the cop and rti to keep running in active bdm mode. 1 stops the cop and rti counters whenever the part is in active bdm mode. 2:0 cr[2:0] cop watchdog timer rate select ?these bits select the cop time-out rate (see table 4-9 ). the cop time-out period is oscclk period divided by cr[2:0] value. writing a nonzero value to cr[2:0] enables the cop counter and starts the time-out period. a cop counter time-out causes a system reset. this can be avoided by periodically (before time-out) reinitializing the cop counter via the armcop register . table 4-9. cop watchdog rates 1 1 oscclk cycles are referenced from the previous cop time-out reset (writing 0x0055/0x00aa to the armcop register) cr2 cr1 cr0 oscclk cycles to time out 0 0 0 cop disabled 001 2 14 010 2 16 011 2 18 100 2 20 101 2 22 110 2 23 111 2 24 memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 155 4.3.2.10 reserved register (forbyp) note this reserved register is designed for factory test purposes only, and is not intended for general user access. writing to this register when in special modes can alter the crg s functionality. read: always read 0x0000 except in special modes write: only in special modes 4.3.2.11 reserved register (ctctl) note this reserved register is designed for factory test purposes only, and is not intended for general user access. writing to this register when in special test modes can alter the crg s functionality. read: always read 0x0080 except in special modes write: only in special modes 76543210 r00000000 w reset 0 0 0 00000 = unimplemented or reserved figure 4-13. reserved register (forbyp) 76543210 r00000000 w reset 0 0 0 00000 = unimplemented or reserved figure 4-14. reserved register (ctctl) chapter 4 clocks and reset generator (crgv4) mc9s12ne64 data sheet, rev. 1.1 156 freescale semiconductor 4.3.2.12 crg cop timer arm/reset register (armcop) this register is used to restart the cop time-out period. read: always reads 0x0000 write: anytime when the cop is disabled (cr[2:0] = ?00? writing to this register has no effect. when the cop is enabled by setting cr[2:0] nonzero, the following applies: writing any value other than 0x0055 or 0x00aa causes a cop reset. to restart the cop time-out period you must write 0x0055 followed by a write of 0x00aa. other instructions may be executed between these writes but the sequence (0x0055, 0x00aa) must be completed prior to cop end of time-out period to avoid a cop reset. sequences of 0x0055 writes or sequences of 0x00aa writes are allowed. when the wcop bit is set, 0x0055 and 0x00aa writes must be done in the last 25% of the selected time-out period; writing any value in the ?st 75% of the selected period will cause a cop reset. 4.4 functional description this section gives detailed informations on the internal operation of the design. 4.4.1 phase locked loop (pll) the pll is used to run the mcu from a different time base than the incoming oscclk. for increased ?xibility, oscclk can be divided in a range of 1 to 16 to generate the reference frequency. this offers a ?er multiplication granularity. the pll can multiply this reference clock by a multiple of 2, 4, 6,... 126,128 based on the synr register. caution although it is possible to set the two dividers to command a very high clock frequency, do not exceed the speci?d bus frequency limit for the mcu. if (pllsel = 1), bus clock = pllclk / 2 the pll is a frequency generator that operates in either acquisition mode or tracking mode, depending on the difference between the output frequency and the target frequency. the pll can change between acquisition and tracking modes either automatically or manually. 76543210 r00000000 w bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 reset 0 0 0 00000 figure 4-15. armcop register diagram pllclk 2 oscclk synr 1 + [] refdv 1 + [] ---------------------------------- - = functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 157 the vco has a minimum operating frequency, which corresponds to the self-clock mode frequency f scm . figure 4-16. pll functional diagram 4.4.1.1 pll operation the oscillator output clock signal (oscclk) is fed through the reference programmable divider and is divided in a range of 1 to 16 (refdv+1) to output the reference clock. the vco output clock, (pllclk) is fed back through the programmable loop divider and is divided in a range of 2 to 128 in increments of [2 x (synr +1)] to output the feedback clock. see figure 4-16 . the phase detector then compares the feedback clock, with the reference clock. correction pulses are generated based on the phase difference between the two signals. the loop ?ter then slightly alters the dc voltage on the external ?ter capacitor connected to xfc pin, based on the width and direction of the correction pulse. the ?ter can make fast or slow corrections depending on its mode, as described in the next subsection. the values of the external ?ter network and the reference frequency determine the speed of the corrections and the stability of the pll. 4.4.1.2 acquisition and tracking modes the lock detector compares the frequencies of the feedback clock, and the reference clock. therefore, the speed of the lock detector is directly proportional to the ?al reference frequency. the circuit determines the mode of the pll and the lock condition based on this comparison. reduced consumption oscillator extal xtal oscclk pllclk reference programmable divider pdet phase detector refdv <3:0> loop programmable divider syn <5:0> cpump vco lock loop filter xfc pin up down lock detector reference feedback vddpll vddpll/vsspll crystal monitor vddpll/vsspll vdd/vss supplied by: chapter 4 clocks and reset generator (crgv4) mc9s12ne64 data sheet, rev. 1.1 158 freescale semiconductor the pll ?ter can be manually or automatically con?ured into one of two possible operating modes: acquisition mode in acquisition mode, the ?ter can make large frequency corrections to the vco. this mode is used at pll start-up or when the pll has suffered a severe noise hit and the vco frequency is far off the desired frequency. when in acquisition mode, the track status bit is cleared in the crgflg register. tracking mode in tracking mode, the ?ter makes only small corrections to the frequency of the vco. pll jitter is much lower in tracking mode, but the response to noise is also slower. the pll enters tracking mode when the vco frequency is nearly correct and the track bit is set in the crgflg register. the pll can change the bandwidth or operational mode of the loop ?ter manually or automatically. in automatic bandwidth control mode (auto = 1), the lock detector automatically switches between acquisition and tracking modes. automatic bandwidth control mode also is used to determine when the pll clock (pllclk) is safe to use as the source for the system and core clocks. if pll lock interrupt requests are enabled, the software can wait for an interrupt request and then check the lock bit. if cpu interrupts are disabled, software can poll the lock bit continuously (during pll start-up, usually) or at periodic intervals. in either case, only when the lock bit is set, is the pllclk clock safe to use as the source for the system and core clocks. if the pll is selected as the source for the system and core clocks and the lock bit is clear, the pll has suffered a severe noise hit and the software must take appropriate action, depending on the application. the following conditions apply when the pll is in automatic bandwidth control mode (auto = 1): the track bit is a read-only indicator of the mode of the ?ter. the track bit is set when the vco frequency is within a certain tolerance, ? trk , and is clear when the vco frequency is out of a certain tolerance, ? unt . the lock bit is a read-only indicator of the locked state of the pll. the lock bit is set when the vco frequency is within a certain tolerance, ? lock , and is cleared when the vco frequency is out of a certain tolerance, ? unl . cpu interrupts can occur if enabled (lockie = 1) when the lock condition changes, toggling the lock bit. the pll can also operate in manual mode (auto = 0). manual mode is used by systems that do not require an indicator of the lock condition for proper operation. such systems typically operate well below the maximum system frequency (f sys ) and require fast start-up. the following conditions apply when in manual mode: acq is a writable control bit that controls the mode of the ?ter. before turning on the pll in manual mode, the acq bit should be asserted to con?ure the ?ter in acquisition mode. after turning on the pll by setting the pllon bit software must wait a given time (t acq ) before entering tracking mode (acq = 0). after entering tracking mode software must wait a given time (t al ) before selecting the pllclk as the source for system and core clocks (pllsel = 1). functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 159 4.4.2 system clocks generator figure 4-17. system clocks generator the clock generator creates the clocks used in the mcu (see figure 4-17 ). the gating condition placed on top of the individual clock gates indicates the dependencies of different modes (stop, wait) and the setting of the respective con?uration bits. the peripheral modules use the bus clock. some peripheral modules also use the oscillator clock. the memory blocks use the bus clock. if the mcu enters self-clock mode (see section 4.4.7.2, ?elf-clock mode ?, oscillator clock source is switched to pllclk running at its minimum frequency f scm . the bus clock is used to generate the clock visible at the eclk pin. the core clock signal is the clock for the cpu. the core clock is twice the bus clock as shown in figure 4-18 . but note that a cpu cycle corresponds to one bus clock. pll clock mode is selected with pllsel bit in the clksel register. when selected, the pll output clock drives sysclk for the main system including the cpu and peripherals. the pll cannot be turned off by clearing the pllon bit, if the pll clock is selected. when pllsel is changed, it takes a maximum oscillator phase lock loop extal xtal sysclk rti oscclk pllclk clock phase generator bus clock clock monitor 1 0 pllsel or scm 2 core clock cop oscillator oscillator = clock gate gating condition wait(cwai,syswai), stop wait(rtiwai), stop( pstp, pre), rti enable wait(copwai), stop( pstp, pce), cop enable wait(syswai), stop stop( pstp) 1 0 scm wait(syswai), stop clock clock (running during pseudo-stop mode chapter 4 clocks and reset generator (crgv4) mc9s12ne64 data sheet, rev. 1.1 160 freescale semiconductor of 4 oscclk plus 4 pllclk cycles to make the transition. during the transition, all clocks freeze and cpu activity ceases. figure 4-18. core clock and bus clock relationship 4.4.3 clock monitor (cm) if no oscclk edges are detected within a certain time, the clock monitor within the oscillator block generates a clock monitor fail event. the crgv4 then asserts self-clock mode or generates a system reset depending on the state of scme bit. if the clock monitor is disabled or the presence of clocks is detected no failure is indicated by the oscillator block.the clock monitor function is enabled/disabled by the cme control bit. 4.4.4 clock quality checker the clock monitor performs a coarse check on the incoming clock signal. the clock quality checker provides a more accurate check in addition to the clock monitor. a clock quality check is triggered by any of the following events: power-on reset (por) low voltage reset (lvr) wake-up from full stop mode (exit full stop) clock monitor fail indication (cm fail) a time window of 50000 vco clock cycles 1 is called check window . a number greater equal than 4096 rising oscclk edges within a check window is called osc ok . note that osc ok immediately terminates the current check window . see figure 4-19 as an example. 1. vco clock cycles are generated by the pll when running at minimum frequency f scm . core clock: bus clock / eclk functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 161 figure 4-19. check window example the sequence for clock quality check is shown in figure 4-20 . figure 4-20. sequence for clock quality check note remember that in parallel to additional actions caused by self-clock mode or clock monitor reset 1 handling the clock quality checker continues to check the oscclk signal. 1. a clock monitor reset will always set the scme bit to logical? 12 49999 50000 vco clock check window 12345 4095 4096 3 oscclk osc ok check window osc ok ? scm active? switch to oscclk exit scm clock ok num=0 num<50 ? num=num+1 yes no yes scme=1 ? no enter scm scm active? yes clock monitor reset no yes no num=50 yes no por exit full stop cm fail lv r chapter 4 clocks and reset generator (crgv4) mc9s12ne64 data sheet, rev. 1.1 162 freescale semiconductor note the clock quality checker enables the pll and the voltage regulator (vreg) anytime a clock check has to be performed. an ongoing clock quality check could also cause a running pll (f scm ) and an active vreg during pseudo-stop mode or wait mode 4.4.5 computer operating properly watchdog (cop) figure 4-21. clock chain for cop the cop (free running watchdog timer) enables the user to check that a program is running and sequencing properly. the cop is disabled out of reset. when the cop is being used, software is responsible for keeping the cop from timing out. if the cop times out it is an indication that the software is no longer being executed in the intended sequence; thus a system reset is initiated (see section 4.5.2, ?omputer operating properly watchdog (cop) reset ).?the cop runs with a gated oscclk (see section figure 4-21., ?lock chain for cop ?. three control bits in the copctl register allow selection of seven cop time-out periods. when cop is enabled, the program must write 0x0055 and 0x00aa (in this order) to the armcop register during the selected time-out period. as soon as this is done, the cop time-out period is restarted. if the program fails to do this and the cop times out, the part will reset. also, if any value other than 0x0055 or 0x00aa is written, the part is immediately reset. windowed cop operation is enabled by setting wcop in the copctl register. in this mode, writes to the armcop register to clear the cop timer must occur in the last 25% of the selected time-out period. a premature write will immediately reset the part. if pce bit is set, the cop will continue to run in pseudo-stop mode. oscclk cr[2:0] cop timeout 0:0:0 0:0:1 0:1:0 0:1:1 1:0:0 1:0:1 1:1:0 1:1:1 4 4 2 4 2 16384 4 cr[2:0] = clock gate wait(copwai), stop( pstp, pce), cop enable gating condition functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 163 4.4.6 real-time interrupt (rti) the rti can be used to generate a hardware interrupt at a ?ed periodic rate. if enabled (by setting rtie=1), this interrupt will occur at the rate selected by the rtictl register. the rti runs with a gated oscclk (see section figure 4-22., ?lock chain for rti ?. at the end of the rti time-out period the rtif ?g is set to 1 and a new rti time-out period starts immediately. a write to the rtictl register restarts the rti time-out period. if the pre bit is set, the rti will continue to run in pseudo-stop mode. . figure 4-22. clock chain for rti 4.4.7 modes of operation 4.4.7.1 normal mode the crgv4 block behaves as described within this speci?ation in all normal modes. 4.4.7.2 self-clock mode the vco has a minimum operating frequency, f scm . if the external clock frequency is not available due to a failure or due to long crystal start-up time, the bus clock and the core clock are derived from the vco oscclk rtr[6:4] 0:0:0 0:0:1 0:1:0 0:1:1 1:0:0 1:0:1 1:1:0 1:1:1 2 2 2 2 2 2 counter (rtr[3:0]) 4-bit modulus 1024 rti timeout = clock gate wait(rtiwai), stop( pstp, pre), rti enable gating condition chapter 4 clocks and reset generator (crgv4) mc9s12ne64 data sheet, rev. 1.1 164 freescale semiconductor running at minimum operating frequency; this mode of operation is called self-clock mode. this requires cme = 1 and scme = 1. if the mcu was clocked by the pll clock prior to entering self-clock mode, the pllsel bit will be cleared. if the external clock signal has stabilized again, the crg will automatically select oscclk to be the system clock and return to normal mode. see section 4.4.4, ?lock quality checker ?for more information on entering and leaving self-clock mode. note in order to detect a potential clock loss, the cme bit should be always enabled (cme=1). if cme bit is disabled and the mcu is con?ured to run on pll clock (pllclk), a loss of external clock (oscclk) will not be detected and will cause the system clock to drift towards the vco s minimum frequency f scm . as soon as the external clock is available again the system clock ramps up to its pll target frequency. if the mcu is running on external clock any loss of clock will cause the system to go static. 4.4.8 low-power operation in run mode the rti can be stopped by setting the associated rate select bits to 0. the cop can be stopped by setting the associated rate select bits to 0. 4.4.9 low-power operation in wait mode the wai instruction puts the mcu in a low power consumption stand-by mode depending on setting of the individual bits in the clksel register. all individual wait mode con?uration bits can be superposed. this provides enhanced granularity in reducing the level of power consumption during wait mode. table 4-10 lists the individual con?uration bits and the parts of the mcu that are affected in wait mode. after executing the wai instruction the core requests the crg to switch mcu into wait mode. the crg then checks whether the pllwai, cwai and syswai bits are asserted (see figure 4-23 ). depending on the con?uration the crg switches the system and core clocks to oscclk by clearing the pllsel bit, disables the pll, disables the core clocks and ?ally disables the remaining system clocks. as soon as all clocks are switched off wait mode is active. table 4-10. mcu con?uration during wait mode pllwai cwai syswai rtiwai copwai roawai pll stopped core stopped stopped system stopped rti stopped cop stopped oscillator reduced 1 1 refer to oscillator block description for availability of a reduced oscillator amplitude. functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 165 figure 4-23. wait mode entry/exit sequence enter wait mode pllwai=1 ? exit wait w. cmreset exit wait w. ext.reset exit wait mode enter scm exit wait mode core req s wait mode. cwai or syswai=1 ? syswai=1 ? clear pllsel, disable pll disable core clocks disable system clocks cme=1 ? int ? cm fail ? scme=1 ? scmie=1 ? continue w. normal op no no no no no no no yes yes yes yes yes no yes yes yes wait mode left due to external reset generate scm interrupt (wakeup from wait) scm=1 ? enter scm no yes chapter 4 clocks and reset generator (crgv4) mc9s12ne64 data sheet, rev. 1.1 166 freescale semiconductor there are ve different scenarios for the crg to restart the mcu from wait mode: external reset clock monitor reset cop reset self-clock mode interrupt real-time interrupt (rti) if the mcu gets an external reset during wait mode active, the crg asynchronously restores all con?uration bits in the register space to its default settings and starts the reset generator. after completing the reset sequence processing begins by fetching the normal reset vector. wait mode is exited and the mcu is in run mode again. if the clock monitor is enabled (cme=1) the mcu is able to leave wait mode when loss of oscillator/external clock is detected by a clock monitor fail. if the scme bit is not asserted the crg generates a clock monitor fail reset (cmreset). the crg s behavior for cmreset is the same compared to external reset, but another reset vector is fetched after completion of the reset sequence. if the scme bit is asserted the crg generates a scm interrupt if enabled (scmie=1). after generating the interrupt the crg enters self-clock mode and starts the clock quality checker (see section 4.4.4, ?lock quality checker ?. then the mcu continues with normal operation.if the scm interrupt is blocked by scmie = 0, the scmif ?g will be asserted and clock quality checks will be performed but the mcu will not wake-up from wait mode. if any other interrupt source (e.g. rti) triggers exit from wait mode the mcu immediately continues with normal operation. if the pll has been powered-down during wait mode the pllsel bit is cleared and the mcu runs on oscclk after leaving wait mode. the software must manually set the pllsel bit again, in order to switch system and core clocks to the pllclk. if wait mode is entered from self-clock mode, the crg will continue to check the clock quality until clock check is successful. the pll and voltage regulator (vreg) will remain enabled. table 4-11 summarizes the outcome of a clock loss while in wait mode. functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 167 table 4-11. outcome of clock loss in wait mode cme scme scmie crg actions 0 x x clock failure --> no action, clock loss not detected. 1 0 x clock failure --> crg performs clock monitor reset immediately 1 1 0 clock failure --> scenario 1: oscclk recovers prior to exiting wait mode. ?mcu remains in wait mode, ?vreg enabled, ?pll enabled, ?scm activated, ?start clock quality check, ?set scmif interrupt ?g. some time later oscclk recovers. ?cm no longer indicates a failure, ?4096 oscclk cycles later clock quality check indicates clock o.k., ?scm deactivated, ?pll disabled depending on pllwai, ?vreg remains enabled (never gets disabled in wait mode) . ?mcu remains in wait mode. s ome time later either a wakeup interrupt occurs (no scm interrupt) ?exit wait mode using oscclk as system clock (sysclk), ?continue normal operation. or an external reset is applied. ?exit wait mode using oscclk as system clock, ?start reset sequence. scenario 2: oscclk does not recover prior to exiting wait mode. ?mcu remains in wait mode, ?vreg enabled, ?pll enabled, ?scm activated, ?start clock quality check, ?set scmif interrupt ?g, ?keep performing clock quality checks (could continue in?itely) while in wait mode. s ome time later either a wakeup interrupt occurs (no scm interrupt) ?exit wait mode in scm using pll clock (f scm ) as system clock, ?continue to perform additional clock quality checks until oscclk is o.k. again. or an external reset is applied. ?exit wait mode in scm using pll clock (f scm ) as system clock, ?start reset sequence, ?continue to perform additional clock quality checks until oscclk is o.k.again. chapter 4 clocks and reset generator (crgv4) mc9s12ne64 data sheet, rev. 1.1 168 freescale semiconductor 4.4.10 low-power operation in stop mode all clocks are stopped in stop mode, dependent of the setting of the pce, pre and pstp bit. the oscillator is disabled in stop mode unless the pstp bit is set. all counters and dividers remain frozen but do not initialize. if the pre or pce bits are set, the rti or cop continues to run in pseudo-stop mode. in addition to disabling system and core clocks the crg requests other functional units of the mcu (e.g. voltage-regulator) to enter their individual power-saving modes (if available). this is the main difference between pseudo-stop mode and wait mode. after executing the stop instruction the core requests the crg to switch the mcu into stop mode. if the pllsel bit remains set when entering stop mode, the crg will switch the system and core clocks to oscclk by clearing the pllsel bit. then the crg disables the pll, disables the core clock and ?ally disables the remaining system clocks. as soon as all clocks are switched off, stop mode is active. if pseudo-stop mode (pstp = 1) is entered from self-clock mode the crg will continue to check the clock quality until clock check is successful. the pll and the voltage regulator (vreg) will remain enabled. if full stop mode (pstp = 0) is entered from self-clock mode an ongoing clock quality check will be stopped. a complete timeout window check will be started when stop mode is exited again. wake-up from stop mode also depends on the setting of the pstp bit. 1 1 1 clock failure --> ?vreg enabled, ?pll enabled, ?scm activated, ?start clock quality check, ?scmif set. scmif generates self-clock mode wakeup interrupt. ?exit wait mode in scm using pll clock (f scm ) as system clock, ?continue to perform a additional clock quality checks until oscclk is o.k. again. table 4-11. outcome of clock loss in wait mode (continued) cme scme scmie crg actions functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 169 figure 4-24. stop mode entry/exit sequence 4.4.10.1 wake-up from pseudo-stop (pstp=1) wake-up from pseudo-stop is the same as wake-up from wait mode. there are also three different scenarios for the crg to restart the mcu from pseudo-stop mode: external reset clock monitor fail wake-up interrupt exit stop w. cmreset exit stop mode enter scm exit stop mode core req s stop mode. clear pllsel, disable pll cme=1 ? int ? cm fail ? scme=1 ? scmie=1 ? continue w. normal op no no no no yes yes yes yes yes generate scm interrupt (wakeup from stop) enter stop mode exit stop w. ext.reset wait mode left due to external clock ok ? scme=1 ? enter scm yes no yes exit stop w. cmreset no no no pstp=1 ? int ? yes no yes exit stop mode exit stop mode scm=1 ? enter scm no yes chapter 4 clocks and reset generator (crgv4) mc9s12ne64 data sheet, rev. 1.1 170 freescale semiconductor if the mcu gets an external reset during pseudo-stop mode active, the crg asynchronously restores all con?uration bits in the register space to its default settings and starts the reset generator. after completing the reset sequence processing begins by fetching the normal reset vector. pseudo-stop mode is exited and the mcu is in run mode again. if the clock monitor is enabled (cme = 1) the mcu is able to leave pseudo-stop mode when loss of oscillator/external clock is detected by a clock monitor fail. if the scme bit is not asserted the crg generates a clock monitor fail reset (cmreset). the crg s behavior for cmreset is the same compared to external reset, but another reset vector is fetched after completion of the reset sequence. if the scme bit is asserted the crg generates a scm interrupt if enabled (scmie=1). after generating the interrupt the crg enters self-clock mode and starts the clock quality checker (see section 4.4.4, ?lock quality checker ?. then the mcu continues with normal operation. if the scm interrupt is blocked by scmie = 0, the scmif ?g will be asserted but the crg will not wake-up from pseudo-stop mode. if any other interrupt source (e.g. rti) triggers exit from pseudo-stop mode the mcu immediately continues with normal operation. because the pll has been powered-down during stop mode the pllsel bit is cleared and the mcu runs on oscclk after leaving stop mode. the software must set the pllsel bit again, in order to switch system and core clocks to the pllclk. table 4-12 summarizes the outcome of a clock loss while in pseudo-stop mode. functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 171 table 4-12. outcome of clock loss in pseudo-stop mode cme scme scmie crg actions 0 x x clock failure --> no action, clock loss not detected. 1 0 x clock failure --> crg performs clock monitor reset immediately 1 1 0 clock monitor failure --> scenario 1: oscclk recovers prior to exiting pseudo-stop mode. ?mcu remains in pseudo-stop mode, ?vreg enabled, ?pll enabled, ?scm activated, ?start clock quality check, ?set scmif interrupt ?g. some time later oscclk recovers. ?cm no longer indicates a failure, ?4096 oscclk cycles later clock quality check indicates clock o.k., ?scm deactivated, ?pll disabled, ?vreg disabled. ?mcu remains in pseudo-stop mode. s ome time later either a wakeup interrupt occurs (no scm interrupt) ?exit pseudo-stop mode using oscclk as system clock (sysclk), ?continue normal operation. or an external reset is applied. ?exit pseudo-stop mode using oscclk as system clock, ?start reset sequence. scenario 2: oscclk does not recover prior to exiting pseudo-stop mode. ?mcu remains in pseudo-stop mode, ?vreg enabled, ?pll enabled, ?scm activated, ?start clock quality check, ?set scmif interrupt ?g, ?keep performing clock quality checks (could continue in?itely) while in pseudo-stop mode. s ome time later either a wakeup interrupt occurs (no scm interrupt) ?exit pseudo-stop mode in scm using pll clock (f scm ) as system clock ?continue to perform additional clock quality checks until oscclk is o.k. again. or an external reset is applied. ?exit pseudo-stop mode in scm using pll clock (f scm ) as system clock ?start reset sequence, ?continue to perform additional clock quality checks until oscclk is o.k.again. chapter 4 clocks and reset generator (crgv4) mc9s12ne64 data sheet, rev. 1.1 172 freescale semiconductor 4.4.10.2 wake-up from full stop (pstp=0) the mcu requires an external interrupt or an external reset in order to wake-up from stop mode. if the mcu gets an external reset during full stop mode active, the crg asynchronously restores all con?uration bits in the register space to its default settings and will perform a maximum of 50 clock check_windows (see section 4.4.4, ?lock quality checker ?. after completing the clock quality check the crg starts the reset generator. after completing the reset sequence processing begins by fetching the normal reset vector. full stop mode is exited and the mcu is in run mode again. if the mcu is woken-up by an interrupt, the crg will also perform a maximum of 50 clock check_window s (see section 4.4.4, ?lock quality checker ?. if the clock quality check is successful, the crg will release all system and core clocks and will continue with normal operation. if all clock checks within the timeout-window are failing, the crg will switch to self-clock mode or generate a clock monitor reset (cmreset) depending on the setting of the scme bit. because the pll has been powered-down during stop mode the pllsel bit is cleared and the mcu runs on oscclk after leaving stop mode. the software must manually set the pllsel bit again, in order to switch system and core clocks to the pllclk. note in full stop mode, the clock monitor is disabled and any loss of clock will not be detected. 4.5 resets this section describes how to reset the crgv4 and how the crgv4 itself controls the reset of the mcu. it explains all special reset requirements. because the reset generator for the mcu is part of the crg, this section also describes all automatic actions that occur during or as a result of individual reset conditions. the reset values of registers and signals are provided in section 4.3, ?emory map and register 1 1 1 clock failure --> ?vreg enabled, ?pll enabled, ?scm activated, ?start clock quality check, ?scmif set. scmif generates self-clock mode wakeup interrupt. ?exit pseudo-stop mode in scm using pll clock (f scm ) as system clock, ?continue to perform a additional clock quality checks until oscclk is o.k. again. table 4-12. outcome of clock loss in pseudo-stop mode (continued) cme scme scmie crg actions resets mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 173 de?ition . all reset sources are listed in table 4-13 . refer to the device overview chapter for related vector addresses and priorities. the reset sequence is initiated by any of the following events: low level is detected at the reset pin (external reset). power on is detected. low voltage is detected. cop watchdog times out. clock monitor failure is detected and self-clock mode was disabled (scme = 0). upon detection of any reset event, an internal circuit drives the reset pin low for 128 sysclk cycles (see figure 4-25 ). because entry into reset is asynchronous it does not require a running sysclk. however, the internal reset circuit of the crgv4 cannot sequence out of current reset condition without a running sysclk. the number of 128 sysclk cycles might be increased by n = 3 to 6 additional sysclk cycles depending on the internal synchronization latency. after 128+n sysclk cycles the reset pin is released. the reset generator of the crgv4 waits for additional 64 sysclk cycles and then samples the reset pin to determine the originating source. table 4-14 shows which vector will be fetched. note external circuitry connected to the reset pin should not include a large capacitance that would interfere with the ability of this signal to rise to a valid logic 1 within 64 sysclk cycles after the low drive is released. table 4-13. reset summary reset source local enable power-on reset none low voltage reset none external reset none clock monitor reset pllctl (cme=1, scme=0) cop watchdog reset copctl (cr[2:0] nonzero) table 4-14. reset vector selection sampled reset pin (64 cycles after release) clock monitor reset pending cop reset pending vector fetch 1 0 0 por / lvr / external reset 1 1 x clock monitor reset 1 0 1 cop reset 0 x x por / lvr / external reset with rise of reset pin chapter 4 clocks and reset generator (crgv4) mc9s12ne64 data sheet, rev. 1.1 174 freescale semiconductor the internal reset of the mcu remains asserted while the reset generator completes the 192 sysclk long reset sequence. the reset generator circuitry always makes sure the internal reset is deasserted synchronously after completion of the 192 sysclk cycles. in case the reset pin is externally driven low for more than these 192 sysclk cycles (external reset), the internal reset remains asserted too. figure 4-25. reset timing 4.5.1 clock monitor reset the crgv4 generates a clock monitor reset in case all of the following conditions are true: clock monitor is enabled (cme=1) loss of clock is detected self-clock mode is disabled (scme=0) the reset event asynchronously forces the con?uration registers to their default settings (see section 4.3, ?emory map and register de?ition ?. in detail the cme and the scme are reset to logical ? (which doesn t change the state of the cme bit, because it has already been set). as a consequence, the crg immediately enters self-clock mode and starts its internal reset sequence. in parallel the clock quality check starts. as soon as clock quality check indicates a valid oscillator clock the crg switches to oscclk and leaves self-clock mode. because the clock quality checker is running in parallel to the reset generator, the crg may leave self-clock mode while completing the internal reset sequence. when the reset sequence is ?ished the crg checks the internally latched state of the clock monitor fail circuit. if a clock monitor fail is indicated processing begins by fetching the clock monitor reset vector. 4.5.2 computer operating properly watchdog (cop) reset when cop is enabled, the crg expects sequential write of 0x0055 and 0x00aa (in this order) to the armcop register during the selected time-out period. as soon as this is done, the cop time-out period restarts. if the program fails to do this the crg will generate a reset. also, if any value other than 0x0055 or 0x00aa is written, the crg immediately generates a reset. in case windowed cop operation is enabled ) ( ) ( ) ( ) sysclk 128+ n cycles 64 cycles with n being min 3 / max 6 cycles depending on internal synchronization delay crg drives reset pin low possibly sysclk not running possibly reset driven low externally ) ( ( reset reset pin released resets mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 175 writes (0x0055 or 0x00aa) to the armcop register must occur in the last 25% of the selected time-out period. a premature write the crg will immediately generate a reset. as soon as the reset sequence is completed the reset generator checks the reset condition. if no clock monitor failure is indicated and the latched state of the cop timeout is true, processing begins by fetching the cop vector. 4.5.3 power-on reset, low voltage reset the on-chip voltage regulator detects when v dd to the mcu has reached a certain level and asserts power-on reset or low voltage reset or both. as soon as a power-on reset or low voltage reset is triggered the crg performs a quality check on the incoming clock signal. as soon as clock quality check indicates a valid oscillator clock signal the reset sequence starts using the oscillator clock. if after 50 check windows the clock quality check indicated a non-valid oscillator clock the reset sequence starts using self-clock mode. figure 4-26 and figure 4-27 show the power-up sequence for cases when the reset pin is tied to v dd and when the reset pin is held low. figure 4-26. reset pin tied to v dd (by a pull-up resistor) figure 4-27. reset pin held low externally reset internal por 128 sysclk 64 sysclk internal reset clock quality check (no self-clock mode) ) ( ) ( ) ( clock quality check reset internal por internal reset 128 sysclk 64 sysclk (no self-clock mode) ) ( ) ( ) ( chapter 4 clocks and reset generator (crgv4) mc9s12ne64 data sheet, rev. 1.1 176 freescale semiconductor 4.6 interrupts the interrupts/reset vectors requested by the crg are listed in table 4-15 . refer to the device overview chapter for related vector addresses and priorities. 4.6.1 real-time interrupt the crgv4 generates a real-time interrupt when the selected interrupt time period elapses. rti interrupts are locally disabled by setting the rtie bit to 0. the real-time interrupt ?g (rtif) is set to 1 when a timeout occurs, and is cleared to 0 by writing a 1 to the rtif bit. the rti continues to run during pseudo-stop mode if the pre bit is set to 1. this feature can be used for periodic wakeup from pseudo-stop if the rti interrupt is enabled. 4.6.2 pll lock interrupt the crgv4 generates a pll lock interrupt when the lock condition of the pll has changed, either from a locked state to an unlocked state or vice versa. lock interrupts are locally disabled by setting the lockie bit to 0. the pll lock interrupt ?g (lockif) is set to1 when the lock condition has changed, and is cleared to 0 by writing a 1 to the lockif bit. 4.6.3 self-clock mode interrupt the crgv4 generates a self-clock mode interrupt when the scm condition of the system has changed, either entered or exited self-clock mode. scm conditions can only change if the self-clock mode enable bit (scme) is set to 1. scm conditions are caused by a failing clock quality check after power-on reset (por) or low voltage reset (lvr) or recovery from full stop mode (pstp = 0) or clock monitor failure. for details on the clock quality check refer to section 4.4.4, ?lock quality checker . if the clock monitor is enabled (cme = 1) a loss of external clock will also cause a scm condition (scme = 1). scm interrupts are locally disabled by setting the scmie bit to 0. the scm interrupt ?g (scmif) is set to 1 when the scm condition has changed, and is cleared to 0 by writing a 1 to the scmif bit. table 4-15. crg interrupt vectors interrupt source ccr mask local enable real-time interrupt i bit crgint (rtie) lock interrupt i bit crgint (lockie) scm interrupt i bit crgint (scmie) mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 177 chapter 5 oscillator (oscv2) 5.1 introduction the oscv2 module provides two alternative oscillator concepts: a low noise and low power colpitts oscillator with amplitude limitation control (alc) a robust full swing pierce oscillator with the possibility to feed in an external square wave 5.1.1 features the colpitts oscv2 option provides the following features: amplitude limitation control (alc) loop: low power consumption and low current induced rf emission sinusoidal waveform with low rf emission low crystal stress (an external damping resistor is not required) normal and low amplitude mode for further reduction of power and emission an external biasing resistor is not required the pierce osc option provides the following features: wider high frequency operation range no dc voltage applied across the crystal full rail-to-rail (2.5 v nominal) swing oscillation with low em susceptibility fast start up common features: clock monitor (cm) operation from the v ddpll 2.5 v (nominal) supply rail 5.1.2 modes of operation two modes of operation exist: amplitude limitation controlled colpitts oscillator mode suitable for power and emission critical applications full swing pierce oscillator mode that can also be used to feed in an externally generated square wave suitable for high frequency operation and harsh environments 5.2 external signal description this section lists and describes the signals that connect off chip. chapter 5 oscillator (oscv2) mc9s12ne64 data sheet, rev. 1.1 178 freescale semiconductor 5.2.1 v ddpll and v sspll ?pll operating voltage, pll ground these pins provide the operating voltage (v ddpll ) and ground (v sspll ) for the oscv2 circuitry. this allows the supply voltage to the oscv2 to be independently bypassed. 5.2.2 extal and xtal ?clock/crystal source pins these pins provide the interface for either a crystal or a cmos compatible clock to control the internal clock generator circuitry. extal is the external clock input or the input to the crystal oscillator ampli?r. xtal is the output of the crystal oscillator ampli?r. all the mcu internal system clocks are derived from the extal input frequency. in full stop mode (pstp = 0) the extal pin is pulled down by an internal resistor of typical 200 k ? . note freescale semiconductor recommends an evaluation of the application board and chosen resonator or crystal by the resonator or crystal supplier . the crystal circuit is changed from standard. the colpitts circuit is not suited for overtone resonators and crystals. figure 5-1. colpitts oscillator connections (xclks = 0) note the pierce circuit is not suited for overtone resonators and crystals without a careful component selection. mcu c2 extal xtal v sspll c1 cdc* crystal or ceramic resonator * due to the nature of a translated ground colpitts oscillator a dc voltage bias is applied to the crystal. please contact the crystal manufacturer for crystal dc bias conditions and recommended capacitor value cdc. external signal description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 179 figure 5-2. pierce oscillator connections (xclks = 1) figure 5-3. external clock connections (xclks = 1) 5.2.3 xclks ?colpitts/pierce oscillator selection signal the xclks is an input signal which controls whether a crystal in combination with the internal colpitts (low power) oscillator is used or whether the pierce oscillator/external clock circuitry is used. the xclks signal is sampled during reset with the rising edge of reset. table 5-1 lists the state coding of the sampled xclks signal. refer to the device overview chapter for polarity of the xclks pin. table 5-1. clock selection based on xclks xclks description 0 colpitts oscillator selected 1 pierce oscillator/external clock selected mcu extal xtal rs* rb v sspll crystal or ceramic resonator c4 c3 * rs can be zero (shorted) when used with higher frequency crystals. refer to manufacturer s data. mcu extal xtal cmos-compatible external oscillator not connected (v ddpll level) chapter 5 oscillator (oscv2) mc9s12ne64 data sheet, rev. 1.1 180 freescale semiconductor 5.3 memory map and register de?ition the crg contains the registers and associated bits for controlling and monitoring the oscv2 module. 5.4 functional description the oscv2 block has two external pins, extal and xtal. the oscillator input pin, extal, is intended to be connected to either a crystal or an external clock source. the selection of colpitts oscillator or pierce oscillator/external clock depends on the xclks signal which is sampled during reset. the xtal pin is an output signal that provides crystal circuit feedback. a buffered extal signal, oscclk, becomes the internal reference clock. to improve noise immunity, the oscillator is powered by the v ddpll and v sspll power supply pins. the pierce oscillator can be used for higher frequencies compared to the low power colpitts oscillator. 5.4.1 amplitude limitation control (alc) the colpitts oscillator is equipped with a feedback system which does not waste current by generating harmonics. its con?uration is ?olpitts oscillator with translated ground.?the transconductor used is driven by a current source under the control of a peak detector which will measure the amplitude of the ac signal appearing on extal node in order to implement an amplitude limitation control (alc) loop. the alc loop is in charge of reducing the quiescent current in the transconductor as a result of an increase in the oscillation amplitude. the oscillation amplitude can be limited to two values. the normal amplitude which is intended for non power saving modes and a small amplitude which is intended for low power operation modes. please refer to the crg block description chapter for the control and assignment of the amplitude value to operation modes. 5.4.2 clock monitor (cm) the clock monitor circuit is based on an internal resistor-capacitor (rc) time delay so that it can operate without any mcu clocks. if no oscclk edges are detected within this rc time delay, the clock monitor indicates a failure which asserts self clock mode or generates a system reset depending on the state of scme bit. if the clock monitor is disabled or the presence of clocks is detected no failure is indicated.the clock monitor function is enabled/disabled by the cme control bit, described in the crg block description chapter. 5.5 interrupts oscv2 contains a clock monitor, which can trigger an interrupt or reset. the control bits and status bits for the clock monitor are described in the crg block description chapter. mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 181 chapter 6 timer module (tim16b4cv1) 6.1 introduction the basic timer consists of a 16-bit, software-programmable counter driven by a seven-stage programmable prescaler. this timer can be used for many purposes, including input waveform measurements while simultaneously generating an output waveform. pulse widths can vary from microseconds to many seconds. this timer contains 4 complete input capture/output compare channels ioc[7:4] and one pulse accumulator. the input capture function is used to detect a selected transition edge and record the time. the output compare function is used for generating output signals or for timer software delays. the 16-bit pulse accumulator is used to operate as a simple event counter or a gated time accumulator. the pulse accumulator shares timer channel 7 when in event mode. a full access for the counter registers or the input capture/output compare registers should take place in one clock cycle. accessing high byte and low byte separately for all of these registers may not yield the same result as accessing them in one word. 6.1.1 features the tim16b4cv1 includes these distinctive features: four input capture/output compare channels. clock prescaling. 16-bit counter. 16-bit pulse accumulator. 6.1.2 modes of operation stop: timer is off because clocks are stopped. freeze: timer counter keep on running, unless tsfrz in tscr (0x0006) is set to 1. wait: counters keep on running, unless tswai in tscr (0x0006) is set to 1. normal: timer counter keep on running, unless ten in tscr (0x0006) is cleared to 0. chapter 6 timer module (tim16b4cv1) mc9s12ne64 data sheet, rev. 1.1 182 freescale semiconductor 6.1.3 block diagrams figure 6-1. tim16b4cv1 block diagram prescaler 16-bit counter 16-bit pulse accumulator ioc5 ioc4 ioc6 ioc7 pa input interrupt pa overflow interrupt timer overflow interrupt timer channel 4 interrupt timer channel 7 interrupt registers bus clock input capture output compare input capture output compare input capture output compare input capture output compare channel 4 channel 5 channel 6 channel 7 introduction mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 183 figure 6-2. 16-bit pulse accumulator block diagram figure 6-3. interrupt flag setting edge detector intermodule bus pt7 m clock divide by 64 clock select clk0 clk1 4:1 mux timclk paclk paclk / 256 paclk / 65536 prescaled clock (pclk) (timer clock) interrupt mux (pamod) pacnt ptn edge detector 16-bit main timer tcn input capture reg. set cnf interrupt chapter 6 timer module (tim16b4cv1) mc9s12ne64 data sheet, rev. 1.1 184 freescale semiconductor figure 6-4. channel 7 output compare/pulse accumulator logic note for more information see the respective functional descriptions in section 6.4, ?unctional description , of this document. 6.2 external signal description the tim16b4cv1 module has a total of four external pins. 6.2.1 ioc7 ?input capture and output compare channel 7 pin this pin serves as input capture or output compare for channel 7. this can also be con?ured as pulse accumulator input. 6.2.2 ioc6 ?input capture and output compare channel 6 pin this pin serves as input capture or output compare for channel 6. 6.2.3 ioc5 ?input capture and output compare channel 5 pin this pin serves as input capture or output compare for channel 5. 6.2.4 ioc4 ?input capture and output compare channel 4 pin this pin serves as input capture or output compare for channel 4. note for the description of interrupts see section 6.6, ?nterrupts . pulse accumulator pa d om7 ol7 oc7m7 channel 7 output compare memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 185 6.3 memory map and register de?ition this section provides a detailed description of all memory and registers. 6.3.1 module memory map the memory map for the tim16b4cv1 module is given below in table 6-1 . the address listed for each register is the address offset. the total address for each register is the sum of the base address for the tim16b4cv1 module and the address offset for each register. table 6-1. tim16b4cv1 memory map address offset use access 0x0000 timer input capture/output compare select (tios) r/w 0x0001 timer compare force register (cforc) r/w 1 1 always read 0x0000. 0x0002 output compare 7 mask register (oc7m) r/w 0x0003 output compare 7 data register (oc7d) r/w 0x0004 timer count register (tcnt(hi)) r/w 2 0x0005 timer count register (tcnt(lo)) r/w 2 0x0006 timer system control register1 (tscr1) r/w 0x0007 timer toggle over?w register (ttov) r/w 0x0008 timer control register1 (tctl1) r/w 0x0009 reserved 3 0x000a timer control register3 (tctl3) r/w 0x000b reserved 3 0x000c timer interrupt enable register (tie) r/w 0x000d timer system control register2 (tscr2) r/w 0x000e main timer interrupt flag1 (tflg1) r/w 0x000f main timer interrupt flag2 (tflg2) r/w 0x0010 - 0x0017 reserved 3 0x0018 timer input capture/output compare register4 (tc4(hi)) r/w 4 0x0019 timer input capture/output compare register 4 (tc4(lo)) r/w 4 0x001a timer input capture/output compare register 5 (tc5(hi)) r/w 4 0x001b timer input capture/output compare register 5 (tc5(lo)) r/w 4 0x001c timer input capture/output compare register 6 (tc6(hi)) r/w 4 0x001d timer input capture/output compare register 6 (tc6(lo)) r/w 4 0x001e timer input capture/output compare register 7 (tc7(hi)) r/w 4 0x001f timer input capture/output compare register 7 (tc7(lo)) r/w 4 0x0020 16-bit pulse accumulator control register (pactl) r/w 0x0021 pulse accumulator flag register (paflg) r/w 0x0022 pulse accumulator count register (pacnt(hi)) r/w 0x0023 pulse accumulator count register (pacnt(lo)) r/w 0x0024 ?0x002c reserved 3 0x002d timer test register (timtst) r/w 2 0x002e ?0x002f reserved 3 chapter 6 timer module (tim16b4cv1) mc9s12ne64 data sheet, rev. 1.1 186 freescale semiconductor 6.3.2 register descriptions this section consists of register descriptions in address order. each description includes a standard register diagram with an associated ?ure number. details of register bit and ?ld function follow the register diagrams, in bit order. 2 only writable in special modes (test_mode = 1). 3 write has no effect; return 0 on read 4 write to these registers have no meaning or effect during input capture. register name bit 7 654321 bit 0 0x0000 tios r ios7 ios6 ios5 ios4 ios3 ios2 ios1 ios0 w 0x0001 cforc r00000000 w foc7 foc6 foc5 foc4 foc3 foc2 foc1 foc0 0x0002 oc7m r oc7m7 oc7m6 oc7m5 oc7m4 oc7m3 oc7m2 oc7m1 oc7m0 w 0x0003 oc7d r oc7d7 oc7d6 oc7d5 oc7d4 oc7d3 oc7d2 oc7d1 oc7d0 w 0x0004 tcnth r tcnt15 tcnt14 tcnt13 tcnt12 tcnt11 tcnt10 tcnt9 tcnt8 w 0x0005 tcntl r tcnt7 tcnt6 tcnt5 tcnt4 tcnt3 tcnt2 tcnt1 tcnt0 w 0x0006 tscr2 r ten tswai tsfrz tffca 0000 w 0x0007 ttov r tov7 tov6 tov5 tov4 tov3 tov2 tov1 tov0 w 0x0008 tctl1 r om7 ol7 om6 ol6 om5 ol5 om4 ol4 w 0x0009 reserved r00000000 w 0x000a tctl3 r edg7b edg7a edg6b edg6a edg5b edg5a edg4b edg4a w = unimplemented or reserved figure 6-5. tim16b4cv1 register summary memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 187 0x000b reserved r00000000 w 0x000c tie r c7i c6i c5i c4i c3i c2i c1i c0i w 0x000d tscr2 r toi 000 tcre pr2 pr1 pr0 w 0x000e tflg1 r c7f c6f c5f c4f c3f c2f c1f c0f w 0x000f tflg2 r tof 0000000 w 0x0010?x0017 reserved r00000000 w 0x0018?x001f tcxh?cxl r bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 w r bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w 0x0020 pactl r0 paen pamod pedge clk1 clk0 paovi pai w 0x0021 paflg r000000 paovf paif w 0x0022 pacnth r pacnt15 pacnt14 pacnt13 pacnt12 pacnt11 pacnt10 pacnt9 pacnt8 w 0x0023 pacntl r pacnt7 pacnt6 pacnt5 pacnt4 pacnt3 pacnt2 pacnt1 pacnt0 w 0x0024?x002f reserved r w register name bit 7 654321 bit 0 = unimplemented or reserved figure 6-5. tim16b4cv1 register summary (continued) chapter 6 timer module (tim16b4cv1) mc9s12ne64 data sheet, rev. 1.1 188 freescale semiconductor 6.3.2.1 timer input capture/output compare select (tios) read: anytime write: anytime 6.3.2.2 timer compare force register (cforc) read: anytime but will always return 0x0000 (1 state is transient) write: anytime 76543210 r ios7 ios6 ios5 ios4 0000 w reset 0 0 0 00000 figure 6-6. timer input capture/output compare select (tios) table 6-2. tios field descriptions field description 7:4 ios[7:4] input capture or output compare channel con?uration 0 the corresponding channel acts as an input capture. 1 the corresponding channel acts as an output compare. 76543210 r00000000 w foc7 foc6 foc5 foc4 reset 0 0 0 00000 figure 6-7. timer compare force register (cforc) table 6-3. cforc field descriptions field description 7:4 foc[7:4] force output compare action for channel 7:4 a write to this register with the corresponding data bit(s) set causes the action which is programmed for output compare ??to occur immediately. the action taken is the same as if a successful comparison had just taken place with the tcx register except the interrupt ?g does not get set. note: a successful channel 7 output compare overrides any channel 6:4 compares. if forced output compare on any channel occurs at the same time as the successful output compare then forced output compare action will take precedence and interrupt ?g won? get set. memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 189 6.3.2.3 output compare 7 mask register (oc7m) read: anytime write: anytime 6.3.2.4 output compare 7 data register (oc7d) read: anytime write: anytime 6.3.2.5 timer count register (tcnt) 76543210 r oc7m7 oc7m6 oc7m5 oc7m4 0000 w reset 0 0 0 00000 figure 6-8. output compare 7 mask register (oc7m) table 6-4. oc7m field descriptions field description 7:4 oc7m[7:4] output compare 7 mask setting the oc7mx (x ranges from 4 to 6) will set the corresponding port to be an output port when the corresponding tiosx (x ranges from 4 to 6) bit is set to be an output compare. note: a successful channel 7 output compare overrides any channel 6:4 compares. for each oc7m bit that is set, the output compare action re?cts the corresponding oc7d bit. 76543210 r oc7d7 oc7d6 oc7d5 oc7d4 0000 w reset 0 0 0 00000 figure 6-9. output compare 7 data register (oc7d) table 6-5. oc7d field descriptions field description 7:4 oc7d[7:4] output compare 7 data ?a channel 7 output compare can cause bits in the output compare 7 data register to transfer to the timer port data register depending on the output compare 7 mask register. 15 14 13 12 11 10 9 9 r tcnt15 tcnt14 tcnt13 tcnt12 tcnt11 tcnt10 tcnt9 tcnt8 w reset 0 0 0 00000 figure 6-10. timer count register high (tcnth) chapter 6 timer module (tim16b4cv1) mc9s12ne64 data sheet, rev. 1.1 190 freescale semiconductor the 16-bit main timer is an up counter. a full access for the counter register should take place in one clock cycle. a separate read/write for high byte and low byte will give a different result than accessing them as a word. read: anytime write: has no meaning or effect in the normal mode; only writable in special modes (test_mode = 1). the period of the ?st count after a write to the tcnt registers may be a different size because the write is not synchronized with the prescaler clock. 6.3.2.6 timer system control register 1 (tscr1) read: anytime write: anytime 76543210 r tcnt7 tcnt6 tcnt5 tcnt4 tcnt3 tcnt2 tcnt1 tcnt0 w reset 0 0 0 00000 figure 6-11. timer count register low (tcntl) 76543210 r ten tswai tsfrz tffca 0000 w reset 0 0 0 00000 = unimplemented or reserved figure 6-12. timer system control register 1 (tscr2) table 6-6. tscr1 field descriptions field description 7 ten timer enable 0 disables the main timer, including the counter. can be used for reducing power consumption. 1 allows the timer to function normally. if for any reason the timer is not active, there is no 64 clock for the pulse accumulator because the 64 is generated by the timer prescaler. 6 tswai timer module stops while in wait 0 allows the timer module to continue running during wait. 1 disables the timer module when the mcu is in the wait mode. timer interrupts cannot be used to get the mcu out of wait. tswai also affects pulse accumulator. memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 191 6.3.2.7 timer toggle on over?w register 1 (ttov) read: anytime write: anytime 6.3.2.8 timer control register 1 (tctl1) read: anytime write: anytime 5 tsfrz timer stops while in freeze mode 0 allows the timer counter to continue running while in freeze mode. 1 disables the timer counter whenever the mcu is in freeze mode. this is useful for emulation. tsfrz does not stop the pulse accumulator. 4 tffca timer fast flag clear all 0 allows the timer ?g clearing to function normally. 1 for tflg1(0x000e), a read from an input capture or a write to the output compare channel (0x0010?x001f) causes the corresponding channel ?g, cnf, to be cleared. for tflg2 (0x000f), any access to the tcnt register (0x0004, 0x0005) clears the tof ?g. any access to the pacnt registers (0x0022, 0x0023) clears the paovf and paif ?gs in the paflg register (0x0021). this has the advantage of eliminating software overhead in a separate clear sequence. extra care is required to avoid accidental ?g clearing due to unintended accesses. 76543210 r tov7 tov6 tov5 tov4 0000 w reset 0 0 0 00000 figure 6-13. timer toggle on over?w register 1 (ttov) table 6-7. ttov field descriptions field description 7:4 tov[7:4] toggle on over?w bits tovx toggles output compare pin on over?w. this feature only takes effect when in output compare mode. when set, it takes precedence over forced output compare but not channel 7 override events. 0 toggle output compare pin on over?w feature disabled. 1 toggle output compare pin on over?w feature enabled. 76543210 r om7 ol7 om6 ol6 om5 ol5 om4 ol4 w reset 0 0 0 00000 figure 6-14. timer control register 1 (tctl1) table 6-6. tscr1 field descriptions (continued) field description chapter 6 timer module (tim16b4cv1) mc9s12ne64 data sheet, rev. 1.1 192 freescale semiconductor to operate the 16-bit pulse accumulator independently of input capture or output compare 7 and 4 respectively the user must set the corresponding bits iosx = 1, omx = 0 and olx = 0. oc7m7 in the oc7m register must also be cleared. table 6-8. tctl1/tctl2 field descriptions field description 7:4 omx output mode these four pairs of control bits are encoded to specify the output action to be taken as a result of a successful ocx compare. when either omx or olx is 1, the pin associated with ocx becomes an output tied to ocx. note: to enable output action by omx bits on timer port, the corresponding bit in oc7m should be cleared. 7:4 olx output level these four pairs of control bits are encoded to specify the output action to be taken as a result of a successful ocx compare. when either omx or olx is 1, the pin associated with ocx becomes an output tied to ocx. note: to enable output action by olx bits on timer port, the corresponding bit in oc7m should be cleared. table 6-9. compare result output action omx olx action 0 0 timer disconnected from output pin logic 0 1 toggle ocx output line 1 0 clear ocx output line to zero 1 1 set ocx output line to one memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 193 6.3.2.9 timer control register 3 (tctl3) read: anytime write: anytime. 76543210 r edg7b edg7a edg6b edg6a edg5b edg5a edg4b edg4a w reset 0 0 0 00000 figure 6-15. timer control register 3 (tctl3) table 6-10. tctl3/tctl4 field descriptions field description 7:0 edgnb edgna input capture edge control ?these eight pairs of control bits con?ure the input capture edge detector circuits. table 6-11. edge detector circuit con?uration edgnb edgna con?uration 0 0 capture disabled 0 1 capture on rising edges only 1 0 capture on falling edges only 1 1 capture on any edge (rising or falling) chapter 6 timer module (tim16b4cv1) mc9s12ne64 data sheet, rev. 1.1 194 freescale semiconductor 6.3.2.10 timer interrupt enable register (tie) read: anytime write: anytime. 6.3.2.11 timer system control register 2 (tscr2) read: anytime write: anytime. 76543210 r c7i c6i c5i c4i 0000 w reset 0 0 0 00000 figure 6-16. timer interrupt enable register (tie) table 6-12. tie field descriptions field description 7:4 c7i:c0i input capture/output compare ??interrupt enable the bits in tie correspond bit-for-bit with the bits in the tflg1 status register. if cleared, the corresponding ?g is disabled from causing a hardware interrupt. if set, the corresponding ?g is enabled to cause a interrupt. 76543210 r toi 000 tcre pr2 pr1 pr0 w reset 0 0 0 00000 = unimplemented or reserved figure 6-17. timer system control register 2 (tscr2) table 6-13. tscr2 field descriptions field description 7 toi timer over?w interrupt enable 0 interrupt inhibited. 1 hardware interrupt requested when tof ?g set. 3 tcre timer counter reset enable this bit allows the timer counter to be reset by a successful output compare 7 event. this mode of operation is similar to an up-counting modulus counter. 0 counter reset inhibited and counter free runs. 1 counter reset by a successful output compare 7. if tc7 = 0x0000 and tcre = 1, tcnt will stay at 0x0000 continuously. if tc7 = 0xffff and tcre = 1, tof will never be set when tcnt is reset from 0xffff to 0x0000. 2 pr[2:0] timer prescaler select ?these three bits select the frequency of the timer prescaler clock derived from the bus clock as shown in table 6-14 . memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 195 note the newly selected prescale factor will not take effect until the next synchronized edge where all prescale counter stages equal zero. 6.3.2.12 main timer interrupt flag 1 (tflg1) read: anytime write: used in the clearing mechanism (set bits cause corresponding bits to be cleared). writing a zero will not affect current status of the bit. table 6-14. timer clock selection pr2 pr1 pr0 timer clock 0 0 0 bus clock / 1 0 0 1 bus clock / 2 0 1 0 bus clock / 4 0 1 1 bus clock / 8 1 0 0 bus clock / 16 1 0 1 bus clock / 32 1 1 0 bus clock / 64 1 1 1 bus clock / 128 76543210 r c7f c6f c5f c4f 0000 w reset 0 0 0 00000 figure 6-18. main timer interrupt flag 1 (tflg1) table 6-15. trlg1 field descriptions field description 7:4 c[7:4]f input capture/output compare channel ??flag ?these flags are set when an input capture or output compare event occurs. clear a channel ?g by writing one to it. when tffca bit in tscr register is set, a read from an input capture or a write into an output compare channel (0x0010?x001f) will cause the corresponding channel ?g cxf to be cleared. chapter 6 timer module (tim16b4cv1) mc9s12ne64 data sheet, rev. 1.1 196 freescale semiconductor 6.3.2.13 main timer interrupt flag 2 (tflg2) tflg2 indicates when interrupt conditions have occurred. to clear a bit in the ?g register, write the bit to one. read: anytime write: used in clearing mechanism (set bits cause corresponding bits to be cleared). any access to tcnt will clear tflg2 register if the tffca bit in tscr register is set. 6.3.2.14 timer input capture/output compare registers high and low 4? (tcxh and tcxl) depending on the tios bit for the corresponding channel, these registers are used to latch the value of the free-running counter when a de?ed transition is sensed by the corresponding input capture edge detector or to trigger an output action for output compare. read: anytime 76543210 r tof 0000000 w reset 0 0 0 00000 unimplemented or reserved figure 6-19. main timer interrupt flag 2 (tflg2) table 6-16. trlg2 field descriptions field description 7 tof timer over?w flag set when 16-bit free-running timer over?ws from 0xffff to 0x0000. this bit is cleared automatically by a write to the tflg2 register with bit 7 set. (see also tcre control bit explanation.) 15 14 11 12 11 10 9 0 r bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 w reset 00000000 figure 6-20. timer input capture/output compare register x high (tcxh) 76543210 r bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 w reset 00000000 figure 6-21. timer input capture/output compare register x low (tcxl) memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 197 write: anytime for output compare function.writes to these registers have no meaning or effect during input capture. all timer input capture/output compare registers are reset to 0x0000. note read/write access in byte mode for high byte should takes place before low byte otherwise it will give a different result. 6.3.2.15 16-bit pulse accumulator control register (pactl) when paen is set, the pact is enabled.the pact shares the input pin with ioc7. read: any time write: any time 76543210 r0 paen pamod pedge clk1 clk0 paovi pai w reset 0 0 0 00000 unimplemented or reserved figure 6-22. 16-bit pulse accumulator control register (pactl) table 6-17. pactl field descriptions field description 6 paen pulse accumulator system enable ?paen is independent from ten. with timer disabled, the pulse accumulator can function unless pulse accumulator is disabled. 0 16-bit pulse accumulator system disabled. 1 pulse accumulator system enabled. 5 pamod pulse accumulator mode ?this bit is active only when the pulse accumulator is enabled (paen = 1). see table 6-18 . 0 event counter mode. 1 gated time accumulation mode. 4 pedge pulse accumulator edge control this bit is active only when the pulse accumulator is enabled (paen = 1). for pamod bit = 0 (event counter mode). see table 6-18 . 0 falling edges on ioc7 pin cause the count to be incremented. 1 rising edges on ioc7 pin cause the count to be incremented. for pamod bit = 1 (gated time accumulation mode). 0 ioc7 input pin high enables m (bus clock) divided by 64 clock to pulse accumulator and the trailing falling edge on ioc7 sets the paif ?g. 1 ioc7 input pin low enables m (bus clock) divided by 64 clock to pulse accumulator and the trailing rising edge on ioc7 sets the paif ?g. 3:2 clk[1:0] clock select bits refer to table 6-19 . chapter 6 timer module (tim16b4cv1) mc9s12ne64 data sheet, rev. 1.1 198 freescale semiconductor note if the timer is not active (ten = 0 in tscr), there is no divide-by-64 because the 64 clock is generated by the timer prescaler. for the description of paclk please refer figure 6-22 . if the pulse accumulator is disabled (paen = 0), the prescaler clock from the timer is always used as an input clock to the timer counter. the change from one selected clock to the other happens immediately after these bits are written. 1 paov i pulse accumulator over?w interrupt enable 0 interrupt inhibited. 1 interrupt requested if paovf is set. 0 pa i pulse accumulator input interrupt enable 0 interrupt inhibited. 1 interrupt requested if paif is set. table 6-18. pin action pamod pedge pin action 0 0 falling edge 0 1 rising edge 1 0 div. by 64 clock enabled with pin high level 1 1 div. by 64 clock enabled with pin low level table 6-19. timer clock selection clk1 clk0 timer clock 0 0 use timer prescaler clock as timer counter clock 0 1 use paclk as input to timer counter clock 1 0 use paclk/256 as timer counter clock frequency 1 1 use paclk/65536 as timer counter clock frequency table 6-17. pactl field descriptions (continued) field description memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 199 6.3.2.16 pulse accumulator flag register (paflg) read: anytime write: anytime when the tffca bit in the tscr register is set, any access to the pacnt register will clear all the ?gs in the paflg register. 76543210 r000000 paovf paif w reset 0 0 0 00000 unimplemented or reserved figure 6-23. pulse accumulator flag register (paflg) table 6-20. paflg field descriptions field description 1 paov f pulse accumulator over?w flag set when the 16-bit pulse accumulator over?ws from 0xffff to 0x0000. this bit is cleared automatically by a write to the paflg register with bit 1 set. 0 paif pulse accumulator input edge flag set when the selected edge is detected at the ioc7 input pin.in event mode the event edge triggers paif and in gated time accumulation mode the trailing edge of the gate signal at the ioc7 input pin triggers paif. this bit is cleared by a write to the paflg register with bit 0 set. any access to the pacnt register will clear all the ?gs in this register when tffca bit in register tscr(0x0006) is set. chapter 6 timer module (tim16b4cv1) mc9s12ne64 data sheet, rev. 1.1 200 freescale semiconductor 6.3.2.17 pulse accumulators count registers (pacnt) read: anytime write: anytime these registers contain the number of active input edges on its input pin since the last reset. when pacnt over?ws from 0xffff to 0x0000, the interrupt ?g paovf in paflg (0x0021) is set. full count register access should take place in one clock cycle. a separate read/write for high byte and low byte will give a different result than accessing them as a word. note reading the pulse accumulator counter registers immediately after an active edge on the pulse accumulator input pin may miss the last count because the input has to be synchronized with the bus clock ?st. 15 14 13 12 11 10 9 0 r pacnt15 pacnt14 pacnt13 pacnt12 pacnt11 pacnt10 pacnt9 pacnt8 w reset 0 0 0 00000 figure 6-24. pulse accumulator count register high (pacnth) 76543210 r pacnt7 pacnt6 pacnt5 pacnt4 pacnt3 pacnt2 pacnt1 pacnt0 w reset 0 0 0 00000 figure 6-25. pulse accumulator count register low (pacntl) functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 201 6.4 functional description this section provides a complete functional description of the timer tim16b4cv1 block. please refer to the detailed timer block diagram in figure 6-26 as necessary. figure 6-26. detailed timer block diagram prescaler channel 4 ioc4 pin 16-bit counter logic pr[2:1:0] divide-by-64 tc4 edge detect pacnt(hi):pacnt(lo) paovf pedge paovi pamod pae 16-bit comparator tcnt(hi):tcnt(lo) 16-bit counter interrupt logic tof toi c4f edge detect cxf channel7 tc7 16-bit comparator c7f ioc7 pin logic edge detect om:ol4 tov4 om:ol7 tov7 edg7a edg7b edg4b tcre paif clear counter paif pai interrupt logic cxi interrupt request paovf ch. 7 compare ch.7 capture mux clk[1:0] paclk paclk/256 paclk/65536 ioc4 pin ioc7 pin paclk paclk/256 paclk/65536 te ch. 4 compare ch. 4 capture pa input edg4a channel 7 output compare ioc4 ioc7 bus clock bus clock paovf paovi tof c4f c7f chapter 6 timer module (tim16b4cv1) mc9s12ne64 data sheet, rev. 1.1 202 freescale semiconductor 6.4.1 prescaler the prescaler divides the bus clock by 1,2,4,8,16,32,64 or 128. the prescaler select bits, pr[2:0], select the prescaler divisor. pr[2:0] are in timer system control register 2 (tscr2). 6.4.2 input capture clearing the i/o (input/output) select bit, iosx, con?ures channel x as an input capture channel. the input capture function captures the time at which an external event occurs. when an active edge occurs on the pin of an input capture channel, the timer transfers the value in the timer counter into the timer channel registers, tcx. the minimum pulse width for the input capture input is greater than two bus clocks. an input capture on channel x sets the cxf ?g. the cxi bit enables the cxf ?g to generate interrupt requests. 6.4.3 output compare setting the i/o select bit, iosx, con?ures channel x as an output compare channel. the output compare function can generate a periodic pulse with a programmable polarity, duration, and frequency. when the timer counter reaches the value in the channel registers of an output compare channel, the timer can set, clear, or toggle the channel pin. an output compare on channel x sets the cxf ?g. the cxi bit enables the cxf ?g to generate interrupt requests. the output mode and level bits, omx and olx, select set, clear, toggle on output compare. clearing both omx and olx disconnects the pin from the output logic. setting a force output compare bit, focx, causes an output compare on channel x. a forced output compare does not set the channel ?g. a successful output compare on channel 7 overrides output compares on all other output compare channels. the output compare 7 mask register masks the bits in the output compare 7 data register. the timer counter reset enable bit, tcre, enables channel 7 output compares to reset the timer counter. a channel 7 output compare can reset the timer counter even if the ioc7 pin is being used as the pulse accumulator input. writing to the timer port bit of an output compare pin does not affect the pin state. the value written is stored in an internal latch. when the pin becomes available for general-purpose output, the last value written to the bit appears at the pin. 6.4.4 pulse accumulator the pulse accumulator (pacnt) is a 16-bit counter that can operate in two modes: event counter mode ?counting edges of selected polarity on the pulse accumulator input pin, pai. gated time accumulation mode counting pulses from a divide-by-64 clock. the pamod bit selects the mode of operation. resets mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 203 the minimum pulse width for the pai input is greater than two bus clocks. 6.4.5 event counter mode clearing the pamod bit con?ures the pacnt for event counter operation. an active edge on the ioc7 pin increments the pulse accumulator counter. the pedge bit selects falling edges or rising edges to increment the count. note the pacnt input and timer channel 7 use the same pin ioc7. to use the ioc7, disconnect it from the output logic by clearing the channel 7 output mode and output level bits, om7 and ol7. also clear the channel 7 output compare 7 mask bit, oc7m7. the pulse accumulator counter register re?ct the number of active input edges on the pacnt input pin since the last reset. the paovf bit is set when the accumulator rolls over from 0xffff to 0x0000. the pulse accumulator over?w interrupt enable bit, paovi, enables the paovf ?g to generate interrupt requests. note the pulse accumulator counter can operate in event counter mode even when the timer enable bit, ten, is clear. 6.4.6 gated time accumulation mode setting the pamod bit con?ures the pulse accumulator for gated time accumulation operation. an active level on the pacnt input pin enables a divided-by-64 clock to drive the pulse accumulator. the pedge bit selects low levels or high levels to enable the divided-by-64 clock. the trailing edge of the active level at the ioc7 pin sets the paif. the pai bit enables the paif ?g to generate interrupt requests. the pulse accumulator counter register re?ct the number of pulses from the divided-by-64 clock since the last reset. note the timer prescaler generates the divided-by-64 clock. if the timer is not active, there is no divided-by-64 clock. 6.5 resets the reset state of each individual bit is listed within section 6.3, ?emory map and register de?ition which details the registers and their bit ?lds. chapter 6 timer module (tim16b4cv1) mc9s12ne64 data sheet, rev. 1.1 204 freescale semiconductor 6.6 interrupts this section describes interrupts originated by the tim16b4cv1 block. table 6-21 lists the interrupts generated by the tim16b4cv1 to communicate with the mcu. the tim16b4cv1 uses a total of 7 interrupt vectors. the interrupt vector offsets and interrupt numbers are chip dependent. 6.6.1 channel [7:4] interrupt (c[7:4]f) this active high outputs will be asserted by the module to request a timer channel 7 ?4 interrupt to be serviced by the system controller. 6.6.2 pulse accumulator input interrupt (paovi) this active high output will be asserted by the module to request a timer pulse accumulator input interrupt to be serviced by the system controller. 6.6.3 pulse accumulator over?w interrupt (paovf) this active high output will be asserted by the module to request a timer pulse accumulator over?w interrupt to be serviced by the system controller. 6.6.4 timer over?w interrupt (tof) this active high output will be asserted by the module to request a timer over?w interrupt to be serviced by the system controller. table 6-21. tim16b8cv1 interrupts interrupt offset 1 1 chip dependent. vector 1 priority 1 source description c[7:4]f timer channel 7? active high timer channel interrupts 7? paovi pulse accumulator input active high pulse accumulator input interrupt paovf pulse accumulator over?w pulse accumulator over?w interrupt tof timer over?w timer over?w interrupt mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 205 chapter 7 analog-to-digital converter (atd10b8cv3) 7.1 introduction the atd10b8c is an 8-channel, 10-bit, multiplexed input successive approximation analog-to-digital converter. refer to device electrical speci?ations for atd accuracy. 7.1.1 features 8/10-bit resolution ? sec, 10-bit single conversion time sample buffer ampli?r programmable sample time left/right justi?d, signed/unsigned result data external trigger control conversion completion interrupt generation analog input multiplexer for 8 analog input channels analog/digital input pin multiplexing 1-to-8 conversion sequence lengths continuous conversion mode multiple channel scans con?urable external trigger functionality on any ad channel or any of four additional external trigger inputs. the four additional trigger inputs can be chip external or internal. refer to the device overview chapter for availability and connectivity. con?urable location for channel wrap around (when converting multiple channels in a sequence). 7.1.2 modes of operation 7.1.2.1 conversion modes there is software programmable selection between performing single or continuous conversion on a single channel or multiple channels. chapter 7 analog-to-digital converter (atd10b8cv3) mc9s12ne64 data sheet, rev. 1.1 206 freescale semiconductor 7.1.2.2 mcu operating modes stop mode entering stop mode causes all clocks to halt and thus the system is placed in a minimum power standby mode. this aborts any conversion sequence in progress. during recovery from stop mode, there must be a minimum delay for the stop recovery time t sr before initiating a new atd conversion sequence. wait mode entering wait mode the atd conversion either continues or aborts for low power depending on the logical value of the await bit. freeze mode in freeze mode the atd will behave according to the logical values of the frz1 and frz0 bits. this is useful for debugging and emulation. 7.1.3 block diagram figure 7-1 shows a block diagram of the atd. 7.2 external signal description this section lists all inputs to the atd block. 7.2.1 an x ( x = 7, 6, 5, 4, 3, 2, 1, 0) ?analog input pin this pin serves as the analog input channel x . it can also be con?ured as general purpose digital port pin and/or external trigger for the atd conversion. 7.2.2 etrig3, etrig2, etrig1, and etrig0 ?external trigger pins these inputs can be con?ured to serve as an external trigger for the atd conversion. refer to the device overview chapter for availability and connectivity of these inputs. 7.2.3 v rh and v rl ?high and low reference voltage pins v rh is the high reference voltage and v rl is the low reference voltage for atd conversion. 7.2.4 v dda and v ssa ?power supply pins these pins are the power supplies for the analog circuitry of the atd block. external signal description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 207 figure 7-1. atd block diagram v ssa atd10b8c analog mux mode and successive approximation register (sar) results atd 0 atd 1 atd 2 atd 3 atd 4 atd 5 atd 6 atd 7 and dac sample & hold 1 1 v dda v rl v rh sequence complete interrupt + comparator clock prescaler bus clock atd clock an7 an6 an5 an4 an3 an2 an1 an0 etrig0 (see device overview chapter for availability etrig1 etrig2 etrig3 and connectivity) timing control atddien atdctl1 portad trigger mux chapter 7 analog-to-digital converter (atd10b8cv3) mc9s12ne64 data sheet, rev. 1.1 208 freescale semiconductor 7.3 memory map and register de?ition this section provides a detailed description of all registers accessible in the atd. 7.3.1 module memory map figure 7-2 gives an overview of all atd registers. note register address = base address + address offset, where the base address is de?ed at the mcu level and the address offset is de?ed at the module level. 7.3.2 register descriptions this section describes in address order all the atd registers and their individual bits. register name bit 7 654321 bit 0 atdctl0 r 00000 wrap2 wrap1 wrap0 w atdctl1 r etrigsel 0000 etrigch2 etrigch1 etrigch0 w atdctl2 r adpu affc awai etrigle etrigp etrige ascie ascif w atdctl3 r 0 s8c s4c s2c s1c fifo frz1 frz0 w atdctl4 r sres8 smp1 smp0 prs4 prs3 prs2 prs1 prs0 w atdctl5 r djm dsgn scan mult 0 cc cb ca w atdstat0 r scf 0 etorf fifor 0 cc2 cc1 cc0 w unimplemente d r w atdtest0 r uuuuuuuu w atdtest1 r u u 00000 sc w = unimplemented or reserved figure 7-2. atd register summary (sheet 1 of 5) memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 209 unimplemente d r w atdstat1 r ccf7 ccf6 ccf5 ccf4 ccf3 ccf2 ccf1 ccf0 w unimplemente d r w atddien r ien7 ien6 ien5 ien4 ien3 ien2 ien1 ien0 w unimplemente d r w portad r ptad7 ptad6 ptad5 ptad4 ptad3 ptad2 ptad1 ptad0 w left justi?d result data note: the read portion of the left justi?d result data registers has been divided to show the bit position when reading 10-bit and 8-bit conversion data. for more detailed information refer to section 7.3.2.13, ?td conversion result registers (atddrx)? atddr0h 10-bit bit 9 msb bit 7 msb bit 8 bit 6 bit 7 bit 5 bit 6 bit 4 bit 5 bit 3 bit 4 bit 2 bit 3 bit 1 bit 2 bit 0 8-bit w atddr0l 10-bit bit 1 u bit 0 u 0 0 0 0 0 0 0 0 0 0 0 0 8-bit w atddr1h 10-bit bit 9 msb bit 7 msb bit 8 bit 6 bit 7 bit 5 bit 6 bit 4 bit 5 bit 3 bit 4 bit 2 bit 3 bit 1 bit 2 bit 0 8-bit w atddr1l 10-bit bit 1 u bit 0 u 0 0 0 0 0 0 0 0 0 0 0 0 8-bit w atddr2h 10-bit bit 9 msb bit 7 msb bit 8 bit 6 bit 7 bit 5 bit 6 bit 4 bit 5 bit 3 bit 4 bit 2 bit 3 bit 1 bit 2 bit 0 8-bit w atddr2l 10-bit bit 1 u bit 0 u 0 0 0 0 0 0 0 0 0 0 0 0 8-bit w atddr3h 10-bit bit 9 msb bit 7 msb bit 8 bit 6 bit 7 bit 5 bit 6 bit 4 bit 5 bit 3 bit 4 bit 2 bit 3 bit 1 bit 2 bit 0 8-bit w register name bit 7 654321 bit 0 = unimplemented or reserved figure 7-2. atd register summary (sheet 2 of 5) chapter 7 analog-to-digital converter (atd10b8cv3) mc9s12ne64 data sheet, rev. 1.1 210 freescale semiconductor atddr3l 10-bit bit 1 u bit 0 u 0 0 0 0 0 0 0 0 0 0 0 0 8-bit w atddr4h 10-bit bit 9 msb bit 7 msb bit 8 bit 6 bit 7 bit 5 bit 6 bit 4 bit 5 bit 3 bit 4 bit 2 bit 3 bit 1 bit 2 bit 0 8-bit w atddr4l 10-bit bit 1 u bit 0 u 0 0 0 0 0 0 0 0 0 0 0 0 8-bit w atdd45h 10-bit bit 9 msb bit 7 msb bit 8 bit 6 bit 7 bit 5 bit 6 bit 4 bit 5 bit 3 bit 4 bit 2 bit 3 bit 1 bit 2 bit 0 8-bit w atdd45l 10-bit bit 1 u bit 0 u 0 0 0 0 0 0 0 0 0 0 0 0 8-bit w atdd46h 10-bit bit 9 msb bit 7 msb bit 8 bit 6 bit 7 bit 5 bit 6 bit 4 bit 5 bit 3 bit 4 bit 2 bit 3 bit 1 bit 2 bit 0 8-bit w atddr6l 10-bit bit 1 u bit 0 u 0 0 0 0 0 0 0 0 0 0 0 0 8-bit w atdd47h 10-bit bit 9 msb bit 7 msb bit 8 bit 6 bit 7 bit 5 bit 6 bit 4 bit 5 bit 3 bit 4 bit 2 bit 3 bit 1 bit 2 bit 0 8-bit w atdd47l 10-bit bit 1 u bit 0 u 0 0 0 0 0 0 0 0 0 0 0 0 8-bit w right justi?d result data note: the read portion of the right justi?d result data registers has been divided to show the bit position when reading 10-bit and 8-bit conversion data. for more detailed information refer to section 7.3.2.13, ?td conversion result registers (atddrx)? atddr0h 10-bit 0 0 0 0 0 0 0 0 0 0 0 0 bit 9 msb 0 bit 8 0 8-bit w atddr0l 10-bit bit 7 bit 7 msb bit 6 bit 6 bit 5 bit 5 bit 4 bit 4 bit 3 bit 3 bit 2 bit 2 bit 1 bit 1 bit 0 bit 0 8-bit w register name bit 7 654321 bit 0 = unimplemented or reserved figure 7-2. atd register summary (sheet 3 of 5) memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 211 atddr1h 10-bit 0 0 0 0 0 0 0 0 0 0 0 0 bit 9 msb 0 bit 8 0 8-bit w atddr1l 10-bit bit 7 bit 7 msb bit 6 bit 6 bit 5 bit 5 bit 4 bit 4 bit 3 bit 3 bit 2 bit 2 bit 1 bit 1 bit 0 bit 0 8-bit w atddr2h 10-bit 0 0 0 0 0 0 0 0 0 0 0 0 bit 9 msb 0 bit 8 0 8-bit w atddr2l 10-bit bit 7 bit 7 msb bit 6 bit 6 bit 5 bit 5 bit 4 bit 4 bit 3 bit 3 bit 2 bit 2 bit 1 bit 1 bit 0 bit 0 8-bit w atddr3h 10-bit 0 0 0 0 0 0 0 0 0 0 0 0 bit 9 msb 0 bit 8 0 8-bit w atddr3l 10-bit bit 7 bit 7 msb bit 6 bit 6 bit 5 bit 5 bit 4 bit 4 bit 3 bit 3 bit 2 bit 2 bit 1 bit 1 bit 0 bit 0 8-bit w atddr4h 10-bit 0 0 0 0 0 0 0 0 0 0 0 0 bit 9 msb 0 bit 8 0 8-bit w atddr4l 10-bit bit 7 bit 7 msb bit 6 bit 6 bit 5 bit 5 bit 4 bit 4 bit 3 bit 3 bit 2 bit 2 bit 1 bit 1 bit 0 bit 0 8-bit w atdd45h 10-bit 0 0 0 0 0 0 0 0 0 0 0 0 bit 9 msb 0 bit 8 0 8-bit w atdd45l 10-bit bit 7 bit 7 msb bit 6 bit 6 bit 5 bit 5 bit 4 bit 4 bit 3 bit 3 bit 2 bit 2 bit 1 bit 1 bit 0 bit 0 8-bit w atdd46h 10-bit 0 0 0 0 0 0 0 0 0 0 0 0 bit 9 msb 0 bit 8 0 8-bit w atddr6l 10-bit bit 7 bit 7 msb bit 6 bit 6 bit 5 bit 5 bit 4 bit 4 bit 3 bit 3 bit 2 bit 2 bit 1 bit 1 bit 0 bit 0 8-bit w register name bit 7 654321 bit 0 = unimplemented or reserved figure 7-2. atd register summary (sheet 4 of 5) chapter 7 analog-to-digital converter (atd10b8cv3) mc9s12ne64 data sheet, rev. 1.1 212 freescale semiconductor 7.3.2.1 atd control register 0 (atdctl0) writes to this register will abort current conversion sequence but will not start a new sequence. read: anytime write: anytime atdd47h 10-bit 0 0 0 0 0 0 0 0 0 0 0 0 bit 9 msb 0 bit 8 0 8-bit w atdd47l 10-bit bit 7 bit 7 msb bit 6 bit 6 bit 5 bit 5 bit 4 bit 4 bit 3 bit 3 bit 2 bit 2 bit 1 bit 1 bit 0 bit 0 8-bit 76543210 r00000 wrap2 wrap1 wrap0 w reset 0 0 0 00111 = unimplemented or reserved figure 7-3. atd control register 0 (atdctl0) table 7-1. atdctl0 field descriptions field description 2? wrap[2:0] wrap around channel select bits ?these bits determine the channel for wrap around when doing multi-channel conversions. the coding is summarized in table 7-2 . table 7-2. multi-channel wrap around coding wrap2 wrap1 wrap0 multiple channel conversions (mult = 1) wrap around to an0 after converting 0 0 0 reserved 001 an1 010 an2 011 an3 100 an4 101 an5 110 an6 111 an7 register name bit 7 654321 bit 0 = unimplemented or reserved figure 7-2. atd register summary (sheet 5 of 5) memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 213 7.3.2.2 atd control register 1 (atdctl1) writes to this register will abort current conversion sequence but will not start a new sequence. read: anytime write: anytime 76543210 r etrigsel 0000 etrigch2 etrigch1 etrigch0 w reset 0 0 0 00111 = unimplemented or reserved figure 7-4. atd control register 1 (atdctl1) table 7-3. atdctl1 field descriptions field description 7 etrigsel external trigger source select ?this bit selects the external trigger source to be either one of the ad channels or one of the etrig3? inputs. see the device overview chapter for availability and connectivity of etrig3? inputs. if etrig3? input option is not available, writing a 1 to etrisel only sets the bit but has not effect, that means still one of the ad channels (selected by etrigch2?) is the source for external trigger. the coding is summarized in table 7-4 . 2? etrigch[2:0] external trigger channel select these bits select one of the ad channels or one of the etrig3? inputs as source for the external trigger. the coding is summarized in table 7-4 . table 7-4. external trigger channel select coding etrigsel etrigch2 etrigch1 etrigch0 external trigger source is 0 0 0 0 an0 0 0 0 1 an1 0 0 1 0 an2 0 0 1 1 an3 0 1 0 0 an4 0 1 0 1 an5 0 1 1 0 an6 0 1 1 1 an7 1 0 0 0 etrig0 1 1 only if etrig3? input option is available (see device overview chapter), else etrisel is ignored, that means external trigger source is still on one of the ad channels selected by etrigch2? 1 0 0 1 etrig1 1 1 0 1 0 etrig2 1 1 0 1 1 etrig3 1 1 1 x x reserved chapter 7 analog-to-digital converter (atd10b8cv3) mc9s12ne64 data sheet, rev. 1.1 214 freescale semiconductor 7.3.2.3 atd control register 2 (atdctl2) this register controls power down, interrupt and external trigger. writes to this register will abort current conversion sequence but will not start a new sequence. read: anytime write: anytime 76543210 r adpu affc awai etrigle etrigp etrige ascie ascif w reset 0 0 0 00000 = unimplemented or reserved figure 7-5. atd control register 2 (atdctl2) table 7-5. atdctl2 field descriptions field description 7 adpu atd power up ?this bit provides on/off control over the atd block allowing reduced mcu power consumption. because analog electronic is turned off when powered down, the atd requires a recovery time period after adpu bit is enabled. 0 power down atd 1 normal atd functionality 6 affc atd fast flag clear all 0 atd ?g clearing operates normally (read the status register atdstat1 before reading the result register to clear the associate ccf ?g). 1 changes all atd conversion complete ?gs to a fast clear sequence. any access to a result register will cause the associate ccf ?g to clear automatically. 5 awai atd power down in wait mode when entering wait mode this bit provides on/off control over the atd block allowing reduced mcu power. because analog electronic is turned off when powered down, the atd requires a recovery time period after exit from wait mode. 0 atd continues to run in wait mode 1 halt conversion and power down atd during wait mode after exiting wait mode with an interrupt conversion will resume. but due to the recovery time the result of this conversion should be ignored. 4 etrigle external trigger level/edge control ?this bit controls the sensitivity of the external trigger signal. see table 7-6 for details. 3 etrigp external trigger polarity ?this bit controls the polarity of the external trigger signal. see table 7-6 for details. 2 etrige external trigger mode enable ?this bit enables the external trigger on one of the ad channels or one of the etrig3? inputs as described in table 7-4 . if external trigger source is one of the ad channels, the digital input buffer of this channel is enabled. the external trigger allows to synchronize sample and atd conversions processes with external events. 0 disable external trigger 1 enable external trigger note: if using one of the ad channel as external trigger (etrigsel = 0) the conversion results for this channel have no meaning while external trigger mode is enabled. memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 215 7.3.2.4 atd control register 3 (atdctl3) this register controls the conversion sequence length, fifo for results registers and behavior in freeze mode. writes to this register will abort current conversion sequence but will not start a new sequence. read: anytime write: anytime 1 ascie atd sequence complete interrupt enable 0 atd sequence complete interrupt requests are disabled. 1 atd interrupt will be requested whenever ascif = 1 is set. 0 ascif atd sequence complete interrupt flag ?if ascie = 1 the ascif ?g equals the scf ?g (see section 7.3.2.7, ?td status register 0 (atdstat0) ), else ascif reads zero. writes have no effect. 0 no atd interrupt occurred 1 atd sequence complete interrupt pending table 7-6. external trigger con?urations etrigle etrigp external trigger sensitivity 0 0 falling edge 0 1 rising edge 1 0 low level 1 1 high level 76543210 r0 s8c s4c s2c s1c fifo frz1 frz0 w reset 0 0 0 00000 = unimplemented or reserved figure 7-6. atd control register 3 (atdctl3) table 7-7. atdctl3 field descriptions field description 6? s8c, s4c, s2c, s1c conversion sequence length these bits control the number of conversions per sequence. table 7-8 shows all combinations. at reset, s4c is set to 1 (sequence length is 4). this is to maintain software continuity to hc12 family. table 7-5. atdctl2 field descriptions (continued) field description chapter 7 analog-to-digital converter (atd10b8cv3) mc9s12ne64 data sheet, rev. 1.1 216 freescale semiconductor 2 fifo result register fifo mode if this bit is zero (non-fifo mode), the a/d conversion results map into the result registers based on the conversion sequence; the result of the ?st conversion appears in the ?st result register, the second result in the second result register, and so on. if this bit is one (fifo mode) the conversion counter is not reset at the beginning or ending of a conversion sequence; sequential conversion results are placed in consecutive result registers. in a continuously scanning conversion sequence, the result register counter will wrap around when it reaches the end of the result register ?e. the conversion counter value (cc2-0 in atdstat0) can be used to determine where in the result register ?e, the current conversion result will be placed. aborting a conversion or starting a new conversion by write to an atdctl register (atdctl5-0) clears the conversion counter even if fifo=1. so the ?st result of a new conversion sequence, started by writing to atdctl5, will always be place in the ?st result register (atdddr0). intended usage of fifo mode is continuos conversion (scan=1) or triggered conversion (etrig=1). finally, which result registers hold valid data can be tracked using the conversion complete ?gs. fast ?g clear mode may or may not be useful in a particular application to track valid data. 0 conversion results are placed in the corresponding result register up to the selected sequence length. 1 conversion results are placed in consecutive result registers (wrap around at end). 1? frz[1:0] background debug freeze enable when debugging an application, it is useful in many cases to have the atd pause when a breakpoint (freeze mode) is encountered. these 2 bits determine how the atd will respond to a breakpoint as shown in table 7-9 . leakage onto the storage node and comparator reference capacitors may compromise the accuracy of an immediately frozen conversion depending on the length of the freeze period. table 7-8. conversion sequence length coding s8c s4c s2c s1c number of conversions per sequence 0000 8 0001 1 0010 2 0011 3 0100 4 0101 5 0110 6 0111 7 1xxx 8 table 7-9. atd behavior in freeze mode (breakpoint) frz1 frz0 behavior in freeze mode 0 0 continue conversion 0 1 reserved 1 0 finish current conversion, then freeze 1 1 freeze immediately table 7-7. atdctl3 field descriptions (continued) field description memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 217 7.3.2.5 atd control register 4 (atdctl4) this register selects the conversion clock frequency, the length of the second phase of the sample time and the resolution of the a/d conversion (i.e.: 8-bits or 10-bits). writes to this register will abort current conversion sequence but will not start a new sequence. read: anytime write: anytime 76543210 r sres8 smp1 smp0 prs4 prs3 prs2 prs1 prs0 w reset 0 0 0 00101 figure 7-7. atd control register 4 (atdctl4) table 7-10. atdctl4 field descriptions field description 7 sres8 a/d resolution select ?this bit selects the resolution of a/d conversion results as either 8 or 10 bits. the a/d converter has an accuracy of 10 bits; however, if low resolution is required, the conversion can be speeded up by selecting 8-bit resolution. 0 10-bit resolution 8-bit resolution 6? smp[1:0] sample time select ?these two bits select the length of the second phase of the sample time in units of atd conversion clock cycles. note that the atd conversion clock period is itself a function of the prescaler value (bits prs4?). the sample time consists of two phases. the ?st phase is two atd conversion clock cycles long and transfers the sample quickly (via the buffer ampli?r) onto the a/d machine s storage node. the second phase attaches the external analog signal directly to the storage node for ?al charging and high accuracy. table 7-11 lists the lengths available for the second sample phase. 4? prs[4:0] atd clock prescaler these 5 bits are the binary value prescaler value prs. the atd conversion clock frequency is calculated as follows: note: the maximum atd conversion clock frequency is half the bus clock. the default (after reset) prescaler value is 5 which results in a default atd conversion clock frequency that is bus clock divided by 12. table 7-12 illustrates the divide-by operation and the appropriate range of the bus clock. table 7-11. sample time select smp1 smp0 length of 2nd phase of sample time 0 0 2 a/d conversion clock periods 0 1 4 a/d conversion clock periods 1 0 8 a/d conversion clock periods 1 1 16 a/d conversion clock periods atdclock busclock [] prs 1 + [] -------------------------------- - 0.5 = chapter 7 analog-to-digital converter (atd10b8cv3) mc9s12ne64 data sheet, rev. 1.1 218 freescale semiconductor table 7-12. clock prescaler values prescale value total divisor value max. bus clock 1 1 maximum atd conversion clock frequency is 2 mhz. the maximum allowed bus clock frequency is shown in this column. min. bus clock 2 2 minimum atd conversion clock frequency is 500 khz. the minimum allowed bus clock frequency is shown in this column. 00000 00001 00010 00011 00100 00101 00110 00111 01000 01001 01010 01011 01100 01101 01110 01111 10000 10001 10010 10011 10100 10101 10110 10111 11000 11001 11010 11011 11100 11101 11110 11111 divide by 2 divide by 4 divide by 6 divide by 8 divide by 10 divide by 12 divide by 14 divide by 16 divide by 18 divide by 20 divide by 22 divide by 24 divide by 26 divide by 28 divide by 30 divide by 32 divide by 34 divide by 36 divide by 38 divide by 40 divide by 42 divide by 44 divide by 46 divide by 48 divide by 50 divide by 52 divide by 54 divide by 56 divide by 58 divide by 60 divide by 62 divide by 64 4 mhz 8 mhz 12 mhz 16 mhz 20 mhz 24 mhz 28 mhz 32 mhz 36 mhz 40 mhz 44 mhz 48 mhz 52 mhz 56 mhz 60 mhz 64 mhz 68 mhz 72 mhz 76 mhz 80 mhz 84 mhz 88 mhz 92 mhz 96 mhz 100 mhz 104 mhz 108 mhz 112 mhz 116 mhz 120 mhz 124 mhz 128 mhz 1 mhz 2 mhz 3 mhz 4 mhz 5 mhz 6 mhz 7 mhz 8 mhz 9 mhz 10 mhz 11 mhz 12 mhz 13 mhz 14 mhz 15 mhz 16 mhz 17 mhz 18 mhz 19 mhz 20 mhz 21 mhz 22 mhz 23 mhz 24 mhz 25 mhz 26 mhz 27 mhz 28 mhz 29 mhz 30 mhz 31 mhz 32 mhz memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 219 7.3.2.6 atd control register 5 (atdctl5) this register selects the type of conversion sequence and the analog input channels sampled. writes to this register will abort current conversion sequence and start a new conversion sequence. read: anytime write: anytime 76543210 r djm dsgn scan mult 0 cc cb ca w reset 0 0 0 00000 = unimplemented or reserved figure 7-8. atd control register 5 (atdctl5) table 7-13. atdctl5 field descriptions field description 7 djm result register data justi?ation ?this bit controls justi?ation of conversion data in the result registers. see section 7.3.2.13, ?td conversion result registers (atddrx), for details. 0 left justi?d data in the result registers 1 right justi?d data in the result registers 6 dsgn result register data signed or unsigned representation this bit selects between signed and unsigned conversion data representation in the result registers. signed data is represented as 2 s complement. signed data is not available in right justi?ation. see section 7.3.2.13, ?td conversion result registers (atddrx), for details. 0 unsigned data representation in the result registers 1 signed data representation in the result registers table 7-14 summarizes the result data formats available and how they are set up using the control bits. table 7-15 illustrates the difference between the signed and unsigned, left justi?d output codes for an input signal range between 0 and 5.12 volts. 5 scan continuous conversion sequence mode ?this bit selects whether conversion sequences are performed continuously or only once. 0 single conversion sequence 1 continuous conversion sequences (scan mode) 4 mult multi-channel sample mode when mult is 0, the atd sequence controller samples only from the speci?d analog input channel for an entire conversion sequence. the analog channel is selected by channel selection code (control bits cc/cb/ca located in atdctl5). when mult is 1, the atd sequence controller samples across channels. the number of channels sampled is determined by the sequence length value (s8c, s4c, s2c, s1c). the ?st analog channel examined is determined by channel selection code (cc, cb, ca control bits); subsequent channels sampled in the sequence are determined by incrementing the channel selection code. 0 sample only one channel 1 sample across several channels 2? cc, cb, ca analog input channel select code ?these bits select the analog input channel(s) whose signals are sampled and converted to digital codes. table 7-16 lists the coding used to select the various analog input channels. in the case of single channel scans (mult = 0), this selection code speci?d the channel examined. in the case of multi-channel scans (mult = 1), this selection code represents the ?st channel to be examined in the conversion sequence. subsequent channels are determined by incrementing channel selection code; selection codes that reach the maximum value wrap around to the minimum value. chapter 7 analog-to-digital converter (atd10b8cv3) mc9s12ne64 data sheet, rev. 1.1 220 freescale semiconductor table 7-14. available result data formats sres8 djm dsgn result data formats description and bus bit mapping 1 1 1 0 0 0 0 0 1 0 0 1 0 1 x 0 1 x 8-bit / left justi?d / unsigned ?bits 8?5 8-bit / left justi?d / signed ?bits 8?5 8-bit / right justi?d / unsigned ?bits 0? 10-bit / left justi?d / unsigned ?bits 6?5 10-bit / left justi?d / signed ?bits 6?5 10-bit / right justi?d / unsigned ?bits 0? table 7-15. left justi?d, signed, and unsigned atd output codes input signal v rl = 0 volts v rh = 5.12 volts signed 8-bit codes unsigned 8-bit codes signed 10-bit codes unsigned 10-bit codes 5.120 volts 5.100 5.080 2.580 2.560 2.540 0.020 0.000 7f 7f 7e 01 00 ff 81 80 ff ff fe 81 80 7f 01 00 7fc0 7f00 7e00 0100 0000 ff00 8100 8000 ffc0 ff00 fe00 8100 8000 7f00 0100 0000 table 7-16. analog input channel select coding cc cb ca analog input channel 0 0 0 an0 0 0 1 an1 0 1 0 an2 0 1 1 an3 1 0 0 an4 1 0 1 an5 1 1 0 an6 1 1 1 an7 memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 221 7.3.2.7 atd status register 0 (atdstat0) this read-only register contains the sequence complete ?g, overrun ?gs for external trigger and fifo mode, and the conversion counter. read: anytime write: anytime (no effect on (cc2, cc1, cc0)) 76543210 r scf 0 etorf fifor 0 cc2 cc1 cc0 w reset 0 0 0 00000 = unimplemented or reserved figure 7-9. atd status register 0 (atdstat0) table 7-17. atdstat0 field descriptions field description 7 scf sequence complete flag ?this ?g is set upon completion of a conversion sequence. if conversion sequences are continuously performed (scan = 1), the ?g is set after each one is completed. this ?g is cleared when one of the following occurs: a) write ??to scf b) write to atdctl5 (a new conversion sequence is started) c) if affc=1 and read of a result register 0 conversion sequence not completed 1 conversion sequence has completed 5 etorf external trigger overrun flag ?while in edge trigger mode (etrigle = 0), if additional active edges are detected while a conversion sequence is in process the overrun ?g is set. this ?g is cleared when one of the following occurs: a) write ??to etorf b) write to atdctl2, atdctl3 or atdctl4 (a conversion sequence is aborted) c) write to atdctl5 (a new conversion sequence is started) 0 no external trigger over run error has occurred 1 external trigger over run error has occurred 4 fifor fifo over run flag ?this bit indicates that a result register has been written to before its associated conversion complete ?g (ccf) has been cleared. this ?g is most useful when using the fifo mode because the ?g potentially indicates that result registers are out of sync with the input channels. however, it is also practical for non-fifo modes, and indicates that a result register has been over written before it has been read (i.e., the old data has been lost). this ?g is cleared when one of the following occurs: a) write ??to fifor b) start a new conversion sequence (write to atdctl5 or external trigger) 0 no over run has occurred 1 an over run condition exists 2? cc[2:0] conversion counter these 3 read-only bits are the binary value of the conversion counter. the conversion counter points to the result register that will receive the result of the current conversion. e.g. cc2 = 1, cc1 = 1, cc0 = 0 indicates that the result of the current conversion will be in atd result register 6. if in non-fifo mode (fifo = 0) the conversion counter is initialized to zero at the begin and end of the conversion sequence. if in fifo mode (fifo = 1) the register counter is not initialized. the conversion counters wraps around when its maximum value is reached. aborting a conversion or starting a new conversion by write to an atdctl register (atdctl5-0) clears the conversion counter even if fifo=1. chapter 7 analog-to-digital converter (atd10b8cv3) mc9s12ne64 data sheet, rev. 1.1 222 freescale semiconductor 7.3.2.8 reserved register (atdtest0) read: anytime, returns unpredictable values write: anytime in special modes, unimplemented in normal modes note writing to this register when in special modes can alter functionality. 7.3.2.9 atd test register 1 (atdtest1) this register contains the sc bit used to enable special channel conversions. read: anytime, returns unpredictable values for bit7 and bit6 write: anytime 76543210 ruuuuuuuu w reset 1 0 0 00000 = unimplemented or reserved figure 7-10. reserved register (atdtest0) 76543210 ruu00000 sc w reset 0 0 0 00000 = unimplemented or reserved figure 7-11. atd test register 1 (atdtest1) table 7-18. atdtest1 field descriptions field description 0 sc special channel conversion bit if this bit is set, then special channel conversion can be selected using cc, cb and ca of atdctl5. table 7-19 lists the coding. 0 special channel conversions disabled 1 special channel conversions enabled note: always write remaining bits of atdtest1 (bit7 to bit1) zero when writing sc bit. not doing so might result in unpredictable atd behavior. table 7-19. special channel select coding sc cc cb ca analog input channel 1 0 x x reserved 11 0 0 v rh 11 0 1 v rl 11 1 0 (v rh +v rl ) / 2 1 1 1 1 reserved memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 223 7.3.2.10 atd status register 1 (atdstat1) this read-only register contains the conversion complete ?gs. read: anytime write: anytime, no effect 76543210 r ccf7 ccf6 ccf5 ccf4 ccf3 ccf2 ccf1 ccf0 w reset 0 0 0 00000 = unimplemented or reserved figure 7-12. atd status register 1 (atdstat1) table 7-20. atdstat1 field descriptions field description 7? ccf[7:0] conversion complete flag x (x = 7, 6, 5, 4, 3, 2, 1, 0) a conversion complete ?g is set at the end of each conversion in a conversion sequence. the ?gs are associated with the conversion position in a sequence (and also the result register number). therefore, ccf0 is set when the ?st conversion in a sequence is complete and the result is available in result register atddr0; ccf1 is set when the second conversion in a sequence is complete and the result is available in atddr1, and so forth. a ?g ccfx (x = 7, 6, 5, 4, 3, 2,1, 70) is cleared when one of the following occurs: a) write to atdctl5 (a new conversion sequence is started) b) if affc=0 and read of atdstat1 followed by read of result register atddrx c) if affc=1 and read of result register atddrx in case of a concurrent set and clear on ccfx: the clearing by method a) will overwrite the set. the clearing by methods b) or c) will be overwritten by the set. 0 conversion number x not completed 1 conversion number x has completed, result ready in atddrx chapter 7 analog-to-digital converter (atd10b8cv3) mc9s12ne64 data sheet, rev. 1.1 224 freescale semiconductor 7.3.2.11 atd input enable register (atddien) read: anytime write: anytime 7.3.2.12 port data register (portad) the data port associated with the atd can be con?ured as general-purpose i/o or input only, as speci?d in the device overview. the port pins are shared with the analog a/d inputs an7?. read: anytime write: anytime, no effect the a/d input channels may be used for general purpose digital input. 76543210 r ien7 ien6 ien5 ien4 ien3 ien2 ien1 ien0 w reset 0 0 0 00000 figure 7-13. atd input enable register (atddien) table 7-21. atddien field descriptions field description 7? ien[7:0] atd digital input enable on channel x (x = 7, 6, 5, 4, 3, 2, 1, 0) this bit controls the digital input buffer from the analog input pin (anx) to ptadx data register. 0 disable digital input buffer to ptadx 1 enable digital input buffer to ptadx. note: setting this bit will enable the corresponding digital input buffer continuously. if this bit is set while simultaneously using it as an analog port, there is potentially increased power consumption because the digital input buffer maybe in the linear region. 76543210 r ptad7 ptad6 ptad5 ptad4 ptad3 ptad2 ptad1 ptad0 w reset 1 1 1 11111 pin function an7 an6 an5 an4 an3 an2 an1 an0 = unimplemented or reserved figure 7-14. port data register (portad) table 7-22. portad field descriptions field description 7? ptad[7:0] a/d channel x (anx) digital input (x = 7, 6, 5, 4, 3, 2, 1, 0) if the digital input buffer on the anx pin is enabled (ienx = 1) or channel x is enabled as external trigger (etrige = 1,etrigch[2?] = x,etrigsel = 0) read returns the logic level on anx pin (signal potentials not meeting v il or v ih speci?ations will have an indeterminate value). if the digital input buffers are disabled (ienx = 0) and channel x is not enabled as external trigger, read returns a ?? reset sets all portad0 bits to ?? memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 225 7.3.2.13 atd conversion result registers (atddrx) the a/d conversion results are stored in 8 read-only result registers. the result data is formatted in the result registers based on two criteria. first there is left and right justi?ation; this selection is made using the djm control bit in atdctl5. second there is signed and unsigned data; this selection is made using the dsgn control bit in atdctl5. signed data is stored in 2 s complement format and only exists in left justi?d format. signed data selected for right justi?d format is ignored. read: anytime write: anytime in special mode, unimplemented in normal modes 7.3.2.13.1 left justi?d result data 7.3.2.13.2 right justi?d result data 76543210 r r bit 9 msb bit 7 msb bit 8 bit 6 bit 7 bit 5 bit 6 bit 4 bit 5 bit 3 bit 4 bit 2 bit 3 bit 1 bit 2 bit 0 10-bit data 8-bit data w reset 0 0 0 0 0 0 0 0 = unimplemented or reserved figure 7-15. left justi?d, atd conversion result register, high byte (atddrxh) 76543210 r r bit 1 u bit 0 u 0 0 0 0 0 0 0 0 0 0 0 0 w reset 0 0 0 0 0 0 0 0 = unimplemented or reserved figure 7-16. left justi?d, atd conversion result register, low byte (atddrxl) 76543210 r r 0 0 0 0 0 0 0 0 0 0 0 0 bit 9 msb 0 bit 8 0 10-bit data 8-bit data w reset 0 0 0 0 0 0 0 0 = unimplemented or reserved figure 7-17. right justi?d, atd conversion result register, high byte (atddrxh) 76543210 r r bit 7 bit 7 msb bit 6 bit 6 bit 5 bit 5 bit 4 bit 4 bit 3 bit 3 bit 2 bit 2 bit 1 bit 1 bit 0 bit 0 10-bit data 8-bit data w reset 0 0 0 0 0 0 0 0 = unimplemented or reserved figure 7-18. right justi?d, atd conversion result register, low byte (atddrxl) chapter 7 analog-to-digital converter (atd10b8cv3) mc9s12ne64 data sheet, rev. 1.1 226 freescale semiconductor 7.4 functional description the atd is structured in an analog and a digital sub-block. 7.4.1 analog sub-block the analog sub-block contains all analog electronics required to perform a single conversion. separate power supplies v dda and v ssa allow to isolate noise of other mcu circuitry from the analog sub-block. 7.4.1.1 sample and hold machine the sample and hold (s/h) machine accepts analog signals from the external surroundings and stores them as capacitor charge on a storage node. the sample process uses a two stage approach. during the ?st stage, the sample ampli?r is used to quickly charge the storage node.the second stage connects the input directly to the storage node to complete the sample for high accuracy. when not sampling, the sample and hold machine disables its own clocks. the analog electronics still draw their quiescent current. the power down (adpu) bit must be set to disable both the digital clocks and the analog power consumption. the input analog signals are unipolar and must fall within the potential range of v ssa to v dda . 7.4.1.2 analog input multiplexer the analog input multiplexer connects one of the 8 external analog input channels to the sample and hold machine. 7.4.1.3 sample buffer ampli?r the sample ampli?r is used to buffer the input analog signal so that the storage node can be quickly charged to the sample potential. 7.4.1.4 analog-to-digital (a/d) machine the a/d machine performs analog to digital conversions. the resolution is program selectable at either 8 or 10 bits. the a/d machine uses a successive approximation architecture. it functions by comparing the stored analog sample potential with a series of digitally generated analog potentials. by following a binary search algorithm, the a/d machine locates the approximating potential that is nearest to the sampled potential. when not converting the a/d machine disables its own clocks. the analog electronics still draws quiescent current. the power down (adpu) bit must be set to disable both the digital clocks and the analog power consumption. only analog input signals within the potential range of v rl to v rh (a/d reference potentials) will result in a non-railed digital output codes. functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 227 7.4.2 digital sub-block this subsection explains some of the digital features in more detail. see register descriptions for all details. 7.4.2.1 external trigger input the external trigger feature allows the user to synchronize atd conversions to the external environment events rather than relying on software to signal the atd module when atd conversions are to take place. the external trigger signal (out of reset atd channel 7, con?urable in atdctl1) is programmable to be edge or level sensitive with polarity control. table 7-23 gives a brief description of the different combinations of control bits and their effect on the external trigger function. during a conversion, if additional active edges are detected the overrun error ?g etorf is set. in either level or edge triggered modes, the ?st conversion begins when the trigger is received. in both cases, the maximum latency time is one bus clock cycle plus any skew or delay introduced by the trigger circuitry. note the conversion results for the external trigger atd channel 7 have no meaning while external trigger mode is enabled. once etrige is enabled, conversions cannot be started by a write to atdctl5, but rather must be triggered externally. if the level mode is active and the external trigger both de-asserts and re-asserts itself during a conversion sequence, this does not constitute an overrun; therefore, the ?g is not set. if the trigger is left asserted in level mode while a sequence is completing, another sequence will be triggered immediately. table 7-23. external trigger control bits etrigle etrigp etrige scan description x x 0 0 ignores external trigger. performs one conversion sequence and stops. x x 0 1 ignores external trigger. performs continuous conversion sequences. 0 0 1 x falling edge triggered. performs one conversion sequence per trigger. 0 1 1 x rising edge triggered. performs one conversion sequence per trigger. 1 0 1 x trigger active low. performs continuous conversions while trigger is active. 1 1 1 x trigger active high. performs continuous conversions while trigger is active. chapter 7 analog-to-digital converter (atd10b8cv3) mc9s12ne64 data sheet, rev. 1.1 228 freescale semiconductor 7.4.2.2 general purpose digital input port operation the input channel pins can be multiplexed between analog and digital data. as analog inputs, they are multiplexed and sampled to supply signals to the a/d converter. as digital inputs, they supply external input data that can be accessed through the digital port register portad (input-only). the analog/digital multiplex operation is performed in the input pads. the input pad is always connected to the analog inputs of the atd. the input pad signal is buffered to the digital port registers. this buffer can be turned on or off with the atddien register. this is important so that the buffer does not draw excess current when analog potentials are presented at its input. 7.4.2.3 low power modes the atd can be con?ured for lower mcu power consumption in 3 different ways: 1. stop mode: this halts a/d conversion. exit from stop mode will resume a/d conversion, but due to the recovery time the result of this conversion should be ignored. 2. wait mode with awai = 1: this halts a/d conversion. exit from wait mode will resume a/d conversion, but due to the recovery time the result of this conversion should be ignored. 3. writing adpu = 0 (note that all atd registers remain accessible.): this aborts any a/d conversion in progress. note that the reset value for the adpu bit is zero. therefore, when this module is reset, it is reset into the power down state. 7.5 resets at reset the atd is in a power down state. the reset state of each individual bit is listed within the register description section (see section 7.3, ?emory map and register de?ition ), which details the registers and their bit-?ld. 7.6 interrupts the interrupt requested by the atd is listed in table 7-24 . refer to the device overview chapter for related vector address and priority. see register descriptions for further details. table 7-24. atd interrupt vectors interrupt source ccr mask local enable sequence complete interrupt i bit ascie in atdctl2 mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 229 chapter 8 serial communication interface (sciv3) 8.1 introduction this block description chapter provides an overview of serial communication interface (sci) module. the sci allows full duplex, asynchronous, serial communication between the cpu and remote devices, including other cpus. the sci transmitter and receiver operate independently, although they use the same baud rate generator. the cpu monitors the status of the sci, writes the data to be transmitted, and processes received data. 8.1.1 glossary ir: infrared irda: infrared design association irq: interrupt request lsb: least signi?ant bit msb: most signi?ant bit nrz: non-return-to-zero rzi: return-to-zero-inverted rxd: receive pin sci: serial communication interface txd: transmit pin 8.1.2 features the sci includes these distinctive features: full-duplex or single-wire operation standard mark/space non-return-to-zero (nrz) format selectable irda 1.4 return-to-zero-inverted (rzi) format with programmable pulse widths 13-bit baud rate selection programmable 8-bit or 9-bit data format separately enabled transmitter and receiver programmable transmitter output parity two receiver wakeup methods: idle line wakeup address mark wakeup chapter 8 serial communication interface (sciv3) mc9s12ne64 data sheet, rev. 1.1 230 freescale semiconductor interrupt-driven operation with eight flags: transmitter empty transmission complete receiver full idle receiver input receiver overrun noise error framing error parity error receiver framing error detection hardware parity checking 1/16 bit-time noise detection 8.1.3 modes of operation the sci functions the same in normal, special, and emulation modes. it has two low-power modes, wait and stop modes. 8.1.3.1 run mode normal mode of operation. 8.1.3.2 wait mode sci operation in wait mode depends on the state of the sciswai bit in the sci control register 1 (scicr1). if sciswai is clear, the sci operates normally when the cpu is in wait mode. if sciswai is set, sci clock generation ceases and the sci module enters a power-conservation state when the cpu is in wait mode. setting sciswai does not affect the state of the receiver enable bit, re, or the transmitter enable bit, te. if sciswai is set, any transmission or reception in progress stops at wait mode entry. the transmission or reception resumes when either an internal or external interrupt brings the cpu out of wait mode. exiting wait mode by reset aborts any transmission or reception in progress and resets the sci. 8.1.3.3 stop mode the sci is inactive during stop mode for reduced power consumption. the stop instruction does not affect the sci register states, but the sci bus clock will be disabled. the sci operation resumes after an external interrupt brings the cpu out of stop mode. exiting stop mode by reset aborts any transmission or reception in progress and resets the sci. introduction mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 231 8.1.4 block diagram figure 8-1 is a high level block diagram of the sci module, showing the interaction of various function blocks. figure 8-1. sci block diagram sci data register receive shift register receive & wakeup control data format control transmit control transmit shift register sci data register baud generator irq generation irq generation rxd data in 16 bus clk encoder infrared data out txd decoder infrared tc interrupt request idle interrupt request sci interrupt request rdrf/or interrupt request tdre interrupt request chapter 8 serial communication interface (sciv3) mc9s12ne64 data sheet, rev. 1.1 232 freescale semiconductor 8.2 external signal descriptions the sci module has a total of two external pins. 8.2.1 txd ?sci transmit pin the txd pin transmits sci (standard or infrared) data. it will idle high in either mode and is high impedance anytime the transmitter is disabled. 8.2.2 rxd ?sci receive pin the rxd pin receives sci (standard or infrared) data. an idle line is detected as a line high. this input is ignored when the receiver is disabled and should be terminated to a known voltage. 8.3 memory map and register de?ition this subsection provides a detailed description of all the sci registers. 8.3.1 module memory map the memory map for the sci module is given in figure 8-2 . the address listed for each register is the address offset. the total address for each register is the sum of the base address for the sci module and the address offset for each register. 8.3.2 register descriptions this subsection consists of register descriptions in address order. each description includes a standard register diagram with an associated ?ure number. writes to reserved register locations do not have any effect and reads of these locations return a 0. details of register bit and ?ld function follow the register diagrams, in bit order. register name bit 7 654321 bit 0 scibdh r iren tnp1 tnp0 sbr12 sbr11 sbr10 sbr9 sbr8 w scibdl r sbr7 sbr6 sbr5 sbr4 sbr3 sbr2 sbr1 sbr0 w scicr1 r loops sciswai rsrc m wake ilt pe pt w = unimplemented or reserved figure 8-2. sci registers summary memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 233 scicr2 r tie tcie rie ilie te re rwu sbk w scisr1 r tdre tc rdrf idle or nf fe pf w scisr2 r 00000 brk13 txdir raf w scidrh r r8 t8 000000 w scidrl r r7 r6 r5 r4 r3 r2 r1 r0 wt7t6t5t4t3t2t1t0 register name bit 7 654321 bit 0 = unimplemented or reserved figure 8-2. sci registers summary chapter 8 serial communication interface (sciv3) mc9s12ne64 data sheet, rev. 1.1 234 freescale semiconductor 8.3.2.1 sci baud rate registers (scibdh and scibdl) read: anytime 76543210 r iren tnp1 tnp0 sbr12 sbr11 sbr10 sbr9 sbr8 w reset 0 0 0 00000 figure 8-3. sci baud rate register high (scibdh) table 8-1. scibdh field descriptions field description 7 iren infrared enable bit ?this bit enables/disables the infrared modulation/demodulation submodule. 0 ir disabled 1 ir enabled 6:5 tnp[1:0] transmitter narrow pulse bits these bits determine if the sci will transmit a 1/16, 3/16 or 1/32 narrow pulse. refer to table 8-3 . 4:0 sbr[11:8] sci baud rate bits ?the baud rate for the sci is determined by the bits in this register. the baud rate is calculated two different ways depending on the state of the iren bit. the formulas for calculating the baud rate are: when iren = 0 then, sci baud rate = sci module clock / (16 x sbr[12:0]) when iren = 1 then, sci baud rate = sci module clock / (32 x sbr[12:1]) 76543210 r sbr7 sbr6 sbr5 sbr4 sbr3 sbr2 sbr1 sbr0 w reset 0 0 0 00100 figure 8-4. sci baud rate register low (scibdl) table 8-2. scibdl field descriptions field description 7:0 sbr[7:0] sci baud rate bits ?the baud rate for the sci is determined by the bits in this register. the baud rate is calculated two different ways depending on the state of the iren bit. the formulas for calculating the baud rate are: when iren = 0 then, sci baud rate = sci module clock / (16 x sbr[12:0]) when iren = 1 then, sci baud rate = sci module clock / (32 x sbr[12:1]) memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 235 note if only scibdh is written to, a read will not return the correct data until scibdl is written to as well, following a write to scibdh. write: anytime the sci baud rate register is used to determine the baud rate of the sci and to control the infrared modulation/demodulation submodule. note the baud rate generator is disabled after reset and not started until the te bit or the re bit is set for the ?st time. the baud rate generator is disabled when (sbr[12:0] = 0 and iren = 0) or (sbr[12:1] = 0 and iren = 1). writing to scibdh has no effect without writing to scibdl, because writing to scibdh puts the data in a temporary location until scibdl is written to. 8.3.2.2 sci control register 1 (scicr1) read: anytime write: anytime table 8-3. irsci transmit pulse width tnp[1:0] narrow pulse width 11 reserved 10 1/32 01 1/16 00 3/16 76543210 r loops sciswai rsrc m wake ilt pe pt w reset 0 0 0 00000 figure 8-5. sci control register 1 (scicr1) chapter 8 serial communication interface (sciv3) mc9s12ne64 data sheet, rev. 1.1 236 freescale semiconductor table 8-4. scicr1 field descriptions field description 7 loops loop select bit loops enables loop operation. in loop operation, the rxd pin is disconnected from the sci and the transmitter output is internally connected to the receiver input. both the transmitter and the receiver must be enabled to use the loop function. 0 normal operation enabled 1 loop operation enabled the receiver input is determined by the rsrc bit. 6 sciswai sci stop in wait mode bit ?sciswai disables the sci in wait mode. 0 sci enabled in wait mode 1 sci disabled in wait mode 5 rsrc receiver source bit ?when loops = 1, the rsrc bit determines the source for the receiver shift register input. 0 receiver input internally connected to transmitter output 1 receiver input connected externally to transmitter refer to table 8-5 . 4 m data format mode bit ?mode determines whether data characters are eight or nine bits long. 0 one start bit, eight data bits, one stop bit 1 one start bit, nine data bits, one stop bit 3 wake wakeup condition bit wake determines which condition wakes up the sci: a logic 1 (address mark) in the most signi?ant bit position of a received data character or an idle condition on the rxd pin. 0 idle line wakeup 1 address mark wakeup 2 ilt idle line type bit ?ilt determines when the receiver starts counting logic 1s as idle character bits. the counting begins either after the start bit or after the stop bit. if the count begins after the start bit, then a string of logic 1s preceding the stop bit may cause false recognition of an idle character. beginning the count after the stop bit avoids false idle character recognition, but requires properly synchronized transmissions. 0 idle character bit count begins after start bit 1 idle character bit count begins after stop bit 1 pe parity enable bit pe enables the parity function. when enabled, the parity function inserts a parity bit in the most signi?ant bit position. 0 parity function disabled 1 parity function enabled 0 pt parity type bit pt determines whether the sci generates and checks for even parity or odd parity. with even parity, an even number of 1s clears the parity bit and an odd number of 1s sets the parity bit. with odd parity, an odd number of 1s clears the parity bit and an even number of 1s sets the parity bit. 0 even parity 1 odd parity table 8-5. loop functions loops rsrc function 0 x normal operation 1 0 loop mode with transmitter output internally connected to receiver input 1 1 single-wire mode with txd pin connected to receiver input memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 237 8.3.2.3 sci control register 2 (scicr2) read: anytime write: anytime 76543210 r tie tcie rie ilie te re rwu sbk w reset 00000000 figure 8-6. sci control register 2 (scicr2) table 8-6. scicr2 field descriptions field description 7 tie transmitter interrupt enable bit ?ie enables the transmit data register empty ?g, tdre, to generate interrupt requests. 0 tdre interrupt requests disabled 1 tdre interrupt requests enabled 6 tcie transmission complete interrupt enable bit tcie enables the transmission complete ?g, tc, to generate interrupt requests. 0 tc interrupt requests disabled 1 tc interrupt requests enabled 5 rie receiver full interrupt enable bit rie enables the receive data register full ?g, rdrf, or the overrun ?g, or, to generate interrupt requests. 0 rdrf and or interrupt requests disabled 1 rdrf and or interrupt requests enabled 4 ilie idle line interrupt enable bit ?ilie enables the idle line ?g, idle, to generate interrupt requests. 0 idle interrupt requests disabled 1 idle interrupt requests enabled 3 te transmitter enable bit ?te enables the sci transmitter and con?ures the txd pin as being controlled by the sci. the te bit can be used to queue an idle preamble. 0 transmitter disabled 1 transmitter enabled 2 re receiver enable bit ?re enables the sci receiver. 0 receiver disabled 1 receiver enabled 1 rwu receiver wakeup bit ?standby state 0 normal operation. 1 rwu enables the wakeup function and inhibits further receiver interrupt requests. normally, hardware wakes the receiver by automatically clearing rwu. 0 sbk send break bit ?toggling sbk sends one break character (10 or 11 logic 0s, respectively 13 or 14 logics 0s if brk13 is set). toggling implies clearing the sbk bit before the break character has ?ished transmitting. as long as sbk is set, the transmitter continues to send complete break characters (10 or 11 bits, respectively 13 or 14 bits). 0 no break characters 1 transmit break characters chapter 8 serial communication interface (sciv3) mc9s12ne64 data sheet, rev. 1.1 238 freescale semiconductor 8.3.2.4 sci status register 1 (scisr1) the scisr1 and scisr2 registers provide inputs to the mcu for generation of sci interrupts. also, these registers can be polled by the mcu to check the status of these bits. the flag-clearing procedures require that the status register be read followed by a read or write to the sci data register. it is permissible to execute other instructions between the two steps as long as it does not compromise the handling of i/o. note that the order of operations is important for flag clearing. read: anytime write: has no meaning or effect 76543210 r tdre tc rdrf idle or nf fe pf w reset 1 1 0 00000 = unimplemented or reserved figure 8-7. sci status register 1 (scisr1) table 8-7. scisr1 field descriptions field description 7 tdre transmit data register empty flag ?tdre is set when the transmit shift register receives a byte from the sci data register. when tdre is 1, the transmit data register (scidrh/l) is empty and can receive a new value to transmit.clear tdre by reading sci status register 1 (scisr1), with tdre set and then writing to sci data register low (scidrl). 0 no byte transferred to transmit shift register 1 byte transferred to transmit shift register; transmit data register empty 6 tc transmit complete flag tc is set low when there is a transmission in progress or when a preamble or break character is loaded. tc is set high when the tdre ?g is set and no data, preamble, or break character is being transmitted.when tc is set, the txd pin becomes idle (logic 1). clear tc by reading sci status register 1 (scisr1) with tc set and then writing to sci data register low (scidrl). tc is cleared automatically when data, preamble, or break is queued and ready to be sent. tc is cleared in the event of a simultaneous set and clear of the tc ?g (transmission not complete). 0 transmission in progress 1 no transmission in progress 5 rdrf receive data register full flag rdrf is set when the data in the receive shift register transfers to the sci data register. clear rdrf by reading sci status register 1 (scisr1) with rdrf set and then reading sci data register low (scidrl). 0 data not available in sci data register 1 received data available in sci data register 4 idle idle line flag 1 idle is set when 10 consecutive logic 1s (if m = 0) or 11 consecutive logic 1s (if m = 1) appear on the receiver input. after the idle ?g is cleared, a valid frame must again set the rdrf ?g before an idle condition can set the idle ?g.clear idle by reading sci status register 1 (scisr1) with idle set and then reading sci data register low (scidrl). 0 receiver input is either active now or has never become active since the idle ?g was last cleared 1 receiver input has become idle memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 239 3 or overrun flag 2 ?or is set when software fails to read the sci data register before the receive shift register receives the next frame. the or bit is set immediately after the stop bit has been completely received for the second frame. the data in the shift register is lost, but the data already in the sci data registers is not affected. clear or by reading sci status register 1 (scisr1) with or set and then reading sci data register low (scidrl). 0 no overrun 1 overrun 2 nf noise flag nf is set when the sci detects noise on the receiver input. nf bit is set during the same cycle as the rdrf ?g but does not get set in the case of an overrun. clear nf by reading sci status register 1(scisr1), and then reading sci data register low (scidrl). 0 no noise 1 noise 1 fe framing error flag fe is set when a logic 0 is accepted as the stop bit. fe bit is set during the same cycle as the rdrf ?g but does not get set in the case of an overrun. fe inhibits further data reception until it is cleared. clear fe by reading sci status register 1 (scisr1) with fe set and then reading the sci data register low (scidrl). 0 no framing error 1 framing error 0 pf parity error flag pf is set when the parity enable bit (pe) is set and the parity of the received data does not match the parity type bit (pt). pf bit is set during the same cycle as the rdrf ?g but does not get set in the case of an overrun. clear pf by reading sci status register 1 (scisr1), and then reading sci data register low (scidrl). 0 no parity error 1 parity error 1 when the receiver wakeup bit (rwu) is set, an idle line condition does not set the idle ?g. 2 the or ?g may read back as set when rdrf ?g is clear. this may happen if the following sequence of events occurs: 1. after the ?st frame is received, read status register scisr1 (returns rdrf set and or ?g clear); 2. receive second frame without reading the ?st frame in the data register (the second frame is not received and or ?g is set); 3. read data register scidrl (returns ?st frame and clears rdrf ?g in the status register); 4. read status register scisr1 (returns rdrf clear and or set). event 3 may be at exactly the same time as event 2 or any time after. when this happens, a dummy scidrl read following event 4 will be required to clear the or ?g if further frames are to be received. table 8-7. scisr1 field descriptions (continued) field description chapter 8 serial communication interface (sciv3) mc9s12ne64 data sheet, rev. 1.1 240 freescale semiconductor 8.3.2.5 sci status register 2 (scisr2) read: anytime write: anytime 76543210 r00000 brk13 txdir raf w reset 0 0 0 00000 = unimplemented or reserved figure 8-8. sci status register 2 (scisr2) table 8-8. scisr2 field descriptions field description 2 brk13 break transmit character length ?this bit determines whether the transmit break character is 10 or 11 bit respectively 13 or 14 bits long. the detection of a framing error is not affected by this bit. 0 break character is 10 or 11 bit long 1 break character is 13 or 14 bit long 1 txdir transmitter pin data direction in single-wire mode ?this bit determines whether the txd pin is going to be used as an input or output, in the single-wire mode of operation. this bit is only relevant in the single-wire mode of operation. 0 txd pin to be used as an input in single-wire mode 1 txd pin to be used as an output in single-wire mode 0 raf receiver active flag raf is set when the receiver detects a logic 0 during the rt1 time period of the start bit search. raf is cleared when the receiver detects an idle character. 0 no reception in progress 1 reception in progress memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 241 8.3.2.6 sci data registers (scidrh and scidrl) read: anytime; reading accesses sci receive data register write: anytime; writing accesses sci transmit data register; writing to r8 has no effect note if the value of t8 is the same as in the previous transmission, t8 does not have to be rewritten.the same value is transmitted until t8 is rewritten in 8-bit data format, only sci data register low (scidrl) needs to be accessed. when transmitting in 9-bit data format and using 8-bit write instructions, write ?st to sci data register high (scidrh) then to scidrl. 76543210 rr8 t8 000000 w reset 0 0 0 00000 = unimplemented or reserved figure 8-9. sci data register high (scidrh) table 8-9. scidrh field descriptions field description 7 r8 received bit 8 ?r8 is the ninth data bit received when the sci is con?ured for 9-bit data format (m = 1). 6 t8 transmit bit 8 ?t8 is the ninth data bit transmitted when the sci is con?ured for 9-bit data format (m = 1). 76543210 rr7r6r5r4r3r2r1r0 w t7 t6 t5 t4 t3 t2 t1 t0 reset 0 0 0 00000 figure 8-10. sci data register low (scidrl) table 8-10. scidrl field descriptions field description 7:0 r[7:0] t[7:0} received bits 7 through 0 ?for 9-bit or 8-bit data formats transmit bits 7 through 0 ?for 9-bit or 8-bit formats chapter 8 serial communication interface (sciv3) mc9s12ne64 data sheet, rev. 1.1 242 freescale semiconductor 8.4 functional description this subsection provides a complete functional description of the sci block, detailing the operation of the design from the end user? perspective in a number of descriptions. figure 8-11 shows the structure of the sci module. the sci allows full duplex, asynchronous, serial communication between the cpu and remote devices, including other cpus. the sci transmitter and receiver operate independently, although they use the same baud rate generator. the cpu monitors the status of the sci, writes the data to be transmitted, and processes received data. figure 8-11. detailed sci block diagram sci data receive shift register sci data register transmit shift register register baud rate generator sbr12?br0 bus transmit control 16 receive and wakeup data format control control t8 pf fe nf rdrf idle tie or tcie tdre tc r8 raf loops rwu re pe ilt pt wake m clock ilie rie rxd rsrc sbk loops te rsrc iren r16xclk ir_rxd txd ir_txd r16xclk r32xclk tnp[1:0] iren transmit encoder receive decoder scrxd sctxd infrared infrared tc tdre rdrf/or idle sci interrupt request functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 243 8.4.1 infrared interface submodule this module provides the capability of transmitting narrow pulses to an ir led and receiving narrow pulses and transforming them to serial bits, which are sent to the sci. the irda physical layer specification defines a half-duplex infrared communication link for exchange data. the full standard includes data rates up to 16 mbits/s. this design covers only data rates between 2.4 kbits/s and 115.2 kbits/s. the infrared submodule consists of two major blocks: the transmit encoder and the receive decoder. the sci transmits serial bits of data which are encoded by the infrared submodule to transmit a narrow pulse for every 0 bit. no pulse is transmitted for every 1 bit. when receiving data, the ir pulses should be detected using an ir photo diode and transformed to cmos levels by the ir receive decoder (external from the mcu). the narrow pulses are then stretched by the infrared submodule to get back to a serial bit stream to be received by the sci. the polarity of transmitted pulses and expected receive pulses can be inverted so that a direct connection can be made to external irda transceiver modules that uses active low pulses. the infrared submodule receives its clock sources from the sci. one of these two clocks are selected in the infrared submodule in order to generate either 3/16, 1/16, or 1/32 narrow pulses during transmission. the infrared block receives two clock sources from the sci, r16xclk, and r32xclk, which are configured to generate the narrow pulse width during transmission. the r16xclk and r32xclk are internal clocks with frequencies 16 and 32 times the baud rate respectively. both r16xclk and r32xclk clocks are used for transmitting data. the receive decoder uses only the r16xclk clock. 8.4.1.1 infrared transmit encoder the infrared transmit encoder converts serial bits of data from transmit shift register to the txd pin. a narrow pulse is transmitted for a 0 bit and no pulse for a 1 bit. the narrow pulse is sent in the middle of the bit with a duration of 1/32, 1/16, or 3/16 of a bit time. 8.4.1.2 infrared receive decoder the infrared receive block converts data from the rxd pin to the receive shift register. a narrow pulse is expected for each 0 received and no pulse is expected for each 1 received. this receive decoder meets the edge jitter requirement as defined by the irda serial infrared physical layer specification. 8.4.2 data format the sci uses the standard nrz mark/space data format. when infrared is enabled, the sci uses rzi data format where 0s are represented by light pulses and 1s remain low. see figure 8-12 . chapter 8 serial communication interface (sciv3) mc9s12ne64 data sheet, rev. 1.1 244 freescale semiconductor figure 8-12. sci data formats each data character is contained in a frame that includes a start bit, eight or nine data bits, and a stop bit. clearing the m bit in sci control register 1 configures the sci for 8-bit data characters. a frame with eight data bits has a total of 10 bits. setting the m bit configures the sci for nine-bit data characters. a frame with nine data bits has a total of 11 bits when the sci is configured for 9-bit data characters, the ninth data bit is the t8 bit in sci data register high (scidrh). it remains unchanged after transmission and can be used repeatedly without rewriting it. a frame with nine data bits has a total of 11 bits. table 8-12. example of 9-bit data formats table 8-11. example of 8-bit data formats start bit data bits address bits parity bits stop bit 18001 17011 17 1 1 1 the address bit identi?s the frame as an address character. see section 8.4.5.6, ?eceiver wakeup . 01 start bit data bits address bits parity bits stop bit 19001 18011 18 1 1 1 the address bit identi?s the frame as an address character. see section 8.4.5.6, ?eceiver wakeup . 01 bit 5 start bit bit 0 bit 1 next stop bit start bit 8-bit data format (bit m in scicr1 clear) start bit bit 0 next stop bit start bit 9-bit data format (bit m in scicr1 set) bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 bit 8 bit 2 bit 3 bit 4 bit 6 bit 7 possible parity bit possible parity bit standard sci data infrared sci data standard sci data infrared sci data functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 245 8.4.3 baud rate generation a 13-bit modulus counter in the baud rate generator derives the baud rate for both the receiver and the transmitter. the value from 0 to 8191 written to the sbr[12:0] bits determines the module clock divisor. the sbr bits are in the sci baud rate registers (scibdh and scibdl). the baud rate clock is synchronized with the bus clock and drives the receiver. the baud rate clock divided by 16 drives the transmitter. the receiver has an acquisition rate of 16 samples per bit time. baud rate generation is subject to one source of error: integer division of the module clock may not give the exact target frequency. table 8-13 lists some examples of achieving target baud rates with a module clock frequency of 10.2 mhz. when iren = 0 then, sci baud rate = sci module clock / (16 * scibr[12:0]) table 8-13. baud rates (example: module clock = 10.2 mhz) bits sbr[12?] receiver clock (hz) transmitter clock (hz) target baud rate error (%) 17 600,000.0 37,500.0 38,400 2.3 33 309,090.9 19,318.2 19,200 .62 66 154,545.5 9659.1 9600 .62 133 76,691.7 4793.2 4800 .14 266 38,345.9 2396.6 2400 .14 531 19,209.0 1200.6 1200 .11 1062 9604.5 600.3 600 .05 2125 4800.0 300.0 300 .00 4250 2400.0 150.0 150 .00 5795 1760.1 110.0 110 .00 chapter 8 serial communication interface (sciv3) mc9s12ne64 data sheet, rev. 1.1 246 freescale semiconductor 8.4.4 transmitter figure 8-13. transmitter block diagram 8.4.4.1 transmitter character length the sci transmitter can accommodate either 8-bit or 9-bit data characters. the state of the m bit in sci control register 1 (scicr1) determines the length of data characters. when transmitting 9-bit data, bit t8 in sci data register high (scidrh) is the ninth bit (bit 8). 8.4.4.2 character transmission to transmit data, the mcu writes the data bits to the sci data registers (scidrh/scidrl), which in turn are transferred to the transmitter shift register. the transmit shift register then shifts a frame out through the txd pin, after it has prefaced them with a start bit and appended them with a stop bit. the sci data registers (scidrh and scidrl) are the write-only buffers between the internal data bus and the transmit shift register. the sci also sets a flag, the transmit data register empty flag (tdre), every time it transfers data from the buffer (scidrh/l) to the transmitter shift register. the transmit driver routine may respond to this pe pt h876543210l 11-bit transmit shift register stop start t8 tdre tie tcie sbk tc parity generation msb sci data registers load from scidr shift enable preamble (all ones) break (all 0s) transmitter control m internal bus sbr12?br0 baud divider 16 tdre interrupt request tc interrupt request bus clock te sctxd loops loop rsrc control to receiver functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 247 flag by writing another byte to the transmitter buffer (scidrh/scidrl), while the shift register is shifting out the first byte. to initiate an sci transmission: 1. con?ure the sci: a) select a baud rate. write this value to the sci baud registers (scibdh/l) to begin the baud rate generator. remember that the baud rate generator is disabled when the baud rate is 0. writing to the scibdh has no effect without also writing to scibdl. b) write to scicr1 to con?ure word length, parity, and other con?uration bits (loops, rsrc, m, wake, ilt, pe, and pt). c) enable the transmitter, interrupts, receive, and wake up as required, by writing to the scicr2 register bits (tie, tcie, rie, ilie, te, re, rwu, and sbk). a preamble or idle character will now be shifted out of the transmitter shift register. 2. transmit procedure for each byte: a) poll the tdre ?g by reading the scisr1 or responding to the tdre interrupt. keep in mind that the tdre bit resets to 1. b) if the tdre ?g is set, write the data to be transmitted to scidrh/l, where the ninth bit is written to the t8 bit in scidrh if the sci is in 9-bit data format. a new transmission will not result until the tdre ?g has been cleared. 3. repeat step 2 for each subsequent transmission. note the tdre ?g is set when the shift register is loaded with the next data to be transmitted from scidrh/l, which happens, generally speaking, a little over half-way through the stop bit of the previous frame. speci?ally, this transfer occurs 9/16ths of a bit time after the start of the stop bit of the previous frame. writing the te bit from 0 to a 1 automatically loads the transmit shift register with a preamble of 10 logic 1s (if m = 0) or 11 logic 1s (if m = 1). after the preamble shifts out, control logic transfers the data from the sci data register into the transmit shift register. a logic 0 start bit automatically goes into the least significant bit position of the transmit shift register. a logic 1 stop bit goes into the most significant bit position. hardware supports odd or even parity. when parity is enabled, the most significant bit (msb) of the data character is the parity bit. the transmit data register empty flag, tdre, in sci status register 1 (scisr1) becomes set when the sci data register transfers a byte to the transmit shift register. the tdre flag indicates that the sci data register can accept new data from the internal data bus. if the transmit interrupt enable bit, tie, in sci control register 2 (scicr2) is also set, the tdre flag generates a transmitter interrupt request. when the transmit shift register is not transmitting a frame, the txd pin goes to the idle condition, logic 1. if at any time software clears the te bit in sci control register 2 (scicr2), the transmitter enable signal goes low and the transmit signal goes idle. chapter 8 serial communication interface (sciv3) mc9s12ne64 data sheet, rev. 1.1 248 freescale semiconductor if software clears te while a transmission is in progress (tc = 0), the frame in the transmit shift register continues to shift out. to avoid accidentally cutting off the last frame in a message, always wait for tdre to go high after the last frame before clearing te. to separate messages with preambles with minimum idle line time, use this sequence between messages: 1. write the last byte of the ?st message to scidrh/l. 2. wait for the tdre ?g to go high, indicating the transfer of the last frame to the transmit shift register. 3. queue a preamble by clearing and then setting the te bit. 4. write the ?st byte of the second message to scidrh/l. 8.4.4.3 break characters writing a logic 1 to the send break bit, sbk, in sci control register 2 (scicr2) loads the transmit shift register with a break character. a break character contains all logic 0s and has no start, stop, or parity bit. break character length depends on the m bit in sci control register 1 (scicr1). as long as sbk is at logic 1, transmitter logic continuously loads break characters into the transmit shift register. after software clears the sbk bit, the shift register finishes transmitting the last break character and then transmits at least one logic 1. the automatic logic 1 at the end of a break character guarantees the recognition of the start bit of the next frame. the sci recognizes a break character when a start bit is followed by eight or nine logic 0 data bits and a logic 0 where the stop bit should be. receiving a break character has these effects on sci registers: sets the framing error ?g, fe sets the receive data register full ?g, rdrf clears the sci data registers (scidrh/l) may set the overrun ?g, or, noise ?g, nf, parity error ?g, pe, or the receiver active ?g, raf (see section 8.3.2.4, ?ci status register 1 (scisr1) and section 8.3.2.5, ?ci status register 2 (scisr2) ). 8.4.4.4 idle characters an idle character (or preamble) contains all logic 1s and has no start, stop, or parity bit. idle character length depends on the m bit in sci control register 1 (scicr1). the preamble is a synchronizing idle character that begins the first transmission initiated after writing the te bit from 0 to 1. if the te bit is cleared during a transmission, the txd pin becomes idle after completion of the transmission in progress. clearing and then setting the te bit during a transmission queues an idle character to be sent after the frame currently being transmitted. note when queueing an idle character, return the te bit to logic 1 before the stop bit of the current frame shifts out through the txd pin. setting te after the stop bit appears on txd causes data previously written to the sci data register to be lost. toggle the te bit for a queued idle character while the functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 249 tdre ?g is set and immediately before writing the next byte to the sci data register. if the te bit is clear and the transmission is complete, the sci is not the master of the txd pin 8.4.5 receiver figure 8-14. sci receiver block diagram 8.4.5.1 receiver character length the sci receiver can accommodate either 8-bit or 9-bit data characters. the state of the m bit in sci control register 1 (scicr1) determines the length of data characters. when receiving 9-bit data, bit r8 in sci data register high (scidrh) is the ninth bit (bit 8). 8.4.5.2 character reception during an sci reception, the receive shift register shifts a frame in from the rxd pin. the sci data register is the read-only buffer between the internal data bus and the receive shift register. after a complete frame shifts into the receive shift register, the data portion of the frame transfers to the sci data register. the receive data register full flag, rdrf, in sci status register 1 (scisr1) becomes set, all ones m wake ilt pe pt re h876543210l 11-bit receive shift register stop start data wakeup parity checking msb sci data register r8 rie ilie rwu rdrf or nf fe pe internal bus bus idle interrupt request rdrf/or interrupt request sbr12?br0 baud clock idle raf recovery logic loops loop rsrc control scrxd from txd pin or transmitter divider chapter 8 serial communication interface (sciv3) mc9s12ne64 data sheet, rev. 1.1 250 freescale semiconductor indicating that the received byte can be read. if the receive interrupt enable bit, rie, in sci control register 2 (scicr2) is also set, the rdrf flag generates an rdrf interrupt request. 8.4.5.3 data sampling the receiver samples the rxd pin at the rt clock rate. the rt clock is an internal signal with a frequency 16 times the baud rate. to adjust for baud rate mismatch, the rt clock (see figure 8-15 ) is re-synchronized: after every start bit after the receiver detects a data bit change from logic 1 to logic 0 (after the majority of data bit samples at rt8, rt9, and rt10 returns a valid logic 1 and the majority of the next rt8, rt9, and rt10 samples returns a valid logic 0) to locate the start bit, data recovery logic does an asynchronous search for a logic 0 preceded by three logic 1s. when the falling edge of a possible start bit occurs, the rt clock begins to count to 16. figure 8-15. receiver data sampling to verify the start bit and to detect noise, data recovery logic takes samples at rt3, rt5, and rt7. table 8-14 summarizes the results of the start bit verification samples. if start bit verification is not successful, the rt clock is reset and a new search for a start bit begins. table 8-14. start bit veri?ation rt3, rt5, and rt7 samples start bit veri?ation noise flag 000 yes 0 001 yes 1 010 yes 1 011 no 0 100 yes 1 101 no 0 110 no 0 111 no 0 reset rt clock rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt5 rt8 rt7 rt6 rt11 rt10 rt9 rt15 rt14 rt13 rt12 rt16 rt1 rt2 rt3 rt4 samples rt clock rt clock count start bit rxd start bit qualification start bit data sampling 11 1 1 1 1 110000 0 00 lsb verification functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 251 to determine the value of a data bit and to detect noise, recovery logic takes samples at rt8, rt9, and rt10. table 8-15 summarizes the results of the data bit samples. note the rt8, rt9, and rt10 samples do not affect start bit veri?ation. if any or all of the rt8, rt9, and rt10 start bit samples are logic 1s following a successful start bit veri?ation, the noise ?g (nf) is set and the receiver assumes that the bit is a start bit (logic 0). to verify a stop bit and to detect noise, recovery logic takes samples at rt8, rt9, and rt10. table 8-16 summarizes the results of the stop bit samples. table 8-15. data bit recovery rt8, rt9, and rt10 samples data bit determination noise flag 000 0 0 001 0 1 010 0 1 011 1 1 100 0 1 101 1 1 110 1 1 111 1 0 table 8-16. stop bit recovery rt8, rt9, and rt10 samples framing error flag noise flag 000 1 0 001 1 1 010 1 1 011 0 1 100 1 1 101 0 1 110 0 1 111 0 0 chapter 8 serial communication interface (sciv3) mc9s12ne64 data sheet, rev. 1.1 252 freescale semiconductor in figure 8-16 the verification samples rt3 and rt5 determine that the first low detected was noise and not the beginning of a start bit. the rt clock is reset and the start bit search begins again. the noise flag is not set because the noise occurred before the start bit was found. figure 8-16. start bit search example 1 in figure 8-17 , verification sample at rt3 is high. the rt3 sample sets the noise flag. although the perceived bit time is misaligned, the data samples rt8, rt9, and rt10 are within the bit time and data recovery is successful. figure 8-17. start bit search example 2 reset rt clock rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt5 rt1 rt1 rt2 rt3 rt4 rt7 rt6 rt5 rt10 rt9 rt8 rt14 rt13 rt12 rt11 rt15 rt16 rt1 rt2 rt3 samples rt clock rt clock count start bit rxd 11 0 1 111000 00 lsb 0 0 reset rt clock rt1 rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt5 rt6 rt7 rt8 rt11 rt10 rt9 rt14 rt13 rt12 rt2 rt1 rt16 rt15 rt3 rt4 rt5 rt6 rt7 samples rt clock rt clock count actual start bit rxd 11 1 1 11000 0 lsb 0 0 perceived start bit functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 253 in figure 8-18 , a large burst of noise is perceived as the beginning of a start bit, although the test sample at rt5 is high. the rt5 sample sets the noise flag. although this is a worst-case misalignment of perceived bit time, the data samples rt8, rt9, and rt10 are within the bit time and data recovery is successful. figure 8-18. start bit search example 3 figure 8-19 shows the effect of noise early in the start bit time. although this noise does not affect proper synchronization with the start bit time, it does set the noise flag. figure 8-19. start bit search example 4 reset rt clock rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt5 rt6 rt7 rt8 rt9 rt10 rt13 rt12 rt11 rt16 rt15 rt14 rt4 rt3 rt2 rt1 rt5 rt6 rt7 rt8 rt9 samples rt clock rt clock count actual start bit rxd 10 1 11000 0 lsb 0 perceived start bit reset rt clock rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt7 rt6 rt5 rt10 rt9 rt8 rt14 rt13 rt12 rt11 rt15 rt16 rt1 rt2 rt3 samples rt clock rt clock count perceived and actual start bit rxd 11 1 1100 1 lsb 1 1 1 1 chapter 8 serial communication interface (sciv3) mc9s12ne64 data sheet, rev. 1.1 254 freescale semiconductor figure 8-20 shows a burst of noise near the beginning of the start bit that resets the rt clock. the sample after the reset is low but is not preceded by three high samples that would qualify as a falling edge. depending on the timing of the start bit search and on the data, the frame may be missed entirely or it may set the framing error flag. figure 8-20. start bit search example 5 in figure 8-21 , a noise burst makes the majority of data samples rt8, rt9, and rt10 high. this sets the noise ?g but does not reset the rt clock. in start bits only, the rt8, rt9, and rt10 data samples are ignored. figure 8-21. start bit search example 6 8.4.5.4 framing errors if the data recovery logic does not detect a logic 1 where the stop bit should be in an incoming frame, it sets the framing error flag, fe, in sci status register 1 (scisr1). a break character also sets the fe flag because a break character has no stop bit. the fe flag is set at the same time that the rdrf flag is set. reset rt clock rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt7 rt6 rt5 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 samples rt clock rt clock count start bit rxd 11 1 1101 0 lsb 1 1 1 1 1 00 0 00 0 0 0 no start bit found reset rt clock rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt1 rt2 rt3 rt4 rt7 rt6 rt5 rt10 rt9 rt8 rt14 rt13 rt12 rt11 rt15 rt16 rt1 rt2 rt3 samples rt clock rt clock count start bit rxd 11 1 1100 0 lsb 1 1 1 1 0 11 0 functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 255 8.4.5.5 baud rate tolerance a transmitting device may be operating at a baud rate below or above the receiver baud rate. accumulated bit time misalignment can cause one of the three stop bit data samples (rt8, rt9, and rt10) to fall outside the actual stop bit. a noise error will occur if the rt8, rt9, and rt10 samples are not all the same logical values. a framing error will occur if the receiver clock is misaligned in such a way that the majority of the rt8, rt9, and rt10 stop bit samples are a logic 0. as the receiver samples an incoming frame, it re-synchronizes the rt clock on any valid falling edge within the frame. re synchronization within frames will correct a misalignment between transmitter bit times and receiver bit times. 8.4.5.5.1 slow data tolerance figure 8-22 shows how much a slow received frame can be misaligned without causing a noise error or a framing error. the slow stop bit begins at rt8 instead of rt1 but arrives in time for the stop bit data samples at rt8, rt9, and rt10. figure 8-22. slow data let? take rtr as receiver rt clock and rtt as transmitter rt clock. for an 8-bit data character, it takes the receiver 9 bit times x 16 rtr cycles +7 rtr cycles =151 rtr cycles to start data sampling of the stop bit. with the misaligned character shown in figure 8-22 , the receiver counts 151 rtr cycles at the point when the count of the transmitting device is 9 bit times x 16 rtt cycles = 144 rtt cycles. the maximum percent difference between the receiver count and the transmitter count of a slow 8-bit data character with no errors is: ((151 ?144) / 151) x 100 = 4.63% for a 9-bit data character, it takes the receiver 10 bit times x 16 rtr cycles + 7 rtr cycles = 167 rtr cycles to start data sampling of the stop bit. with the misaligned character shown in figure 8-22 , the receiver counts 167 rtr cycles at the point when the count of the transmitting device is 10 bit times x 16 rtt cycles = 160 rtt cycles. the maximum percent difference between the receiver count and the transmitter count of a slow 9-bit character with no errors is: ((167 ?160) / 167) x 100 = 4.19% msb stop rt1 rt2 rt3 rt4 rt5 rt6 rt7 rt8 rt9 rt10 rt11 rt12 rt13 rt14 rt15 rt16 data samples receiver rt clock chapter 8 serial communication interface (sciv3) mc9s12ne64 data sheet, rev. 1.1 256 freescale semiconductor 8.4.5.5.2 fast data tolerance figure 8-23 shows how much a fast received frame can be misaligned. the fast stop bit ends at rt10 instead of rt16 but continues to be sampled at rt8, rt9, and rt10. figure 8-23. fast data for an 8-bit data character, it takes the receiver 9 bit times x 16 rtr cycles + 10 rtr cycles = 154 rtr cycles to finish data sampling of the stop bit. with the misaligned character shown in figure 8-23 , the receiver counts 154 rtr cycles at the point when the count of the transmitting device is 10 bit times x 16 rtt cycles = 160 rtt cycles. the maximum percent difference between the receiver count and the transmitter count of a fast 8-bit character with no errors is: ((160 ?154) / 160) x 100 = 3.75% for a 9-bit data character, it takes the receiver 10 bit times x 16 rtr cycles + 10 rtr cycles = 170 rtr cycles to finish data sampling of the stop bit. with the misaligned character shown in figure 8-23 , the receiver counts 170 rtr cycles at the point when the count of the transmitting device is 11 bit times x 16 rtt cycles = 176 rtt cycles. the maximum percent difference between the receiver count and the transmitter count of a fast 9-bit character with no errors is: ((176 ?170) / 176) x 100 = 3.40% 8.4.5.6 receiver wakeup to enable the sci to ignore transmissions intended only for other receivers in multiple-receiver systems, the receiver can be put into a standby state. setting the receiver wakeup bit, rwu, in sci control register 2 (scicr2) puts the receiver into standby state during which receiver interrupts are disabled.the sci will continue to load the receive data into the scidrh/l registers, but it will not set the rdrf flag. the transmitting device can address messages to selected receivers by including addressing information in the initial frame or frames of each message. the wake bit in sci control register 1 (scicr1) determines how the sci is brought out of the standby state to process an incoming message. the wake bit enables either idle line wakeup or address mark wakeup. idle or next frame stop rt1 rt2 rt3 rt4 rt5 rt6 rt7 rt8 rt9 rt10 rt11 rt12 rt13 rt14 rt15 rt16 data samples receiver rt clock functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 257 8.4.5.6.1 idle input line wakeup (wake = 0) in this wakeup method, an idle condition on the rxd pin clears the rwu bit and wakes up the sci. the initial frame or frames of every message contain addressing information. all receivers evaluate the addressing information, and receivers for which the message is addressed process the frames that follow. any receiver for which a message is not addressed can set its rwu bit and return to the standby state. the rwu bit remains set and the receiver remains on standby until another idle character appears on the rxd pin. idle line wakeup requires that messages be separated by at least one idle character and that no message contains idle characters. the idle character that wakes a receiver does not set the receiver idle bit, idle, or the receive data register full ?g, rdrf. the idle line type bit, ilt, determines whether the receiver begins counting logic 1s as idle character bits after the start bit or after the stop bit. ilt is in sci control register 1 (scicr1). 8.4.5.6.2 address mark wakeup (wake = 1) in this wakeup method, a logic 1 in the most signi?ant bit (msb) position of a frame clears the rwu bit and wakes up the sci. the logic 1 in the msb position marks a frame as an address frame that contains addressing information. all receivers evaluate the addressing information, and the receivers for which the message is addressed process the frames that follow. any receiver for which a message is not addressed can set its rwu bit and return to the standby state. the rwu bit remains set and the receiver remains on standby until another address frame appears on the rxd pin. the logic 1 msb of an address frame clears the receiver s rwu bit before the stop bit is received and sets the rdrf ?g. address mark wakeup allows messages to contain idle characters but requires that the msb be reserved for use in address frames. note with the wake bit clear, setting the rwu bit after the rxd pin has been idle can cause the receiver to wake up immediately. 8.4.6 single-wire operation normally, the sci uses two pins for transmitting and receiving. in single-wire operation, the rxd pin is disconnected from the sci. the sci uses the txd pin for both receiving and transmitting. figure 8-24. single-wire operation (loops = 1, rsrc = 1) rxd transmitter receiver txd chapter 8 serial communication interface (sciv3) mc9s12ne64 data sheet, rev. 1.1 258 freescale semiconductor enable single-wire operation by setting the loops bit and the receiver source bit, rsrc, in sci control register 1 (scicr1). setting the loops bit disables the path from the rxd pin to the receiver. setting the rsrc bit connects the txd pin to the receiver. both the transmitter and receiver must be enabled (te = 1 and re = 1).the txdir bit (scisr2[1]) determines whether the txd pin is going to be used as an input (txdir = 0) or an output (txdir = 1) in this mode of operation. 8.4.7 loop operation in loop operation the transmitter output goes to the receiver input. the rxd pin is disconnected from the sci . figure 8-25. loop operation (loops = 1, rsrc = 0) enable loop operation by setting the loops bit and clearing the rsrc bit in sci control register 1 (scicr1). setting the loops bit disables the path from the rxd pin to the receiver. clearing the rsrc bit connects the transmitter output to the receiver input. both the transmitter and receiver must be enabled (te = 1 and re = 1). 8.5 interrupts this section describes the interrupt originated by the sci block.the mcu must service the interrupt requests. table 8-17 lists the five interrupt sources of the sci. 8.5.1 description of interrupt operation the sci only originates interrupt requests. the following is a description of how the sci makes a request and how the mcu should acknowledge that request. the interrupt vector offset and interrupt number are table 8-17. sci interrupt sources interrupt source local enable description tdre scisr1[7] tie active high level. indicates that a byte was transferred from scidrh/l to the transmit shift register. tc scisr1[6] tcie active high level. indicates that a transmit is complete. rdrf scisr1[5] rie active high level. the rdrf interrupt indicates that received data is available in the sci data register. or scisr1[3] active high level. this interrupt indicates that an overrun condition has occurred. idle scisr1[4] ilie active high level. indicates that receiver input has become idle. rxd transmitter receiver txd interrupts mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 259 chip dependent. the sci only has a single interrupt line (sci interrupt signal, active high operation) and all the following interrupts, when generated, are ored together and issued through that port. 8.5.1.1 tdre description the tdre interrupt is set high by the sci when the transmit shift register receives a byte from the sci data register. a tdre interrupt indicates that the transmit data register (scidrh/l) is empty and that a new byte can be written to the scidrh/l for transmission.clear tdre by reading sci status register 1 with tdre set and then writing to sci data register low (scidrl). 8.5.1.2 tc description the tc interrupt is set by the sci when a transmission has been completed.a tc interrupt indicates that there is no transmission in progress. tc is set high when the tdre flag is set and no data, preamble, or break character is being transmitted. when tc is set, the txd pin becomes idle (logic 1). clear tc by reading sci status register 1 (scisr1) with tc set and then writing to sci data register low (scidrl).tc is cleared automatically when data, preamble, or break is queued and ready to be sent. 8.5.1.3 rdrf description the rdrf interrupt is set when the data in the receive shift register transfers to the sci data register. a rdrf interrupt indicates that the received data has been transferred to the sci data register and that the byte can now be read by the mcu. the rdrf interrupt is cleared by reading the sci status register one (scisr1) and then reading sci data register low (scidrl). 8.5.1.4 or description the or interrupt is set when software fails to read the sci data register before the receive shift register receives the next frame. the newly acquired data in the shift register will be lost in this case, but the data already in the sci data registers is not affected. the or interrupt is cleared by reading the sci status register one (scisr1) and then reading sci data register low (scidrl). 8.5.1.5 idle description the idle interrupt is set when 10 consecutive logic 1s (if m = 0) or 11 consecutive logic 1s (if m = 1) appear on the receiver input. after the idle is cleared, a valid frame must again set the rdrf flag before an idle condition can set the idle flag. clear idle by reading sci status register 1 (scisr1) with idle set and then reading sci data register low (scidrl). 8.5.2 recovery from wait mode the sci interrupt request can be used to bring the cpu out of wait mode. chapter 8 serial communication interface (sciv3) mc9s12ne64 data sheet, rev. 1.1 260 freescale semiconductor mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 261 chapter 9 serial peripheral interface (spiv3) 9.1 introduction the spi module allows a duplex, synchronous, serial communication between the mcu and peripheral devices. software can poll the spi status ?gs or the spi operation can be interrupt driven. 9.1.1 features the spiv3 includes these distinctive features: master mode and slave mode bidirectional mode slave select output mode fault error ?g with cpu interrupt capability double-buffered data register serial clock with programmable polarity and phase control of spi operation during wait mode 9.1.2 modes of operation the spi functions in three modes, run, wait, and stop. run mode this is the basic mode of operation. wait mode spi operation in wait mode is a con?urable low power mode, controlled by the spiswai bit located in the spicr2 register. in wait mode, if the spiswai bit is clear, the spi operates like in run mode. if the spiswai bit is set, the spi goes into a power conservative state, with the spi clock generation turned off. if the spi is con?ured as a master, any transmission in progress stops, but is resumed after cpu goes into run mode. if the spi is con?ured as a slave, reception and transmission of a byte continues, so that the slave stays synchronized to the master. stop mode the spi is inactive in stop mode for reduced power consumption. if the spi is con?ured as a master, any transmission in progress stops, but is resumed after cpu goes into run mode. if the spi is con?ured as a slave, reception and transmission of a byte continues, so that the slave stays synchronized to the master. this is a high level description only, detailed descriptions of operating modes are contained in section 9.4, ?unctional description . chapter 9 serial peripheral interface (spiv3) mc9s12ne64 data sheet, rev. 1.1 262 freescale semiconductor 9.1.3 block diagram figure 9-1 gives an overview on the spi architecture. the main parts of the spi are status, control, and data registers, shifter logic, baud rate generator, master/slave control logic, and port control logic. figure 9-1. spi block diagram 9.2 external signal description this section lists the name and description of all ports including inputs and outputs that do, or may, connect off chip. the spiv3 module has a total of four external pins. 9.2.1 mosi ?master out/slave in pin this pin is used to transmit data out of the spi module when it is con?ured as a master and receive data when it is con?ured as slave. spi control register 1 spi control register 2 spi baud rate register spi status register spi data register shifter port control logic mosi sck interrupt control spi msb lsb lsbfe=1 lsbfe=0 lsbfe=0 lsbfe=1 data in lsbfe=1 lsbfe=0 data out 8 8 baud rate generator prescaler bus clock counter clock select sppr 3 3 spr baud rate phase + polarity control master slave sck in sck out master baud rate slave baud rate phase + polarity control control control cpol cpha 2 bidiroe spc0 2 modf spif sptef spi request interrupt ss shift clock sample clock memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 263 9.2.2 miso ?master in/slave out pin this pin is used to transmit data out of the spi module when it is con?ured as a slave and receive data when it is con?ured as master. 9.2.3 ss ?slave select pin this pin is used to output the select signal from the spi module to another peripheral with which a data transfer is to take place when its con?ured as a master and its used as an input to receive the slave select signal when the spi is con?ured as slave. 9.2.4 sck ?serial clock pin this pin is used to output the clock with respect to which the spi transfers data or receive clock in case of slave. 9.3 memory map and register de?ition this section provides a detailed description of address space and registers used by the spi. the memory map for the spiv3 is given below in table 9-1 . the address listed for each register is the sum of a base address and an address offset. the base address is de?ed at the soc level and the address offset is de?ed at the module level. reads from the reserved bits return zeros and writes to the reserved bits have no effect. 9.3.1 module memory map table 9-1. spiv3 memory map address use access 0x0000 spi control register 1 (spicr1) r/w 0x0001 spi control register 2 (spicr2) r/w 1 1 certain bits are non-writable. 0x0002 spi baud rate register (spibr) r/w 1 0x0003 spi status register (spisr) r 2 2 writes to this register are ignored. 0x0004 reserved 2,3 3 reading from this register returns all zeros. 0x0005 spi data register (spidr) r/w 0x0006 reserved 2,3 0x0007 reserved 2,3 chapter 9 serial peripheral interface (spiv3) mc9s12ne64 data sheet, rev. 1.1 264 freescale semiconductor 9.3.2 register descriptions this section consists of register descriptions in address order. each description includes a standard register diagram with an associated ?ure number. details of register bit and ?ld function follow the register diagrams, in bit order. 9.3.2.1 spi control register 1 (spicr1) read: anytime write: anytime name 7 6 5 4 3 2 1 0 spicr1 r spie spe sptie mstr cpol cpha ssoe lsbfe w spicr2 r0 0 0 modfen bidiroe 0 spiswai spc0 w spibr r0 sppr2 sppr1 sppr0 0 spr2 spr1 spr0 w spisr r spif 0 sptef modf 0 0 0 0 w reserved r w spidr r bit 7 6 5 4 3 2 2 bit 0 w reserved r w reserved r w = unimplemented or reserved figure 9-2. spi register summary 76543210 r spie spe sptie mstr cpol cpha ssoe lsbfe w reset 0 0 0 00100 figure 9-3. spi control register 1 (spicr1) memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 265 table 9-2. spicr1 field descriptions field description 7 spie spi interrupt enable bit ?this bit enables spi interrupt requests, if spif or modf status ?g is set. 0 spi interrupts disabled. 1 spi interrupts enabled. 6 spe spi system enable bit ?this bit enables the spi system and dedicates the spi port pins to spi system functions. if spe is cleared, spi is disabled and forced into idle state, status bits in spisr register are reset. 0 spi disabled (lower power consumption). 1 spi enabled, port pins are dedicated to spi functions. 5 sptie spi transmit interrupt enable ?this bit enables spi interrupt requests, if sptef ?g is set. 0 sptef interrupt disabled. 1 sptef interrupt enabled. 4 mstr spi master/slave mode select bit ?this bit selects, if the spi operates in master or slave mode. switching the spi from master to slave or vice versa forces the spi system into idle state. 0 spi is in slave mode 1 spi is in master mode 3 cpol spi clock polarity bit this bit selects an inverted or non-inverted spi clock. to transmit data between spi modules, the spi modules must have identical cpol values. in master mode, a change of this bit will abort a transmission in progress and force the spi system into idle state. 0 active-high clocks selected. in idle state sck is low. 1 active-low clocks selected. in idle state sck is high. 2 cpha spi clock phase bit this bit is used to select the spi clock format. in master mode, a change of this bit will abort a transmission in progress and force the spi system into idle state. 0 sampling of data occurs at odd edges (1,3,5,...,15) of the sck clock 1 sampling of data occurs at even edges (2,4,6,...,16) of the sck clock 1 ssoe slave select output enable ?the ss output feature is enabled only in master mode, if modfen is set, by asserting the ssoe as shown in table 9-3 . in master mode, a change of this bit will abort a transmission in progress and force the spi system into idle state. 0 lsbfe lsb-first enable ?this bit does not affect the position of the msb and lsb in the data register. reads and writes of the data register always have the msb in bit 7. in master mode, a change of this bit will abort a transmission in progress and force the spi system into idle state. 0 data is transferred most signi?ant bit ?st. 1 data is transferred least signi?ant bit ?st. table 9-3. ss input / output selection modfen ssoe master mode slave mode 00 ss not used by spi ss input 01 ss not used by spi ss input 10 ss input with modf feature ss input 11 ss is slave select output ss input chapter 9 serial peripheral interface (spiv3) mc9s12ne64 data sheet, rev. 1.1 266 freescale semiconductor 9.3.2.2 spi control register 2 (spicr2) read: anytime write: anytime; writes to the reserved bits have no effect 76543210 r000 modfen bidiroe 0 spiswai spc0 w reset 0 0 0 00000 = unimplemented or reserved figure 9-4. spi control register 2 (spicr2) table 9-4. spicr2 field descriptions field description 4 modfen mode fault enable bit ?this bit allows the modf failure being detected. if the spi is in master mode and modfen is cleared, then the ss port pin is not used by the spi. in slave mode, the ss is available only as an input regardless of the value of modfen. for an overview on the impact of the modfen bit on the ss port pin con?uration refer to table 9-3 . in master mode, a change of this bit will abort a transmission in progress and force the spi system into idle state. 0 ss port pin is not used by the spi 1 ss port pin with modf feature 3 bidiroe output enable in the bidirectional mode of operation this bit controls the mosi and miso output buffer of the spi, when in bidirectional mode of operation (spc0 is set). in master mode this bit controls the output buffer of the mosi port, in slave mode it controls the output buffer of the miso port. in master mode, with spc0 set, a change of this bit will abort a transmission in progress and force the spi into idle state. 0 output buffer disabled 1 output buffer enabled 1 spiswai spi stop in wait mode bit ?this bit is used for power conservation while in wait mode. 0 spi clock operates normally in wait mode 1 stop spi clock generation when in wait mode 0 spc0 serial pin control bit 0 ?this bit enables bidirectional pin con?urations as shown in table 9-5 . in master mode, a change of this bit will abort a transmission in progress and force the spi system into idle state table 9-5. bidirectional pin con?urations pin mode spc0 bidiroe miso mosi master mode of operation normal 0 x master in master out bidirectional 1 0 miso not used by spi master in 1 master i/o slave mode of operation normal 0 x slave out slave in bidirectional 1 0 slave in mosi not used by spi 1 slave i/o memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 267 9.3.2.3 spi baud rate register (spibr) read: anytime write: anytime; writes to the reserved bits have no effect the baud rate divisor equation is as follows: the baud rate can be calculated with the following equation: 76543210 r0 sppr2 sppr1 sppr0 0 spr2 spr1 spr0 w reset 0 0 0 00000 = unimplemented or reserved figure 9-5. spi baud rate register (spibr) table 9-6. spibr field descriptions field description 6:4 sppr[2:0] spi baud rate preselection bits ?these bits specify the spi baud rates as shown in table 9-7 . in master mode, a change of these bits will abort a transmission in progress and force the spi system into idle state. 2:0 spr[2:0} spi baud rate selection bits these bits specify the spi baud rates as shown in table 9-7 . in master mode, a change of these bits will abort a transmission in progress and force the spi system into idle state. baudratedivisor sppr 1 + () 2 ? spr 1 + () = baud rate busclock baudratedivisor ? = chapter 9 serial peripheral interface (spiv3) mc9s12ne64 data sheet, rev. 1.1 268 freescale semiconductor table 9-7. example spi baud rate selection (25 mhz bus clock) sppr2 sppr1 sppr0 spr2 spr1 spr0 baud rate divisor baud rate 0000002 12.5 mhz 0000014 6.25 mhz 0000108 3.125 mhz 00001116 1.5625 mhz 00010032 781.25 khz 00010164 390.63 khz 000110128 195.31 khz 000111256 97.66 khz 0010004 6.25 mhz 0010018 3.125 mhz 00101016 1.5625 mhz 00101132 781.25 khz 00110064 390.63 khz 001101128 195.31 khz 001110256 97.66 khz 001111512 48.83 khz 0100006 4.16667 mhz 01000112 2.08333 mhz 01001024 1.04167 mhz 01001148 520.83 khz 01010096 260.42 khz 010101192 130.21 khz 010110384 65.10 khz 010111768 32.55 khz 0110008 3.125 mhz 01100116 1.5625 mhz 01101032 781.25 khz 01101164 390.63 khz 011100128 195.31 khz 011101256 97.66 khz 011110512 48.83 khz 011111 1024 24.41 khz 10000010 2.5 mhz 10000120 1.25 mhz 10001040 625 khz 10001180 312.5 khz 100100160 156.25 khz 100101320 78.13 khz 100110640 39.06 khz memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 269 note in slave mode of spi s-clock speed div2 is not supported. 100111 1280 19.53 khz 10100012 2.08333 mhz 10100124 1.04167 mhz 10101048 520.83 khz 10101196 260.42 khz 101100192 130.21 khz 101101384 65.10 khz 101110768 32.55 khz 101111 1536 16.28 khz 11000014 1.78571 mhz 11000128 892.86 khz 11001056 446.43 khz 110011112 223.21 khz 110100224 111.61 khz 110101448 55.80 khz 110110896 27.90 khz 110111 1792 13.95 khz 11100016 1.5625 mhz 11100132 781.25 khz 11101064 390.63 khz 111011128 195.31 khz 111100256 97.66 khz 111101512 48.83 khz 111110 1024 24.41 khz 111111 2048 12.21 khz table 9-7. example spi baud rate selection (25 mhz bus clock) (continued) sppr2 sppr1 sppr0 spr2 spr1 spr0 baud rate divisor baud rate chapter 9 serial peripheral interface (spiv3) mc9s12ne64 data sheet, rev. 1.1 270 freescale semiconductor 9.3.2.4 spi status register (spisr) read: anytime write: has no effect 9.3.2.5 spi data register (spidr) read: anytime; normally read only after spif is set write: anytime 76543210 r spif 0 sptef modf 0000 w reset 0 0 1 00000 = unimplemented or reserved figure 9-6. spi status register (spisr) table 9-8. spisr field descriptions field description 7 spif spif interrupt flag this bit is set after a received data byte has been transferred into the spi data register. this bit is cleared by reading the spisr register (with spif set) followed by a read access to the spi data register. 0 transfer not yet complete 1 new data copied to spidr 5 sptef spi transmit empty interrupt flag if set, this bit indicates that the transmit data register is empty. to clear this bit and place data into the transmit data register, spisr has to be read with sptef = 1, followed by a write to spidr. any write to the spi data register without reading sptef = 1, is effectively ignored. 0 spi data register not empty 1 spi data register empty 4 modf mode fault flag this bit is set if the ss input becomes low while the spi is con?ured as a master and mode fault detection is enabled, modfen bit of spicr2 register is set. refer to modfen bit description in section 9.3.2.2, ?pi control register 2 (spicr2) . the ?g is cleared automatically by a read of the spi status register (with modf set) followed by a write to the spi control register 1. 0 mode fault has not occurred. 1 mode fault has occurred. 76543210 r bit 7 6 5 4322 bit 0 w reset 0 0 0 00000 = unimplemented or reserved figure 9-7. spi data register (spidr) functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 271 the spi data register is both the input and output register for spi data. a write to this register allows a data byte to be queued and transmitted. for a spi con?ured as a master, a queued data byte is transmitted immediately after the previous transmission has completed. the spi transmitter empty flag sptef in the spisr register indicates when the spi data register is ready to accept new data. reading the data can occur anytime from after the spif is set to before the end of the next transfer. if the spif is not serviced by the end of the successive transfers, those data bytes are lost and the data within the spidr retains the ?st byte until spif is serviced. 9.4 functional description the spi module allows a duplex, synchronous, serial communication between the mcu and peripheral devices. software can poll the spi status ?gs or spi operation can be interrupt driven. the spi system is enabled by setting the spi enable (spe) bit in spi control register 1. while spe bit is set, the four associated spi port pins are dedicated to the spi function as: slave select ( ss) serial clock (sck) master out/slave in (mosi) master in/slave out (miso) the main element of the spi system is the spi data register. the 8-bit data register in the master and the 8-bit data register in the slave are linked by the mosi and miso pins to form a distributed 16-bit register. when a data transfer operation is performed, this 16-bit register is serially shifted eight bit positions by the s-clock from the master, so data is exchanged between the master and the slave. data written to the master spi data register becomes the output data for the slave, and data read from the master spi data register after a transfer operation is the input data from the slave. a read of spisr with sptef = 1 followed by a write to spidr puts data into the transmit data register. when a transfer is complete, received data is moved into the receive data register. data may be read from this double-buffered system any time before the next transfer has completed. this 8-bit data register acts as the spi receive data register for reads and as the spi transmit data register for writes. a single spi register address is used for reading data from the read data buffer and for writing data to the transmit data register. the clock phase control bit (cpha) and a clock polarity control bit (cpol) in the spi control register 1 (spicr1) select one of four possible clock formats to be used by the spi system. the cpol bit simply selects a non-inverted or inverted clock. the cpha bit is used to accommodate two fundamentally different protocols by sampling data on odd numbered sck edges or on even numbered sck edges (see section 9.4.3, ?ransmission formats ). the spi can be con?ured to operate as a master or as a slave. when the mstr bit in spi control register1 is set, master mode is selected, when the mstr bit is clear, slave mode is selected. chapter 9 serial peripheral interface (spiv3) mc9s12ne64 data sheet, rev. 1.1 272 freescale semiconductor 9.4.1 master mode the spi operates in master mode when the mstr bit is set. only a master spi module can initiate transmissions. a transmission begins by writing to the master spi data register. if the shift register is empty, the byte immediately transfers to the shift register. the byte begins shifting out on the mosi pin under the control of the serial clock. s-clock the spr2, spr1, and spr0 baud rate selection bits in conjunction with the sppr2, sppr1, and sppr0 baud rate preselection bits in the spi baud rate register control the baud rate generator and determine the speed of the transmission. the sck pin is the spi clock output. through the sck pin, the baud rate generator of the master controls the shift register of the slave peripheral. mosi and miso pins in master mode, the function of the serial data output pin (mosi) and the serial data input pin (miso) is determined by the spc0 and bidiroe control bits. ss pin if modfen and ssoe bit are set, the ss pin is con?ured as slave select output. the ss output becomes low during each transmission and is high when the spi is in idle state. if modfen is set and ssoe is cleared, the ss pin is con?ured as input for detecting mode fault error. if the ss input becomes low this indicates a mode fault error where another master tries to drive the mosi and sck lines. in this case, the spi immediately switches to slave mode, by clearing the mstr bit and also disables the slave output buffer miso (or siso in bidirectional mode). so the result is that all outputs are disabled and sck, mosi and miso are inputs. if a transmission is in progress when the mode fault occurs, the transmission is aborted and the spi is forced into idle state. this mode fault error also sets the mode fault (modf) ?g in the spi status register (spisr). if the spi interrupt enable bit (spie) is set when the modf ?g gets set, then an spi interrupt sequence is also requested. when a write to the spi data register in the master occurs, there is a half sck-cycle delay. after the delay, sck is started within the master. the rest of the transfer operation differs slightly, depending on the clock format speci?d by the spi clock phase bit, cpha, in spi control register 1 (see section 9.4.3, ?ransmission formats ). note a change of the bits cpol, cpha, ssoe, lsbfe, modfen, spc0, bidiroe with spc0 set, sppr2?ppr0 and spr2?pr0 in master mode will abort a transmission in progress and force the spi into idle state. the remote slave cannot detect this, therefore the master has to ensure that the remote slave is set back to idle state. functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 273 9.4.2 slave mode the spi operates in slave mode when the mstr bit in spi control register1 is clear. sck clock in slave mode, sck is the spi clock input from the master. miso and mosi pins in slave mode, the function of the serial data output pin (miso) and serial data input pin (mosi) is determined by the spc0 bit and bidiroe bit in spi control register 2. ss pin the ss pin is the slave select input. before a data transmission occurs, the ss pin of the slave spi must be low. ss must remain low until the transmission is complete. if ss goes high, the spi is forced into idle state. the ss input also controls the serial data output pin, if ss is high (not selected), the serial data output pin is high impedance, and, if ss is low the ?st bit in the spi data register is driven out of the serial data output pin. also, if the slave is not selected ( ss is high), then the sck input is ignored and no internal shifting of the spi shift register takes place. although the spi is capable of duplex operation, some spi peripherals are capable of only receiving spi data in a slave mode. for these simpler devices, there is no serial data out pin. note when peripherals with duplex capability are used, take care not to simultaneously enable two receivers whose serial outputs drive the same system slave s serial data output line. as long as no more than one slave device drives the system slave s serial data output line, it is possible for several slaves to receive the same transmission from a master, although the master would not receive return information from all of the receiving slaves. if the cpha bit in spi control register 1 is clear, odd numbered edges on the sck input cause the data at the serial data input pin to be latched. even numbered edges cause the value previously latched from the serial data input pin to shift into the lsb or msb of the spi shift register, depending on the lsbfe bit. if the cpha bit is set, even numbered edges on the sck input cause the data at the serial data input pin to be latched. odd numbered edges cause the value previously latched from the serial data input pin to shift into the lsb or msb of the spi shift register, depending on the lsbfe bit. when cpha is set, the ?st edge is used to get the ?st data bit onto the serial data output pin. when cpha is clear and the ss input is low (slave selected), the ?st bit of the spi data is driven out of the serial data output pin. after the eighth shift, the transfer is considered complete and the received data is transferred into the spi data register. to indicate transfer is complete, the spif ?g in the spi status register is set. note a change of the bits cpol, cpha, ssoe, lsbfe, modfen, spc0 and bidiroe with spc0 set in slave mode will corrupt a transmission in progress and has to be avoided. chapter 9 serial peripheral interface (spiv3) mc9s12ne64 data sheet, rev. 1.1 274 freescale semiconductor 9.4.3 transmission formats during an spi transmission, data is transmitted (shifted out serially) and received (shifted in serially) simultaneously. the serial clock (sck) synchronizes shifting and sampling of the information on the two serial data lines. a slave select line allows selection of an individual slave spi device, slave devices that are not selected do not interfere with spi bus activities. optionally, on a master spi device, the slave select line can be used to indicate multiple-master bus contention. figure 9-8. master/slave transfer block diagram 9.4.3.1 clock phase and polarity controls using two bits in the spi control register1, software selects one of four combinations of serial clock phase and polarity. the cpol clock polarity control bit speci?s an active high or low clock and has no signi?ant effect on the transmission format. the cpha clock phase control bit selects one of two fundamentally different transmission formats. clock phase and polarity should be identical for the master spi device and the communicating slave device. in some cases, the phase and polarity are changed between transmissions to allow a master device to communicate with peripheral slaves having different requirements. 9.4.3.2 cpha = 0 transfer format the ?st edge on the sck line is used to clock the ?st data bit of the slave into the master and the ?st data bit of the master into the slave. in some peripherals, the ?st bit of the slave s data is available at the slave s data out pin as soon as the slave is selected. in this format, the ?st sck edge is issued a half cycle after ss has become low. a half sck cycle later, the second edge appears on the sck line. when this second edge occurs, the value previously latched from the serial data input pin is shifted into the lsb or msb of the shift register, depending on lsbfe bit. after this second edge, the next bit of the spi master data is transmitted out of the serial data output pin of the master to the serial input pin on the slave. this process continues for a total of 16 edges on the sck line, with data being latched on odd numbered edges and shifted on even numbered edges. shift register shift register baud rate generator master spi slave spi mosi mosi miso miso sck sck ss ss v dd functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 275 data reception is double buffered. data is shifted serially into the spi shift register during the transfer and is transferred to the parallel spi data register after the last bit is shifted in. after the 16th (last) sck edge: data that was previously in the master spi data register should now be in the slave data register and the data that was in the slave data register should be in the master. the spif ?g in the spi status register is set indicating that the transfer is complete. figure 9-9 is a timing diagram of an spi transfer where cpha = 0. sck waveforms are shown for cpol = 0 and cpol = 1. the diagram may be interpreted as a master or slave timing diagram because the sck, miso, and mosi pins are connected directly between the master and the slave. the miso signal is the output from the slave and the mosi signal is the output from the master. the ss pin of the master must be either high or recon?ured as a general-purpose output not affecting the spi. figure 9-9. spi clock format 0 (cpha = 0) in slave mode, if the ss line is not deasserted between the successive transmissions then the content of the spi data register is not transmitted, instead the last received byte is transmitted. if the ss line is deasserted for at least minimum idle time (half sck cycle) between successive transmissions then the content of the spi data register is transmitted. tl begin end sck (cpol = 0) sample i change o sel ss (o) transfer sck (cpol = 1) msb ?st (lsbfe = 0): lsb ?st (lsbfe = 1): msb lsb lsb msb bit 5 bit 2 bit 6 bit 1 bit 4 bit 3 bit 3 bit 4 bit 2 bit 5 bit 1 bit 6 change o sel ss (i) mosi pin miso pin master only mosi/miso tt if next transfer begins here for t t , t l , t l minimum 1/2 sck ti tl t l = minimum leading time before the ?st sck edge t t = minimum trailing time after the last sck edge t i = minimum idling time between transfers (minimum ss high time) t l , t t , and t i are guaranteed for the master mode and required for the slave mode. 1 2 34 56 78910111213141516 sck edge nr. end of idle state begin of idle state chapter 9 serial peripheral interface (spiv3) mc9s12ne64 data sheet, rev. 1.1 276 freescale semiconductor in master mode, with slave select output enabled the ss line is always deasserted and reasserted between successive transfers for at least minimum idle time. 9.4.3.3 cpha = 1 transfer format some peripherals require the ?st sck edge before the ?st data bit becomes available at the data out pin, the second edge clocks data into the system. in this format, the ?st sck edge is issued by setting the cpha bit at the beginning of the 8-cycle transfer operation. the ?st edge of sck occurs immediately after the half sck clock cycle synchronization delay. this ?st edge commands the slave to transfer its ?st data bit to the serial data input pin of the master. a half sck cycle later, the second edge appears on the sck pin. this is the latching edge for both the master and slave. when the third edge occurs, the value previously latched from the serial data input pin is shifted into the lsb or msb of the spi shift register, depending on lsbfe bit. after this edge, the next bit of the master data is coupled out of the serial data output pin of the master to the serial input pin on the slave. this process continues for a total of 16 edges on the sck line with data being latched on even numbered edges and shifting taking place on odd numbered edges. data reception is double buffered, data is serially shifted into the spi shift register during the transfer and is transferred to the parallel spi data register after the last bit is shifted in. after the 16th sck edge: data that was previously in the spi data register of the master is now in the data register of the slave, and data that was in the data register of the slave is in the master. the spif ?g bit in spisr is set indicating that the transfer is complete. figure 9-10 shows two clocking variations for cpha = 1. the diagram may be interpreted as a master or slave timing diagram because the sck, miso, and mosi pins are connected directly between the master and the slave. the miso signal is the output from the slave, and the mosi signal is the output from the master. the ss line is the slave select input to the slave. the ss pin of the master must be either high or recon?ured as a general-purpose output not affecting the spi. the ss line can remain active low between successive transfers (can be tied low at all times). this format is sometimes preferred in systems having a single ?ed master and a single slave that drive the miso data line. back-to-back transfers in master mode in master mode, if a transmission has completed and a new data byte is available in the spi data register, this byte is send out immediately without a trailing and minimum idle time. the spi interrupt request ?g (spif) is common to both the master and slave modes. spif gets set one half sck cycle after the last sck edge. functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 277 figure 9-10. spi clock format 1 (cpha = 1) 9.4.4 spi baud rate generation baud rate generation consists of a series of divider stages. six bits in the spi baud rate register (sppr2, sppr1, sppr0, spr2, spr1, and spr0) determine the divisor to the spi module clock which results in the spi baud rate. the spi clock rate is determined by the product of the value in the baud rate preselection bits (sppr2?ppr0) and the value in the baud rate selection bits (spr2?pr0). the module clock divisor equation is shown in figure 9-11 when all bits are clear (the default condition), the spi module clock is divided by 2. when the selection bits (spr2?pr0) are 001 and the preselection bits (sppr2?ppr0) are 000, the module clock divisor becomes 4. when the selection bits are 010, the module clock divisor becomes 8 etc. when the preselection bits are 001, the divisor determined by the selection bits is multiplied by 2. when the preselection bits are 010, the divisor is multiplied by 3, etc. see table 9-7 for baud rate calculations for all bit conditions, based on a 25-mhz bus clock. the two sets of selects allows the clock to be divided by a non-power of two to achieve other baud rates such as divide by 6, divide by 10, etc. tl tt for t t , t l , t l minimum 1/2 sck ti tl if next transfer begins here begin end sck (cpol = 0) sample i change o sel ss (o) transfer sck (cpol = 1) msb ?st (lsbfe = 0): lsb ?st (lsbfe = 1): msb lsb lsb msb bit 5 bit 2 bit 6 bit 1 bit 4 bit 3 bit 3 bit 4 bit 2 bit 5 bit 1 bit 6 change o sel ss (i) mosi pin miso pin master only mosi/miso t l = minimum leading time before the ?st sck edge, not required for back to back transfers t t = minimum trailing time after the last sck edge t i = minimum idling time between transfers (minimum ss high time), not required for back to back transfers 1 2 34 56 78910111213141516 sck edge nr. end of idle state begin of idle state chapter 9 serial peripheral interface (spiv3) mc9s12ne64 data sheet, rev. 1.1 278 freescale semiconductor the baud rate generator is activated only when the spi is in the master mode and a serial transfer is taking place. in the other cases, the divider is disabled to decrease i dd current. figure 9-11. baud rate divisor equation 9.4.5 special features 9.4.5.1 ss output the ss output feature automatically drives the ss pin low during transmission to select external devices and drives it high during idle to deselect external devices. when ss output is selected, the ss output pin is connected to the ss input pin of the external device. the ss output is available only in master mode during normal spi operation by asserting ssoe and modfen bit as shown in table 9-3 . the mode fault feature is disabled while ss output is enabled. note care must be taken when using the ss output feature in a multimaster system because the mode fault feature is not available for detecting system errors between masters. 9.4.5.2 bidirectional mode (mosi or miso) the bidirectional mode is selected when the spc0 bit is set in spi control register 2 (see table 9-9 ). in this mode, the spi uses only one serial data pin for the interface with external device(s). the mstr bit decides which pin to use. the mosi pin becomes the serial data i/o (momi) pin for the master mode, and the miso pin becomes serial data i/o (siso) pin for the slave mode. the miso pin in master mode and mosi pin in slave mode are not used by the spi. table 9-9. normal mode and bidirectional mode when spe = 1 master mode mstr = 1 slave mode mstr = 0 normal mode spc0 = 0 bidirectional mode spc0 = 1 baudratedivisor sppr 1 + () 2 ? spr 1 + () = spi mosi miso serial out serial in spi mosi miso serial in serial out spi momi serial out serial in bidiroe spi siso serial in serial out bidiroe functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 279 the direction of each serial i/o pin depends on the bidiroe bit. if the pin is con?ured as an output, serial data from the shift register is driven out on the pin. the same pin is also the serial input to the shift register. the sck is output for the master mode and input for the slave mode. the ss is the input or output for the master mode, and it is always the input for the slave mode. the bidirectional mode does not affect sck and ss functions. note in bidirectional master mode, with mode fault enabled, both data pins miso and mosi can be occupied by the spi, though mosi is normally used for transmissions in bidirectional mode and miso is not used by the spi. if a mode fault occurs, the spi is automatically switched to slave mode, in this case miso becomes occupied by the spi and mosi is not used. this has to be considered, if the miso pin is used for other purpose. 9.4.6 error conditions the spi has one error condition: mode fault error 9.4.6.1 mode fault error if the ss input becomes low while the spi is con?ured as a master, it indicates a system error where more than one master may be trying to drive the mosi and sck lines simultaneously. this condition is not permitted in normal operation, the modf bit in the spi status register is set automatically provided the modfen bit is set. in the special case where the spi is in master mode and modfen bit is cleared, the ss pin is not used by the spi. in this special case, the mode fault error function is inhibited and modf remains cleared. in case the spi system is con?ured as a slave, the ss pin is a dedicated input pin. mode fault error doesn t occur in slave mode. if a mode fault error occurs the spi is switched to slave mode, with the exception that the slave output buffer is disabled. so sck, miso and mosi pins are forced to be high impedance inputs to avoid any possibility of con?ct with another output driver. a transmission in progress is aborted and the spi is forced into idle state. if the mode fault error occurs in the bidirectional mode for a spi system con?ured in master mode, output enable of the momi (mosi in bidirectional mode) is cleared if it was set. no mode fault error occurs in the bidirectional mode for spi system con?ured in slave mode. the mode fault ?g is cleared automatically by a read of the spi status register (with modf set) followed by a write to spi control register 1. if the mode fault ?g is cleared, the spi becomes a normal master or slave again. chapter 9 serial peripheral interface (spiv3) mc9s12ne64 data sheet, rev. 1.1 280 freescale semiconductor 9.4.7 operation in run mode in run mode with the spi system enable (spe) bit in the spi control register clear, the spi system is in a low-power, disabled state. spi registers remain accessible, but clocks to the core of this module are disabled. 9.4.8 operation in wait mode spi operation in wait mode depends upon the state of the spiswai bit in spi control register 2. if spiswai is clear, the spi operates normally when the cpu is in wait mode if spiswai is set, spi clock generation ceases and the spi module enters a power conservation state when the cpu is in wait mode. if spiswai is set and the spi is con?ured for master, any transmission and reception in progress stops at wait mode entry. the transmission and reception resumes when the spi exits wait mode. if spiswai is set and the spi is con?ured as a slave, any transmission and reception in progress continues if the sck continues to be driven from the master. this keeps the slave synchronized to the master and the sck. if the master transmits several bytes while the slave is in wait mode, the slave will continue to send out bytes consistent with the operation mode at the start of wait mode (i.e. if the slave is currently sending its spidr to the master, it will continue to send the same byte. else if the slave is currently sending the last received byte from the master, it will continue to send each previous master byte). note care must be taken when expecting data from a master while the slave is in wait or stop mode. even though the shift register will continue to operate, the rest of the spi is shut down (i.e. a spif interrupt will not be generated until exiting stop or wait mode). also, the byte from the shift register will not be copied into the spidr register until after the slave spi has exited wait or stop mode. a spif ?g and spidr copy is only generated if wait mode is entered or exited during a tranmission. if the slave enters wait mode in idle mode and exits wait mode in idle mode, neither a spif nor a spidr copy will occur. 9.4.9 operation in stop mode stop mode is dependent on the system. the spi enters stop mode when the module clock is disabled (held high or low). if the spi is in master mode and exchanging data when the cpu enters stop mode, the transmission is frozen until the cpu exits stop mode. after stop, data to and from the external spi is exchanged correctly. in slave mode, the spi will stay synchronized with the master. the stop mode is not dependent on the spiswai bit. reset mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 281 9.5 reset the reset values of registers and signals are described in the memory map and registers section (see section 9.3, ?emory map and register de?ition ) which details the registers and their bit-?lds. if a data transmission occurs in slave mode after reset without a write to spidr, it will transmit garbage, or the byte last received from the master before the reset. reading from the spidr after reset will always read a byte of zeros. 9.6 interrupts the spiv3 only originates interrupt requests when spi is enabled (spe bit in spicr1 set). the following is a description of how the spiv3 makes a request and how the mcu should acknowledge that request. the interrupt vector offset and interrupt priority are chip dependent. the interrupt ?gs modf, spif and sptef are logically ored to generate an interrupt request. 9.6.1 modf modf occurs when the master detects an error on the ss pin. the master spi must be con?ured for the modf feature (see table 9-3 ). after modf is set, the current transfer is aborted and the following bit is changed: mstr = 0, the master bit in spicr1 resets. the modf interrupt is re?cted in the status register modf ?g. clearing the ?g will also clear the interrupt. this interrupt will stay active while the modf ?g is set. modf has an automatic clearing process which is described in section 9.3.2.4, ?pi status register (spisr) . 9.6.2 spif spif occurs when new data has been received and copied to the spi data register. after spif is set, it does not clear until it is serviced. spif has an automatic clearing process which is described in section 9.3.2.4, ?pi status register (spisr) . in the event that the spif is not serviced before the end of the next transfer (i.e. spif remains active throughout another transfer), the latter transfers will be ignored and no new data will be copied into the spidr. 9.6.3 sptef sptef occurs when the spi data register is ready to accept new data. after sptef is set, it does not clear until it is serviced. sptef has an automatic clearing process which is described in section 9.3.2.4, ?pi status register (spisr) . chapter 9 serial peripheral interface (spiv3) mc9s12ne64 data sheet, rev. 1.1 282 freescale semiconductor mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 283 chapter 10 inter-integrated circuit (iicv2) 10.1 introduction the inter-ic bus (iic) is a two-wire, bidirectional serial bus that provides a simple, ef?ient method of data exchange between devices. being a two-wire device, the iic bus minimizes the need for large numbers of connections between devices, and eliminates the need for an address decoder. this bus is suitable for applications requiring occasional communications over a short distance between a number of devices. it also provides ?xibility, allowing additional devices to be connected to the bus for further expansion and system development. the interface is designed to operate up to 100 kbps with maximum bus loading and timing. the device is capable of operating at higher baud rates, up to a maximum of clock/20, with reduced bus loading. the maximum communication length and the number of devices that can be connected are limited by a maximum bus capacitance of 400 pf. 10.1.1 features the iic module has the following key features: compatible with i2c bus standard multi-master operation software programmable for one of 256 different serial clock frequencies software selectable acknowledge bit interrupt driven byte-by-byte data transfer arbitration lost interrupt with automatic mode switching from master to slave calling address identi?ation interrupt start and stop signal generation/detection repeated start signal generation acknowledge bit generation/detection bus busy detection chapter 10 inter-integrated circuit (iicv2) mc9s12ne64 data sheet, rev. 1.1 284 freescale semiconductor 10.1.2 modes of operation the iic functions the same in normal, special, and emulation modes. it has two low power modes: wait and stop modes. 10.1.3 block diagram the block diagram of the iic module is shown in figure 10-1 . figure 10-1. iic block diagram in/out data shift register address compare sda interrupt clock control start stop arbitration control scl bus_clock iic registers external signal description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 285 10.2 external signal description the iicv2 module has two external pins. 10.2.1 iic_scl ?serial clock line pin this is the bidirectional serial clock line (scl) of the module, compatible to the iic bus speci?ation. 10.2.2 iic_sda ?serial data line pin this is the bidirectional serial data line (sda) of the module, compatible to the iic bus speci?ation. 10.3 memory map and register de?ition this section provides a detailed description of all memory and registers for the iic module. 10.3.1 module memory map the memory map for the iic module is given below in figure 10-2 . the address listed for each register is the address offset.the total address for each register is the sum of the base address for the iic module and the address offset for each register. chapter 10 inter-integrated circuit (iicv2) mc9s12ne64 data sheet, rev. 1.1 286 freescale semiconductor 10.3.2 register descriptions this section consists of register descriptions in address order. each description includes a standard register diagram with an associated ?ure number. details of register bit and ?ld function follow the register diagrams, in bit order. 10.3.2.1 iic address register (ibad) read and write anytime this register contains the address the iic bus will respond to when addressed as a slave; note that it is not the address sent on the bus during the address transfer. register name bit 7 654321 bit 0 ibad r adr7 adr6 adr5 adr4 adr3 adr2 adr1 0 w ibfd r ibc7 ibc6 ibc5 ibc4 ibc3 ibc2 ibc1 ibc0 w ibcr r iben ibie ms/ sl tx/ rx txak 00 ibswai w rsta ibsr r tcf iaas ibb ibal 0srw ibif rxak w ibdr r d7 d6 d5 d4 d3 d2 d1 d0 w = unimplemented or reserved figure 10-2. iic register summary 76543210 r adr7 adr6 adr5 adr4 adr3 adr2 adr1 0 w reset 0 0 0 00000 = unimplemented or reserved figure 10-3. iic bus address register (ibad) table 10-1. ibad field descriptions field description 7:1 adr[7:1] slave address bit 1 to bit 7 contain the speci? slave address to be used by the iic bus module.the default mode of iic bus is slave mode for an address match on the bus. 0 reserved reserved ?bit 0 of the ibad is reserved for future compatibility. this bit will always read 0. memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 287 10.3.2.2 iic frequency divider register (ibfd) read and write anytime 76543210 r ibc7 ibc6 ibc5 ibc4 ibc3 ibc2 ibc1 ibc0 w reset 0 0 0 00000 = unimplemented or reserved figure 10-4. iic bus frequency divider register (ibfd) table 10-2. ibfd field descriptions field description 7:0 ibc[7:0] i bus clock rate 7:0 ?this ?ld is used to prescale the clock for bit rate selection. the bit clock generator is implemented as a prescale divider ibc7:6, prescaled shift register ibc5:3 select the prescaler divider and ibc2-0 select the shift register tap point. the ibc bits are decoded to give the tap and prescale values as shown in table 10-3 . table 10-3. i-bus tap and prescale values ibc2-0 (bin) scl tap (clocks) sda tap (clocks) 000 5 1 001 6 1 010 7 2 011 8 2 100 9 3 101 10 3 110 12 4 111 15 4 ibc5-3 (bin) scl2start (clocks) scl2stop (clocks) scl2tap (clocks) tap2tap (clocks) 0002741 0012742 0102964 0116968 100 14 17 14 16 101 30 33 30 32 110 62 65 62 64 111 126 129 126 128 chapter 10 inter-integrated circuit (iicv2) mc9s12ne64 data sheet, rev. 1.1 288 freescale semiconductor the number of clocks from the falling edge of scl to the ?st tap (tap[1]) is de?ed by the values shown in the scl2tap column of table 10-3 , all subsequent tap points are separated by 2 ibc5-3 as shown in the tap2tap column in table 10-3 . the scl tap is used to generated the scl period and the sda tap is used to determine the delay from the falling edge of scl to sda changing, the sda hold time. ibc7? de?es the multiplier factor mul. the values of mul are shown in the table 10-4 . figure 10-5. scl divider and sda hold the equation used to generate the divider values from the ibfd bits is: scl divider = mul x {2 x (scl2tap + [(scl_tap -1) x tap2tap] + 2)} table 10-4. multiplier factor ibc7-6 mul 00 01 01 02 10 04 11 reserved scl divider sda hold scl sda sda scl start condition stop condition scl hold(start) scl hold(stop) memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 289 the sda hold delay is equal to the cpu clock period multiplied by the sda hold value shown in table 10-5 . the equation used to generate the sda hold value from the ibfd bits is: sda hold = mul x {scl2tap + [(sda_tap - 1) x tap2tap] + 3} the equation for scl hold values to generate the start and stop conditions from the ibfd bits is: scl hold(start) = mul x [scl2start + (scl_tap - 1) x tap2tap] scl hold(stop) = mul x [scl2stop + (scl_tap - 1) x tap2tap] table 10-5. iic divider and hold values (sheet 1 of 5) ibc[7:0] (hex) scl divider (clocks) sda hold (clocks) scl hold (start) scl hold (stop) mul=1 00 20 7 6 11 01 22 7 7 12 02 24 8 8 13 03 26 8 9 14 04 28 9 10 15 05 30 9 11 16 06 34 10 13 18 07 40 10 16 21 08 28 7 10 15 09 32 7 12 17 0a 36 9 14 19 0b 40 9 16 21 0c 44 11 18 23 0d 48 11 20 25 0e 56 13 24 29 0f 68 13 30 35 10 48 9 18 25 11 56 9 22 29 12 64 13 26 33 13 72 13 30 37 14 80 17 34 41 15 88 17 38 45 16 104 21 46 53 17 128 21 58 65 18 80 9 38 41 19 96 9 46 49 1a 112 17 54 57 1b 128 17 62 65 1c 144 25 70 73 1d 160 25 78 81 1e 192 33 94 97 1f 240 33 118 121 20 160 17 78 81 21 192 17 94 97 22 224 33 110 113 chapter 10 inter-integrated circuit (iicv2) mc9s12ne64 data sheet, rev. 1.1 290 freescale semiconductor 23 256 33 126 129 24 288 49 142 145 25 320 49 158 161 26 384 65 190 193 27 480 65 238 241 28 320 33 158 161 29 384 33 190 193 2a 448 65 222 225 2b 512 65 254 257 2c 576 97 286 289 2d 640 97 318 321 2e 768 129 382 385 2f 960 129 478 481 30 640 65 318 321 31 768 65 382 385 32 896 129 446 449 33 1024 129 510 513 34 1152 193 574 577 35 1280 193 638 641 36 1536 257 766 769 37 1920 257 958 961 38 1280 129 638 641 39 1536 129 766 769 3a 1792 257 894 897 3b 2048 257 1022 1025 3c 2304 385 1150 1153 3d 2560 385 1278 1281 3e 3072 513 1534 1537 3f 3840 513 1918 1921 mul=2 40 40 14 12 22 41 44 14 14 24 42 48 16 16 26 43 52 16 18 28 44 56 18 20 30 45 60 18 22 32 46 68 20 26 36 47 80 20 32 42 48 56 14 20 30 49 64 14 24 34 4a 72 18 28 38 4b 80 18 32 42 4c 88 22 36 46 4d 96 22 40 50 4e 112 26 48 58 table 10-5. iic divider and hold values (sheet 2 of 5) ibc[7:0] (hex) scl divider (clocks) sda hold (clocks) scl hold (start) scl hold (stop) memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 291 4f 136 26 60 70 50 96 18 36 50 51 112 18 44 58 52 128 26 52 66 53 144 26 60 74 54 160 34 68 82 55 176 34 76 90 56 208 42 92 106 57 256 42 116 130 58 160 18 76 82 59 192 18 92 98 5a 224 34 108 114 5b 256 34 124 130 5c 288 50 140 146 5d 320 50 156 162 5e 384 66 188 194 5f 480 66 236 242 60 320 34 156 162 61 384 34 188 194 62 448 66 220 226 63 512 66 252 258 64 576 98 284 290 65 640 98 316 322 66 768 130 380 386 67 960 130 476 482 68 640 66 316 322 69 768 66 380 386 6a 896 130 444 450 6b 1024 130 508 514 6c 1152 194 572 578 6d 1280 194 636 642 6e 1536 258 764 770 6f 1920 258 956 962 70 1280 130 636 642 71 1536 130 764 770 72 1792 258 892 898 73 2048 258 1020 1026 74 2304 386 1148 1154 75 2560 386 1276 1282 76 3072 514 1532 1538 77 3840 514 1916 1922 78 2560 258 1276 1282 79 3072 258 1532 1538 7a 3584 514 1788 1794 7b 4096 514 2044 2050 table 10-5. iic divider and hold values (sheet 3 of 5) ibc[7:0] (hex) scl divider (clocks) sda hold (clocks) scl hold (start) scl hold (stop) chapter 10 inter-integrated circuit (iicv2) mc9s12ne64 data sheet, rev. 1.1 292 freescale semiconductor 7c 4608 770 2300 2306 7d 5120 770 2556 2562 7e 6144 1026 3068 3074 7f 7680 1026 3836 3842 mul=4 80 80 28 24 44 81 88 28 28 48 82 96 32 32 52 83 104 32 36 56 84 112 36 40 60 85 120 36 44 64 86 136 40 52 72 87 160 40 64 84 88 112 28 40 60 89 128 28 48 68 8a 144 36 56 76 8b 160 36 64 84 8c 176 44 72 92 8d 192 44 80 100 8e 224 52 96 116 8f 272 52 120 140 90 192 36 72 100 91 224 36 88 116 92 256 52 104 132 93 288 52 120 148 94 320 68 136 164 95 352 68 152 180 96 416 84 184 212 97 512 84 232 260 98 320 36 152 164 99 384 36 184 196 9a 448 68 216 228 9b 512 68 248 260 9c 576 100 280 292 9d 640 100 312 324 9e 768 132 376 388 9f 960 132 472 484 a0 640 68 312 324 a1 768 68 376 388 a2 896 132 440 452 a3 1024 132 504 516 a4 1152 196 568 580 a5 1280 196 632 644 a6 1536 260 760 772 a7 1920 260 952 964 table 10-5. iic divider and hold values (sheet 4 of 5) ibc[7:0] (hex) scl divider (clocks) sda hold (clocks) scl hold (start) scl hold (stop) memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 293 10.3.2.3 iic control register (ibcr) read and write anytime a8 1280 132 632 644 a9 1536 132 760 772 aa 1792 260 888 900 ab 2048 260 1016 1028 ac 2304 388 1144 1156 ad 2560 388 1272 1284 ae 3072 516 1528 1540 af 3840 516 1912 1924 b0 2560 260 1272 1284 b1 3072 260 1528 1540 b2 3584 516 1784 1796 b3 4096 516 2040 2052 b4 4608 772 2296 2308 b5 5120 772 2552 2564 b6 6144 1028 3064 3076 b7 7680 1028 3832 3844 b8 5120 516 2552 2564 b9 6144 516 3064 3076 ba 7168 1028 3576 3588 bb 8192 1028 4088 4100 bc 9216 1540 4600 4612 bd 10240 1540 5112 5124 be 12288 2052 6136 6148 bf 15360 2052 7672 7684 76543210 r iben ibie ms/sl tx/rx txak 00 ibswai w rsta reset 0 0 0 00000 = unimplemented or reserved figure 10-6. iic bus control register (ibcr) table 10-5. iic divider and hold values (sheet 5 of 5) ibc[7:0] (hex) scl divider (clocks) sda hold (clocks) scl hold (start) scl hold (stop) chapter 10 inter-integrated circuit (iicv2) mc9s12ne64 data sheet, rev. 1.1 294 freescale semiconductor wait mode is entered via execution of a cpu wai instruction. in the event that the ibswai bit is set, all clocks internal to the iic will be stopped and any transmission currently in progress will halt.if the cpu were woken up by a source other than the iic module, then clocks would restart and the iic would resume table 10-6. ibcr field descriptions field description 7 iben i-bus enable ?this bit controls the software reset of the entire iic bus module. 0 the module is reset and disabled. this is the power-on reset situation. when low the interface is held in reset but registers can be accessed 1 the iic bus module is enabled.this bit must be set before any other ibcr bits have any effect if the iic bus module is enabled in the middle of a byte transfer the interface behaves as follows: slave mode ignores the current transfer on the bus and starts operating whenever a subsequent start condition is detected. master mode will not be aware that the bus is busy, hence if a start cycle is initiated then the current bus cycle may become corrupt. this would ultimately result in either the current bus master or the iic bus module losing arbitration, after which bus operation would return to normal. 6 ibie i-bus interrupt enable 0 interrupts from the iic bus module are disabled. note that this does not clear any currently pending interrupt condition 1 interrupts from the iic bus module are enabled. an iic bus interrupt occurs provided the ibif bit in the status register is also set. 5 ms/sl master/slave mode select bit upon reset, this bit is cleared. when this bit is changed from 0 to 1, a start signal is generated on the bus, and the master mode is selected. when this bit is changed from 1 to 0, a stop signal is generated and the operation mode changes from master to slave.a stop signal should only be generated if the ibif ?g is set. ms/ sl is cleared without generating a stop signal when the master loses arbitration. 0 slave mode 1 master mode 4 tx/rx transmit/receive mode select bit ?this bit selects the direction of master and slave transfers. when addressed as a slave this bit should be set by software according to the srw bit in the status register. in master mode this bit should be set according to the type of transfer required. therefore, for address cycles, this bit will always be high. 0 receive 1 transmit 3 txak transmit acknowledge enable this bit speci?s the value driven onto sda during data acknowledge cycles for both master and slave receivers. the iic module will always acknowledge address matches, provided it is enabled, regardless of the value of txak. note that values written to this bit are only used when the iic bus is a receiver, not a transmitter. 0 an acknowledge signal will be sent out to the bus at the 9th clock bit after receiving one byte data 1 no acknowledge signal response is sent (i.e., acknowledge bit = 1) 2 rsta repeat start ?writing a 1 to this bit will generate a repeated start condition on the bus, provided it is the current bus master. this bit will always be read as a low. attempting a repeated start at the wrong time, if the bus is owned by another master, will result in loss of arbitration. 1 generate repeat start cycle 1 reserved reserved ?bit 1 of the ibcr is reserved for future compatibility. this bit will always read 0. 0 ibswai i bus interface stop in wait mode 0 iic bus module clock operates normally 1 halt iic bus module clock generation in wait mode memory map and register de?ition mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 295 from where was during the previous transmission. it is not possible for the iic to wake up the cpu when its internal clocks are stopped. if it were the case that the ibswai bit was cleared when the wai instruction was executed, the iic internal clocks and interface would remain alive, continuing the operation which was currently underway. it is also possible to con?ure the iic such that it will wake up the cpu via an interrupt at the conclusion of the current operation. see the discussion on the ibif and ibie bits in the ibsr and ibcr, respectively. 10.3.2.4 iic status register (ibsr) this status register is read-only with exception of bit 1 (ibif) and bit 4 (ibal), which are software clearable. 76543210 r tcf iaas ibb ibal 0srw ibif rxak w reset 1 0 0 00000 = unimplemented or reserved figure 10-7. iic bus status register (ibsr) table 10-7. ibsr field descriptions field description 7 tcf data transferring bit ?while one byte of data is being transferred, this bit is cleared. it is set by the falling edge of the 9th clock of a byte transfer. note that this bit is only valid during or immediately following a transfer to the iic module or from the iic module. 0 transfer in progress 1 transfer complete 6 iaas addressed as a slave bit when its own speci? address (i-bus address register) is matched with the calling address, this bit is set.the cpu is interrupted provided the ibie is set.then the cpu needs to check the srw bit and set its tx/ rx mode accordingly.writing to the i-bus control register clears this bit. 0 not addressed 1 addressed as a slave 5 ibb bus busy bit 0 this bit indicates the status of the bus. when a start signal is detected, the ibb is set. if a stop signal is detected, ibb is cleared and the bus enters idle state. 1 bus is busy 4 ibal arbitration lost ?the arbitration lost bit (ibal) is set by hardware when the arbitration procedure is lost. arbitration is lost in the following circumstances: 1. sda sampled low when the master drives a high during an address or data transmit cycle. 2. sda sampled low when the master drives a high during the acknowledge bit of a data receive cycle. 3. a start cycle is attempted when the bus is busy. 4. a repeated start cycle is requested in slave mode. 5. a stop condition is detected when the master did not request it. this bit must be cleared by software, by writing a one to it. a write of 0 has no effect on this bit. 3 reserved reserved ?bit 3 of ibsr is reserved for future use. a read operation on this bit will return 0. chapter 10 inter-integrated circuit (iicv2) mc9s12ne64 data sheet, rev. 1.1 296 freescale semiconductor 10.3.2.5 iic data i/o register (ibdr) in master transmit mode, when data is written to the ibdr a data transfer is initiated. the most signi?ant bit is sent ?st. in master receive mode, reading this register initiates next byte data receiving. in slave mode, the same functions are available after an address match has occurred.note that the tx/rx bit in the ibcr must correctly re?ct the desired direction of transfer in master and slave modes for the transmission to begin. for instance, if the iic is con?ured for master transmit but a master receive is desired, then reading the ibdr will not initiate the receive. reading the ibdr will return the last byte received while the iic is con?ured in either master receive or slave receive modes. the ibdr does not re?ct every byte that is transmitted on the iic bus, nor can software verify that a byte has been written to the ibdr correctly by reading it back. in master transmit mode, the ?st byte of data written to ibdr following assertion of ms/ sl is used for the address transfer and should com.prise of the calling address (in position d7:d1) concatenated with the required r/ w bit (in position d0). 2 srw slave read/write when iaas is set this bit indicates the value of the r/w command bit of the calling address sent from the master this bit is only valid when the i-bus is in slave mode, a complete address transfer has occurred with an address match and no other transfers have been initiated. checking this bit, the cpu can select slave transmit/receive mode according to the command of the master. 0 slave receive, master writing to slave 1 slave transmit, master reading from slave 1 ibif i-bus interrupt ?the ibif bit is set when one of the following conditions occurs: ?arbitration lost (ibal bit set) ?byte transfer complete (tcf bit set) ?addressed as slave (iaas bit set) it will cause a processor interrupt request if the ibie bit is set. this bit must be cleared by software, writing a one to it. a write of 0 has no effect on this bit. 0 rxak received acknowledge ?the value of sda during the acknowledge bit of a bus cycle. if the received acknowledge bit (rxak) is low, it indicates an acknowledge signal has been received after the completion of 8 bits data transmission on the bus. if rxak is high, it means no acknowledge signal is detected at the 9th clock. 0 acknowledge received 1 no acknowledge received 76543210 r d7 d6 d5 d4 d3 d2 d1 d0 w reset 0 0 0 00000 figure 10-8. iic bus data i/o register (ibdr) table 10-7. ibsr field descriptions (continued) field description functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 297 10.4 functional description this section provides a complete functional description of the iicv2. 10.4.1 i-bus protocol the iic bus system uses a serial data line (sda) and a serial clock line (scl) for data transfer. all devices connected to it must have open drain or open collector outputs. logic and function is exercised on both lines with external pull-up resistors. the value of these resistors is system dependent. normally, a standard communication is composed of four parts: start signal, slave address transmission, data transfer and stop signal. they are described brie? in the following sections and illustrated in figure 10-9 . figure 10-9. iic-bus transmission signals 10.4.1.1 start signal when the bus is free, i.e. no master device is engaging the bus (both scl and sda lines are at logical high), a master may initiate communication by sending a start signal.as shown in figure 10-9 , a start signal is de?ed as a high-to-low transition of sda while scl is high. this signal denotes the beginning of a new data transfer (each data transfer may contain several bytes of data) and brings all slaves out of their idle states. scl sda start signal ack bit 12345678 msb lsb 12345678 msb lsb stop signal no scl sda 1234567 8 msb lsb 1 2 5 678 msb lsb repeated 34 99 ad7 ad6 ad5 ad4 ad3 ad2 ad1 r/w xxx d7 d6 d5 d4 d3 d2 d1 d0 calling address read/ data byte ad7 ad6 ad5 ad4 ad3 ad2 ad1 r/w ad7 ad6 ad5 ad4 ad3 ad2 ad1 r/w new calling address 99 xx ack bit write start signal start signal ack bit calling address read/ write stop signal no ack bit read/ write chapter 10 inter-integrated circuit (iicv2) mc9s12ne64 data sheet, rev. 1.1 298 freescale semiconductor figure 10-10. start and stop conditions 10.4.1.2 slave address transmission the ?st byte of data transfer immediately after the start signal is the slave address transmitted by the master. this is a seven-bit calling address followed by a r/w bit. the r/w bit tells the slave the desired direction of data transfer. 1 = read transfer, the slave transmits data to the master. 0 = write transfer, the master transmits data to the slave. only the slave with a calling address that matches the one transmitted by the master will respond by sending back an acknowledge bit. this is done by pulling the sda low at the 9th clock (see figure 10-9 ). no two slaves in the system may have the same address. if the iic bus is master, it must not transmit an address that is equal to its own slave address. the iic bus cannot be master and slave at the same time.however, if arbitration is lost during an address cycle the iic bus will revert to slave mode and operate correctly even if it is being addressed by another master. 10.4.1.3 data transfer as soon as successful slave addressing is achieved, the data transfer can proceed byte-by-byte in a direction speci?d by the r/w bit sent by the calling master all transfers that come after an address cycle are referred to as data transfers, even if they carry sub-address information for the slave device. each data byte is 8 bits long. data may be changed only while scl is low and must be held stable while scl is high as shown in figure 10-9 . there is one clock pulse on scl for each data bit, the msb being transferred ?st. each data byte has to be followed by an acknowledge bit, which is signalled from the receiving device by pulling the sda low at the ninth clock. so one complete data byte transfer needs nine clock pulses. if the slave receiver does not acknowledge the master, the sda line must be left high by the slave. the master can then generate a stop signal to abort the data transfer or a start signal (repeated start) to commence a new calling. sda scl start condition stop condition functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 299 if the master receiver does not acknowledge the slave transmitter after a byte transmission, it means 'end of data' to the slave, so the slave releases the sda line for the master to generate stop or start signal. 10.4.1.4 stop signal the master can terminate the communication by generating a stop signal to free the bus. however, the master may generate a start signal followed by a calling command without generating a stop signal ?st. this is called repeated start. a stop signal is de?ed as a low-to-high transition of sda while scl at logical 1 (see figure 10-9 ). the master can generate a stop even if the slave has generated an acknowledge at which point the slave must release the bus. 10.4.1.5 repeated start signal as shown in figure 10-9 , a repeated start signal is a start signal generated without ?st generating a stop signal to terminate the communication. this is used by the master to communicate with another slave or with the same slave in different mode (transmit/receive mode) without releasing the bus. 10.4.1.6 arbitration procedure the inter-ic bus is a true multi-master bus that allows more than one master to be connected on it. if two or more masters try to control the bus at the same time, a clock synchronization procedure determines the bus clock, for which the low period is equal to the longest clock low period and the high is equal to the shortest one among the masters. the relative priority of the contending masters is determined by a data arbitration procedure, a bus master loses arbitration if it transmits logic 1 while another master transmits logic 0. the losing masters immediately switch over to slave receive mode and stop driving sda output. in this case the transition from master to slave mode does not generate a stop condition. meanwhile, a status bit is set by hardware to indicate loss of arbitration. 10.4.1.7 clock synchronization because wire-and logic is performed on scl line, a high-to-low transition on scl line affects all the devices connected on the bus. the devices start counting their low period and as soon as a device's clock has gone low, it holds the scl line low until the clock high state is reached.however, the change of low to high in this device clock may not change the state of the scl line if another device clock is within its low period. therefore, synchronized clock scl is held low by the device with the longest low period. devices with shorter low periods enter a high wait state during this time (see figure 10-10 ). when all devices concerned have counted off their low period, the synchronized clock scl line is released and pulled high. there is then no difference between the device clocks and the state of the scl line and all the devices start counting their high periods.the ?st device to complete its high period pulls the scl line low again. chapter 10 inter-integrated circuit (iicv2) mc9s12ne64 data sheet, rev. 1.1 300 freescale semiconductor figure 10-11. iic-bus clock synchronization 10.4.1.8 handshaking the clock synchronization mechanism can be used as a handshake in data transfer. slave devices may hold the scl low after completion of one byte transfer (9 bits). in such case, it halts the bus clock and forces the master clock into wait states until the slave releases the scl line. 10.4.1.9 clock stretching the clock synchronization mechanism can be used by slaves to slow down the bit rate of a transfer. after the master has driven scl low the slave can drive scl low for the required period and then release it.if the slave scl low period is greater than the master scl low period then the resulting scl bus signal low period is stretched. 10.4.2 operation in run mode this is the basic mode of operation. 10.4.3 operation in wait mode iic operation in wait mode can be con?ured. depending on the state of internal bits, the iic can operate normally when the cpu is in wait mode or the iic clock generation can be turned off and the iic module enters a power conservation state during wait mode. in the later case, any transmission or reception in progress stops at wait mode entry. 10.4.4 operation in stop mode the iic is inactive in stop mode for reduced power consumption. the stop instruction does not affect iic register states. scl1 scl2 scl internal counter reset wait start counting high period resets mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 301 10.5 resets the reset state of each individual bit is listed in section 10.3, ?emory map and register de?ition , which details the registers and their bit-?lds. 10.6 interrupts iicv2 uses only one interrupt vector. table 10-8. interrupt summary internally there are three types of interrupts in iic. the interrupt service routine can determine the interrupt type by reading the status register. iic interrupt can be generated on 1. arbitration lost condition (ibal bit set) 2. byte transfer condition (tcf bit set) 3. address detect condition (iaas bit set) the iic interrupt is enabled by the ibie bit in the iic control register. it must be cleared by writing 0 to the ibf bit in the interrupt service routine. 10.7 initialization/application information 10.7.1 iic programming examples 10.7.1.1 initialization sequence reset will put the iic bus control register to its default status. before the interface can be used to transfer serial data, an initialization procedure must be carried out, as follows: 1. update the frequency divider register (ibfd) and select the required division ratio to obtain scl frequency from system clock. 2. update the iic bus address register (ibad) to de?e its slave address. 3. set the iben bit of the iic bus control register (ibcr) to enable the iic interface system. 4. modify the bits of the iic bus control register (ibcr) to select master/slave mode, transmit/receive mode and interrupt enable or not. interrupt offset vector priority source description iic interrupt ibal, tcf, iaas bits in ibsr register when either of ibal, tcf or iaas bits is set may cause an interrupt based on arbitration lost, transfer complete or address detect conditions chapter 10 inter-integrated circuit (iicv2) mc9s12ne64 data sheet, rev. 1.1 302 freescale semiconductor 10.7.1.2 generation of start after completion of the initialization procedure, serial data can be transmitted by selecting the 'master transmitter' mode. if the device is connected to a multi-master bus system, the state of the iic bus busy bit (ibb) must be tested to check whether the serial bus is free. if the bus is free (ibb=0), the start condition and the ?st byte (the slave address) can be sent. the data written to the data register comprises the slave calling address and the lsb set to indicate the direction of transfer required from the slave. the bus free time (i.e., the time between a stop condition and the following start condition) is built into the hardware that generates the start cycle. depending on the relative frequencies of the system clock and the scl period it may be necessary to wait until the iic is busy after writing the calling address to the ibdr before proceeding with the following instructions. this is illustrated in the following example. an example of a program which generates the start signal and transmits the ?st byte of data (slave address) is shown below: 10.7.1.3 post-transfer software response transmission or reception of a byte will set the data transferring bit (tcf) to 1, which indicates one byte communication is ?ished. the iic bus interrupt bit (ibif) is set also; an interrupt will be generated if the interrupt function is enabled during initialization by setting the ibie bit. software must clear the ibif bit in the interrupt routine ?st. the tcf bit will be cleared by reading from the iic bus data i/o register (ibdr) in receive mode or writing to ibdr in transmit mode. software may service the iic i/o in the main program by monitoring the ibif bit if the interrupt function is disabled. note that polling should monitor the ibif bit rather than the tcf bit because their operation is different when arbitration is lost. note that when an interrupt occurs at the end of the address cycle the master will always be in transmit mode, i.e. the address is transmitted. if master receive mode is required, indicated by r/w bit in ibdr, then the tx/rx bit should be toggled at this stage. during slave mode address cycles (iaas=1), the srw bit in the status register is read to determine the direction of the subsequent transfer and the tx/rx bit is programmed accordingly. for slave mode data cycles (iaas=0) the srw bit is not valid, the tx/rx bit in the control register should be read to determine the direction of the current transfer. the following is an example of a software response by a 'master transmitter' in the interrupt routine. chflag brset ibsr,#$20,* ;wait for ibb flag to clear txstart bset ibcr,#$30 ;set transmit and master mode;i.e. generate start condition movb calling,ibdr ;transmit the calling address, d0=r/w ibfree brclr ibsr,#$20,* ;wait for ibb flag to set isr bclr ibsr,#$02 ;clear the ibif flag brclr ibcr,#$20,slave ;branch if in slave mode brclr ibcr,#$10,receive ;branch if in receive mode brset ibsr,#$01,end ;if no ack, end of transmission transmit movb databuf,ibdr ;transmit next byte of data initialization/application information mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 303 10.7.1.4 generation of stop a data transfer ends with a stop signal generated by the 'master' device. a master transmitter can simply generate a stop signal after all the data has been transmitted. the following is an example showing how a stop condition is generated by a master transmitter. if a master receiver wants to terminate a data transfer, it must inform the slave transmitter by not acknowledging the last byte of data which can be done by setting the transmit acknowledge bit (txak) before reading the 2nd last byte of data. before reading the last byte of data, a stop signal must be generated ?st. the following is an example showing how a stop signal is generated by a master receiver. 10.7.1.5 generation of repeated start at the end of data transfer, if the master continues to want to communicate on the bus, it can generate another start signal followed by another slave address without ?st generating a stop signal. a program example is as shown. 10.7.1.6 slave mode in the slave interrupt service routine, the module addressed as slave bit (iaas) should be tested to check if a calling of its own address has just been received. if iaas is set, software should set the transmit/receive mode select bit (tx/rx bit of ibcr) according to the r/w command bit (srw). writing to the ibcr clears the iaas automatically. note that the only time iaas is read as set is from the interrupt at the end of the address cycle where an address match occurred, interrupts resulting from subsequent data transfers will have iaas cleared. a data transfer may now be initiated by writing information to ibdr, for slave transmits, or dummy reading from ibdr, in slave receive mode. the slave will drive scl low in-between byte transfers, scl is released when the ibdr is accessed in the required mode. mastx tst txcnt ;get value from the transmiting counter beq end ;end if no more data brset ibsr,#$01,end ;end if no ack movb databuf,ibdr ;transmit next byte of data dec txcnt ;decrease the txcnt bra emastx ;exit end bclr ibcr,#$20 ;generate a stop condition emastx rti ;return from interrupt masr dec rxcnt ;decrease the rxcnt beq enmasr ;last byte to be read movb rxcnt,d1 ;check second last byte dec d1 ;to be read bne nxmar ;not last or second last lamar bset ibcr,#$08 ;second last, disable ack ;transmitting bra nxmar enmasr bclr ibcr,#$20 ;last one, generate ?top?signal nxmar movb ibdr,rxbuf ;read data and store rti restart bset ibcr,#$04 ;another start (restart) movb calling,ibdr ;transmit the calling address;d0=r/w chapter 10 inter-integrated circuit (iicv2) mc9s12ne64 data sheet, rev. 1.1 304 freescale semiconductor in slave transmitter routine, the received acknowledge bit (rxak) must be tested before transmitting the next byte of data. setting rxak means an 'end of data' signal from the master receiver, after which it must be switched from transmitter mode to receiver mode by software. a dummy read then releases the scl line so that the master can generate a stop signal. 10.7.1.7 arbitration lost if several masters try to engage the bus simultaneously, only one master wins and the others lose arbitration. the devices which lost arbitration are immediately switched to slave receive mode by the hardware. their data output to the sda line is stopped, but scl continues to be generated until the end of the byte during which arbitration was lost. an interrupt occurs at the falling edge of the ninth clock of this transfer with ibal=1 and ms/sl=0. if one master attempts to start transmission while the bus is being engaged by another master, the hardware will inhibit the transmission; switch the ms/sl bit from 1 to 0 without generating stop condition; generate an interrupt to cpu and set the ibal to indicate that the attempt to engage the bus is failed. when considering these cases, the slave service routine should test the ibal ?st and the software should clear the ibal bit if it is set. initialization/application information mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 305 figure 10-12. flow-chart of typical iic interrupt routine clear master mode ? tx/rx ? last byte transmitted ? rxak=0 ? end of addr cycle (master rx) ? write next byte to ibdr switch to rx mode dummy read from ibdr generate stop signal read data from ibdr and store set txak =1 generate stop signal 2nd last byte to be read ? last byte to be read ? arbitration lost ? clear ibal iaas=1 ? iaas=1 ? srw=1 ? tx/rx ? set tx mode write data to ibdr set rx mode dummy read from ibdr ack from receiver ? tx next byte read data from ibdr and store switch to rx mode dummy read from ibdr rti yn y y y y y y y y y n n n n n n n n n y tx rx rx tx (write) (read) n ibif address transfer data transfer chapter 10 inter-integrated circuit (iicv2) mc9s12ne64 data sheet, rev. 1.1 306 freescale semiconductor mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 307 chapter 11 ethernet media access controller (emacv1) 11.1 introduction the ethernet media access controller (emac) is ieee 802.3 compliant supporting 10/100 ethernet operation. the emac module supports the medium-independent interface (mii) and the mii management interface (mi). by connecting a physical layer device (phy) supporting mii, a 10/100 mbps ethernet network is implemented. 11.1.1 features ieee 802.3 compliant medium-independent interface (mii) full-duplex and half-duplex modes flow control using pause frames mii management function address recognition frames with broadcast address are always accepted or always rejected exact match for single 48-bit individual (unicast) address hash (64-bit hash) check of group (multicast) addresses promiscuous mode ethertype ?ter loopback mode two receive and one transmit ethernet buffer interfaces chapter 11 ethernet media access controller (emacv1) mc9s12ne64 data sheet, rev. 1.1 308 freescale semiconductor 11.1.2 block diagram figure 11-1. emac block diagram 11.2 external signal description the emac module supports the medium-independent interface (mii) which requires 18 input/output (i/o) pins. the transmit and receive functions require seven signals each (four data signals, a delimiter, error, and clock). in addition, there are two signals which indicate the status of the media (one indicates the presence of a carrier and the other indicates that a collision has occurred). the mii management function requires the remaining two signals, mii_mdc and mii_mdio. each mii signal is described below. these signals are available externally only when the emac is enabled in external phy mode. mii signals are available only in certain mcu modes. receiver transmitter mac flow control mii management mii ip bus registers tx buffer interface emac ip bus signals ram interface signals ram interface signals mii_mdc mii_txclk mii_txen mii_txd[3:0] mii_txer mii_crs mii_col mii_rxclk mii_rxdv mii_rxd[3:0] mii_rxer mii_mdio rx buffer a interface rx buffer b interface mcu interface mii interface external signal description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 309 11.2.1 mii_txclk ?mii transmit clock the phy provides this input clock, which is used as a timing reference for mii_txd, mii_txen, and mii_txer. it operates at 25% of the transmit data rate (25 mhz for 100 mbps or 2.5 mhz for 10 mbps). the emac bus clock frequency must be greater-than or equal-to mii_txclk. 11.2.2 mii_txd[3:0] ?mii transmit data mii_txd[3:0] is a transmit nibble of data to be transferred from the emac to the phy. the nibble is synchronized to the rising edge of mii_txclk. when mii_txen is asserted, the phy accepts mii_txd[3:0], and at all other times, mii_txd[3:0] is ignored. mii_txd[0] is the least signi?ant bit. table 11-1 summarizes the permissible encoding of mii_txd[3:0], mii_txen, and mii_txer. 11.2.3 mii_txen ?mii transmit enable assertion of this output signal indicates that there are valid nibbles being presented on the mii and the transmission can start. this signal is asserted with the ?st nibble of the preamble, remains asserted until all nibbles to be transmitted have been presented to the phy, and is negated following the ?al nibble of the frame. 11.2.4 mii_txer ?mii transmit coding error assertion of this output signal for one or more clock cycles while mii_txen is asserted causes the phy to transmit one or more illegal symbols. mii_txer is asserted if the abort command is issued during a transmit. this signal transitions synchronously with respect to mii_txclk. 11.2.5 mii_rxclk ?mii receive clock the phy provides this input clock, which is used as a timing reference for mii_rxd, mii_rxdv, and mii_rxer. it operates at 25% of the receive data rate (25 mhz for 100 mbps or 2.5 mhz for 10 mbps). the emac bus clock frequency must be greater-than or equal-to mii_rxclk. table 11-1. permissible encoding of mii_txd, mii_txen, and mii_txer mii_txen mii_txer mii_txd[3:0] indication 0 0 0000 through 1111 normal interframe 0 1 0000 through 1111 reserved 1 0 0000 through 1111 normal data transmission 1 1 0000 through 1111 transmit error propagation chapter 11 ethernet media access controller (emacv1) mc9s12ne64 data sheet, rev. 1.1 310 freescale semiconductor 11.2.6 mii_rxd[3:0] ?mii receive data mii_rxd[3:0] is a receive nibble of data to be transferred from the phy to the emac. the nibble is synchronized to the rising edge of mii_rxclk. when mii_rxdv is asserted, the emac accepts the mii_rxd[3:0], and at all other times, mii_rxd[3:0] is ignored. mii_rxd[0] is the least signi?ant bit. table 11-2 summarizes the permissible encoding of mii_rxd, mii_rxdv, and mii_rxer, as well as the speci? indication provided by each code. a false carrier indication is ignored by the emac. 11.2.7 mii_rxdv ?mii receive data valid when this input signal is asserted, the phy is indicating that a valid nibble is present on the mii. this signal remains asserted from the ?st recovered nibble of the frame through the last nibble. assertion of mii_rxdv must start no later than the start frame delimiter (sfd). 11.2.8 mii_rxer ?mii receive error when this input signal and mii_rxdv are asserted, the phy is indicating that a media error has been detected during the transmission of the current frame. at all other times, mii_rxer is ignored. this signal transitions synchronously with mii_rxclk. 11.2.9 mii_crs ?mii carrier sense this input signal is asserted when the transmit or receive medium is in a non-idle state. when de-asserted, this signal indicates that the medium is in an idle state and a transmission can start. in the event of a collision, mii_crs remains asserted through the duration of the collision. in full-duplex mode, this signal is unde?ed. this signal is not required to transition synchronously with mii_txclk or mii_rxclk. 11.2.10 mii_col ?mii collision this input signal is asserted upon detection of a collision, and remains asserted through the duration of the collision. in full-duplex mode, this signal is unde?ed. this signal is not required to transition synchronously with mii_txclk or mii_rxclk. table 11-2. permissible encoding of mii_rxd, mii_rxdv, and mii_rxer mii_rxdv mii_rxer mii_rxd[3:0] indication 0 0 0000 through 1111 normal interframe 0 1 0000 normal interframe 0 1 0001 through 1101 reserved 0 1 1110 false carrier 0 1 1111 reserved 1 0 0000 through 1111 normal data reception 1 1 0000 through 1111 data reception with errors memory map and register descriptions mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 311 11.2.11 mii_mdc ?mii management data clock this output signal provides a timing reference to the phy for data transfers on the mii_mdio signal. mii_mdc is aperiodic and has no maximum high or low times. the maximum clock frequency is 2.5 mhz, regardless of the nominal period of mii_txclk and mii_rxclk. 11.2.12 mii_mdio ?mii management data input/output this bidirectional signal transfers control/status information between the phy and emac. control information is driven by the emac synchronously with respect to mii_mdc and is sampled synchronously by the phy. status information is driven by the phy synchronously with respect to mii_mdc and is sampled synchronously by the emac. 11.3 memory map and register descriptions this section provides a detailed description of all registers accessible in the emac. 11.3.1 module memory map table 11-3 gives an overview of all registers in the emac memory map. the emac occupies 48 bytes in the memory space. the register address results from the addition of base address and address offset. the base address is determined at the mcu level and is given in the device user guide. the address offset is de?ed at the module level and is provided in table 11-3 . table 11-3. emac module memory map address offset use access $__00 network control (netctl) r/w $__01 reserved $__02 $__03 receive control and status (rxcts) r/w $__04 transmit control and status (txcts) r/w $__05 ethertype control (etctl) r/w $__06 programmable ethertype (etype) r/w $__07 $__08 pause timer value and counter (ptime) r/w $__09 $__0a interrupt event (ievent) r/w $__0b $__0c interrupt mask (imask) r/w $__0d $__0e software reset (swrst) r/w $__0f reserved $__10 mii management phy address (mpadr) r/w $__11 mii management register address (mradr) r/w chapter 11 ethernet media access controller (emacv1) mc9s12ne64 data sheet, rev. 1.1 312 freescale semiconductor 11.3.2 register descriptions this section describes in detail all the registers and register bits in the emac module. each description includes a standard register diagram with an associated ?ure number. details of register bit and ?ld function follow the register diagrams, in bit order. $__12 mii management write data (mwdata) r/w $__13 $__14 mii management read data (mrdata) r $__15 $__16 mii management command and status (mcmst) r/w $__17 reserved $__18 ethernet buffer con?uration (bufcfg) r/w $__19 $__1a receive a end-of-frame pointer (rxaefp) r $__1b $__1c receive b end-of-frame pointer (rxbefp) r $__1d $__1e transmit end-of-frame pointer (txefp) r/w $__1f $__20 multicast hash table (mchash) r/w $__21 $__22 $__23 $__24 $__25 $__26 $__27 $__28 mac address (macad) r/w $__29 $__2a $__2b $__2c $__2d $__2e miscellaneous (emisc) r/w $__2f table 11-3. emac module memory map (continued) address offset use access memory map and register descriptions mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 313 11.3.2.1 network control (netctl) figure 11-2. network control (netctl) read: anytime. write: see each bit description. note when con?uring for loopback mode or for an external phy, the user must set the mlb or extphy bit before enabling the emac by setting emace. that is, when setting mlb or extphy, the initial write to this register should not also set the emace bit; separate writes must be performed. note when con?uring mlb and extphy bits, any internal or external phy connected should be disabled to protect against possible glitches generated on mii signals as port con?uration logic settles. emace ?emac enable this bit can be written anytime, but the user must not modify this bit while txact is set. while this bit is set, the emac is enabled, and reception and transmission are possible. when this bit is cleared, the emac receiver and transmitter are immediately disabled, any receive in progress is dropped, and any pause timeout is cleared. emace has no effect on the mii management functions. 1 = enables emac. 0 = disables emac. eswai ?emac disabled during wait mode this bit can be written anytime. when this bit is set, the emac receiver, transmitter, and mii management logic are disabled during wait mode, any receive in progress is dropped, and any pause timeout is cleared. the user must not enter wait mode with the eswai bit set if txact or busy are asserted. while the eswai bit is clear, the emac continues to operate during wait mode. 1 = emac is disabled during wait mode. 0 = emac continues to operate normally during wait mode. extphy ?external phy this bit can be written once after a hardware or software reset, but the user must not modify this bit while emace or busy is set. while this bit is set, the emac is configured for an external phy, all the emac mii i/o pins are available externally, and the mii to the internal phy is not available. module base + $0 7 6 5 4 3 2 1 0 r emace 0 0 eswai extphy mlb fdx 0 w reset: 0 0 0 0 0 0 0 0 = unimplemented or reserved chapter 11 ethernet media access controller (emacv1) mc9s12ne64 data sheet, rev. 1.1 314 freescale semiconductor while this bit is clear, the emac is configured for the internal phy, all the emac mii i/o pins are not available externally, and the mii interface to the internal phy is available. 1 = external phy. 0 = internal phy. note if mlb is set, extphy is ignored. if extphy is set, it is recommended that any internal phy be disabled. mlb ?mac loopback this bit can be written once after a hardware or software reset, but the user must not change this bit while emace or busy is set. while this bit is set, the emac is in the loopback mode which routes all transmit traffic to the receiver and disables the mii. 1 = loopback mode. 0 = normal operation. note while con?ured for loopback mode, receiver frame recognition algorithms remain active and transmitted frames failing to meet acceptance criteria will be dropped by the receiver. fdx ?full duplex this bit can be written anytime, but the user must not modify this bit while emace is set. while this bit is set, the emac is set for full-duplex mode, which bypasses the carrier sense multiple access with collision detect (csma/cd) protocol. frame reception occurs independently of frame transmission. while this bit is clear, the emac is set for half-duplex mode. frame reception is disabled during frame transmission. the mode used is the traditional mode of operation that relies on the csma/cd protocol to manage collisions and network access. 1 = full-duplex mode. 0 = half-duplex mode. 11.3.2.2 receive control and status (rxcts) figure 11-3. receive control and status (rxcts) read: anytime. write: see each bit description. module base + $3 7 6 5 4 3 2 1 0 r rxact 0 0 rfce 0 prom conmc bcrej w reset: 0 0 0 0 0 0 0 0 = unimplemented or reserved memory map and register descriptions mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 315 rxact ?receiver active status this is a read-only status bit that indicates activity in the emac receiver. rxact is asserted when mii_rxdv is asserted and clears when the emac has finished processing the receive frame after mii_rxdv is negated. 1 = receiver is active. 0 = receiver is idle. rfce ?reception flow control enable this bit can be written anytime, but the user must not change this bit while emace is set. while this bit is set, the receiver detects pause frames (full-duplex mode only). upon pause frame detection, the transmitter stops transmitting data frames for a given duration (pause time in received frame). the value of the pause timer counter is updated when a valid pause control frame is received. while this bit is clear, the receiver ignores any pause frames. 1 = upon pause frame detection, transmitter stops for a given duration. 0 = received pause control frames are ignored. prom ?promiscuous mode this bit can be written anytime, but the user must not change this bit while emace is set. changing values while the receiver is active may affect the outcome of the receive filters. while set, the address recognition filter is ignored and all frames are received regardless of destination address. while clear, the destination address is checked for incoming frames. 1 = all frames are received regardless of address. 0 = destination address is checked for incoming frames. conmc ?conditional multicast this bit can be written anytime, but the user must not change this bit while emace is set. changing values while the receiver is active may affect the outcome of the receive filters. while set, the multicast hash table is used to check all multicast addresses received unless the prom bit is set. while clear, all multicast address frames are accepted. 1 = multicast hash table is used for checking multicast addresses. 0 = multicast address frames are accepted. bcrej ?broadcast reject this bit can be written anytime, but the user must not change this bit while emace is set. while set, all broadcast addresses are rejected unless the prom bit is set. while clear, all broadcast address frames are accepted. 1 = all broadcast address frames are rejected. 0 = all broadcast address frames are accepted. chapter 11 ethernet media access controller (emacv1) mc9s12ne64 data sheet, rev. 1.1 316 freescale semiconductor 11.3.2.3 transmit control and status (txcts) figure 11-4. transmit control and status (txcts) read: anytime. write: see each bit description. txact ?transmitter active status this is a read-only status bit that indicates activity in the emac transmitter. txact is set after a valid tcmd write and is cleared when the emac has finished sending the transmit frame. 1 = transmitter is active. 0 = transmitter is idle. cslf ?carrier sense lost flag this status bit is set when the carrier sense (half-duplex mode) drops out or is never sensed during transmission (excluding the preamble) without collision. the frame is transmitted normally and no retries are performed as a result of this flag. this flag bit is cleared by writing a 1 to it. a write of 0 has no effect. 1 = carrier sense lost has been detected without collision during transmission. 0 = no carrier sense lost has been detected. ptrc ?pause timer register control this bit can be written anytime. while set, writes to the ptime register update the pause duration used in the transmission of a pause control frame. reads of the ptime register return the pause duration used in the transmission of a hardware-generated pause control frame. while clear, ptime register read accesses return the current number of slot times (512 bit times) remaining in a pause period after the receiver accepts a pause frame. writes to ptime are ignored. 1 = ptime controls the transmit pause duration parameter for pause control frames. 0 = ptime read accesses return the pause timer counter value. ssb ?single slot backoff this bit can be written anytime, but the user must not change this bit while txact is set. setting this bit forces the transmitter to backoff for only a single ethernet slot time instead of following the random backoff algorithm. for more information about the backoff algorithm, refer to section 11.4.3.3.3, ?ackoff generator. 1 = single slot backoff. 0 = random backoff. module base + $4 7 6 5 4 3 2 1 0 r txact 0 cslf ptrc ssb 0 0 0 w tcmd reset: 0 0 0 0 0 0 0 0 = unimplemented or reserved memory map and register descriptions mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 317 tcmd ?transmit command this is a 2-bit write-only field that can launch three different transmission commands: start, pause, or abort. the start command starts transmission of the frame in the transmit buffer. the pause command starts transmission of a hardware-generated pause frame. the abort command terminates any current transmission after a bad crc is appended to the frame currently being transmitted and mii_txer is asserted. the abort command does not affect any received pause time out. see table 11-4 , section 11.4.3, ?ransmitter , and section section 11.4.5.2, ?ardware generated pause control frame transmission , for more detail. note the start and pause commands are ignored if there is a transmission in progress (txact is set). after the reception of a pause frame, a launched start command is suspended until the pause time has expired. during the pause time, the emac may transmit a control pause frame if no start transmission is pending. 11.3.2.4 ethertype control (etctl) figure 11-5. ethertype control (etctl) read: anytime. write: anytime, but the user must not change this ?ld while emace is set. changing values while the receiver is active will affect the outcome of the ethertype ?ter. if every bit in etctl is clear, there is no mask for ethertype messages so all are received. conversely, if any bit in etctl is set, ethertype ?tering will occur and will be de?ed by the con?uration bits. fpet ?programmable ethertype if this bit is set, all messages with the ethertype in etype are accepted. if this bit is clear, messages of this type are ignored. 1 = accept ethertype messages selected in etype. 0 = ignore ethertype messages selected in etype. table 11-4. transmit commands tcmd command description 0 reserved ignore 1 start transmit buffer frame 2 pause transmit pause frame (full-duplex mode only) 3 abort abort transmission module base + $5 7 6 5 4 3 2 1 0 r fpet 0 0 femw fipv6 farp fipv4 fieee w reset: 0 0 0 0 0 0 0 0 = unimplemented or reserved chapter 11 ethernet media access controller (emacv1) mc9s12ne64 data sheet, rev. 1.1 318 freescale semiconductor femw ?emware ethertype if this bit is set, all messages with 0x8876 ethertype are accepted. if this bit is clear, messages of this type are ignored. 1 = accept emware messages. 0 = ignore emware messages. fipv6 ?internet protocol version 6 (ipv6) ethertype if this bit is set, all messages with 0x86dd ethertype are accepted. if this bit is clear, messages of this type are ignored. 1 = accept ipv6 messages. 0 = ignore ipv6 messages. farp ?address resolution protocol (arp) ethertype if this bit is set, all messages with 0x0806 ethertype are accepted. if this bit is clear, messages of this type are ignored. 1 = accept arp messages. 0 = ignore arp messages. fipv4 ?internet protocol version 4 (ipv4) ethertype if this bit is set, all messages with 0x0800 ethertype are accepted. if this bit is clear, messages of this type are ignored. 1 = accept ipv4 messages. 0 = ignore ipv4 messages. fieee ?ieee802.3 length field ethertype if this bit is set, all messages with 0x0000 to 0x05dc ethertype are accepted. if this bit is clear, messages of this type are ignored. 1 = accept length field messages. 0 = ignore length field messages. 11.3.2.5 programmable ethertype (etype) figure 11-6. programmable ethertype (etype) read: anytime. write: anytime, but the user must not change this ?ld while emace is set. changing values while the receiver is active may affect the outcome of the ethertype ?ter. etype ?programmable ethertype this 16-bit field is used to program an ethertype value to be used for the ethertype filter. module base + $6 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r etype w reset: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 memory map and register descriptions mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 319 11.3.2.6 pause timer value and counter (ptime) figure 11-7. pause timer value and counter (ptime) read: anytime. write: anytime except while ptrc is clear, but the user must not change this ?ld while txact is set. ptime ?pause timer value and counter while the ptrc bit is set, the ptime register controls the pause duration parameter in units of slot times (512 bit times) used in a transmission of a pause control frame. while ptrc bit is clear, the ptime register indicates the current number of slot times (512 bit times) remaining in a pause period after the receiver accepts a pause frame. the value of the pause timer counter is updated when a valid pause control frame is accepted, regardless of ptrc. 11.3.2.7 interrupt event (ievent) when an event occurs that sets a bit in the interrupt event register, an interrupt is generated if the corresponding bit in the interrupt mask registers is also set. each bit in the interrupt event register is cleared by writing a 1 to that bit position. a write of 0 has no effect. figure 11-8. interrupt event (ievent) read: anytime. write: anytime (0s have no effect). rfcif ?receive flow control interrupt flag this flag is set when a full-duplex flow control pause frame has been received. if not masked (rfcie is set), a receive flow control interrupt is pending while this flag is set. 1 = transmitter stopped due to reception of a pause frame. 0 = normal transmit operation. breif ?babbling receive error interrupt flag this flag is set when the receive frame length exceeds the value of maxfl. if not masked (breie is set), a babbling receive error interrupt is pending while this flag is set. 1 = a babbling receive error has been detected. 0 = no babbling receive errors have been detected. module base + $8 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r ptime w reset: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 module base + $a 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r rfcif 0 breif rxeif rxaoif rxboif rxacif rxbcif mmcif 0 lcif ecif 0 0 txcif 0 w reset: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = unimplemented or reserved chapter 11 ethernet media access controller (emacv1) mc9s12ne64 data sheet, rev. 1.1 320 freescale semiconductor rxeif ?receive error interrupt flag this flag is set when mii_rxer signal is asserted during reception, when there is a receive frame length mismatch, an alignment error, or when a crc error has occurred. if not masked (rxeie is set), a receive error interrupt is pending while this flag is set. 1 = receive errors have been detected. 0 = no receive errors have been detected. rxaoif ?receive buffer a overrun interrupt flag this flag is set when an overrun occurs in receive buffer a. if not masked (rxaoie is set), a receive buffer a overrun interrupt is pending while this flag is set. 1 = receive buffer a overrun has occurred. 0 = no receive buffer a overrun has been detected. rxboif ?receive buffer b overrun interrupt flag this flag is set when an overrun occurs in receive buffer b. if not masked (rxboie is set), a receive buffer b overrun interrupt is pending while this flag is set. 1 = receive buffer b overrun has occurred. 0 = no receive buffer b overrun has been detected. rxacif ?valid frame reception to receive buffer a complete interrupt flag this flag is set when a complete valid frame has been received in receive buffer a. if not masked (rxacie is set), a valid frame reception to receive buffer a complete interrupt is pending while this flag is set. 1 = frame to receive buffer a has been validated. 0 = frame to receive buffer a has not been validated. rxbcif ?valid frame reception to receive buffer b complete interrupt flag this flag is set when a complete valid frame has been received in receive buffer b. if not masked (rxbcie is set), a valid frame reception to receive buffer b complete interrupt is pending while this flag is set. 1 = frame to receive buffer b has been validated. 0 = frame to receive buffer b has not been validated. mmcif ?mii management transfer complete interrupt flag this flag is set when the mii has completed a requested mii management transfer. if not masked (mmcie is set), an mii management transfer complete interrupt is pending while this flag is set. 1 = mii management transfer completion. 0 = mii management transfer in progress or none requested. lcif ?late collision interrupt flag this flag is set if a collision has occurred after the collision window of 512 bit times while in half-duplex mode. if not masked (lcie is set), a late collision interrupt is pending while this flag is set. 1 = late collision during transmission. 0 = no collisions after collision window. memory map and register descriptions mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 321 ecif ?excessive collision interrupt flag this flag is set if the total number of collisions has exceeded the maximum retransmission count of 15 while in half-duplex mode. the frame is discarded and another start command must be invoked to commence a new transmission. if not masked (ecie is set), an excessive collision interrupt is pending while this flag is set. 1 = number of collisions exceeds 15. 0 = number of collisions is 15 or less. txcif ?frame transmission complete interrupt flag this flag is set when a transmit frame has been completed. if not masked (txcie is set), a frame transmission complete interrupt is pending while this flag is set. 1 = frame transmission has been completed. 0 = frame transmission has not been confirmed. 11.3.2.8 interrupt mask (imask) the interrupt mask register provides control over which possible interrupt events are allowed to generate an interrupt. if the corresponding bits in both ievent and imask registers are set, an interrupt is generated and remains active until a 1 is written to the ievent bit or a 0 is written to the imask bit. figure 11-9. interrupt mask (imask) read: anytime. write: anytime. rfcie ?receive flow control interrupt enable 1 = a receive flow control event causes a receive flow control interrupt request. 0 = no interrupt request is generated by this event. breie ?babbling receive error interrupt enable 1 = a babbling receive error event causes a babbling receive error interrupt request. 0 = no interrupt request is generated by this event. rxeie ?receive error interrupt enable 1 = a receive error event causes a receive error interrupt request. 0 = no interrupt request is generated by this event. rxaoie ?receive buffer a overrun interrupt enable 1 = a receive buffer a overrun event causes a receive buffer a overrun interrupt request. 0 = no interrupt request is generated by this event. rxboie ?receive buffer b overrun interrupt enable 1 = a receive buffer b overrun event causes a receive buffer b overrun interrupt request. module base + $c 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r rfcie 0 breie rxeie rxaoie rxboie rxacie rxbcie mmcie 0 lcie ecie 0 0 txcie 0 w reset: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = unimplemented or reserved chapter 11 ethernet media access controller (emacv1) mc9s12ne64 data sheet, rev. 1.1 322 freescale semiconductor 0 = no interrupt request is generated by this event. rxacie ?valid frame reception to receive buffer a complete interrupt enable 1 = a valid frame reception to receive buffer a complete event causes a valid frame reception to receive buffer a complete interrupt request. 0 = no interrupt request is generated by this event. rxbcie ?valid frame reception to receive buffer b complete interrupt enable 1 = a valid frame reception to receive buffer b complete event causes a valid frame reception to receive buffer b complete interrupt request. 0 = no interrupt request is generated by this event. mmcie ?mii management transfer complete interrupt enable 1 = an mii management transfer complete event causes an mii management transfer complete interrupt request. 0 = no interrupt request is generated by this event. lcie ?late collision interrupt enable 1 = a late collision event causes a late collision interrupt request. 0 = no interrupt request is generated by this event. ecie ?excessive collision interrupt enable 1 = an excessive collision event causes an excessive collision interrupt request. 0 = no interrupt request is generated by this event. txcie ?frame transmission complete interrupt enable 1 = a frame transmission complete event causes a frame transmission complete interrupt request. 0 = no interrupt request is generated by this event. 11.3.2.9 software reset (swrst) figure 11-10. software reset (swrst) read: anytime. write: anytime, but the user must not change this bit while busy is set. macrst ?mac software reset writing a 0 to this bit has no effect. this bit always reads 0. when this bit is set, the equivalent of a hardware reset is performed but it is local to the emac. the emac logic is initialized and all emac registers take their reset values. any transmission/reception currently in progress is abruptly aborted. 1 = emac is reset. 0 = normal operation. module base + $e 7 6 5 4 3 2 1 0 r 0 0 0 0 0 0 0 0 w macrst reset: 0 0 0 0 0 0 0 0 = unimplemented or reserved memory map and register descriptions mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 323 11.3.2.10 mii management phy address (mpadr) figure 11-11. mii management phy address (mpadr) read: anytime. write: anytime, but the user must not change this ?ld while busy is set. paddr ?mii management phy address this field specifies 1 of up to 32 attached phy devices. the default address for the internal phy after reset is 0, but can be changed by writing the phy address register. 11.3.2.11 mii management register address (mradr) figure 11-12. mii management register address (mradr) read: anytime. write: anytime, but the user must not change this ?ld while busy is set. raddr ?mii management register address this field selects 1 of the 32 mii registers of a phy device to be accessed. the default address for the internal phy after reset is 0, but can be changed by writing the phy address register. 11.3.2.12 mii management write data (mwdata) figure 11-13. mii management write data (mwdata) read: anytime. write: anytime, but the user must not change this ?ld while busy is set. module base + $10 7 6 5 4 3 2 1 0 r 0 0 0 paddr w reset: 0 0 0 0 0 0 0 0 = unimplemented or reserved module base + $11 7 6 5 4 3 2 1 0 r 0 0 0 raddr w reset: 0 0 0 0 0 0 0 0 = unimplemented or reserved module base + $12 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r wdata w reset: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 chapter 11 ethernet media access controller (emacv1) mc9s12ne64 data sheet, rev. 1.1 324 freescale semiconductor wdata ?mii management write data this data field contains the write data to be used when sourcing a write mii management frame. 11.3.2.13 mii management read data (mrdata) figure 11-14. mii management read data (mrdata) read: anytime. write: never. rdata ?mii management read data this data field contains the read data resulting from a read mii management frame. rdata is valid only when mmcif is set after a valid read frame operation. 11.3.2.14 mii management command and status (mcmst) figure 11-15. mii management command and status (mcmst) read: anytime. write: see each bit description. op ?operation code this field must be programmed to 10 to generate a valid read frame operation. see section 11.4.6.2, ?ead operation . this field must be programmed to 01 to generate a valid write frame operation. see section 11.4.6.3, ?rite operation . a programmed value of 00, 11, or any value programmed while busy is set is ignored. while programming mcmst, the op write is ignored if mdcsel is a 0 value. this field always reads 00. module base + $14 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r rdata w reset: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = unimplemented or reserved module base + $16 7 6 5 4 3 2 1 0 r 0 0 busy nopre mdcsel w op reset: 0 0 0 0 0 0 0 0 = unimplemented or reserved memory map and register descriptions mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 325 busy ?operation in progress this read-only status bit indicates mii management activity. busy is asserted after a valid op write and is cleared when the mmcif flag is set. 1 = mii is busy (operation in progress). 0 = mii is idle (ready for operation). nopre ?no preamble any value written while busy is set is ignored. the ieee 802.3 standard allows the preamble to be dropped if the attached phy does not require it. while this bit is set, a preamble is not prepended to the mii management frame. 1 = no preamble is sent. 0 = 32-bit preamble is sent. mdcsel ?management clock rate select any value programmed while busy bit is set is ignored. this field controls the frequency of the mii management data clock (mdc) relative to the ip bus clock. mdc toggles only during a valid mii management transaction. while mdc is not active, it remains low. any nonzero value results in an mdc frequency given by the following formula: mdc frequency = bus clock frequency / (2 * mdcsel) the mdcsel field must be programmed with a value to provide an mdc frequency of less-than or equal-to 2.5 mhz to be compliant with the ieee mii specification. the mdcsel must be set to a nonzero value in order to source a read or write mii management frame. table 11-5. mii management frame operation busy op operation 1 xx ignore 0 00 ignore 0 01 write 0 10 read 0 11 ignore table 11-6. programming examples for mdcsel ip bus clock frequency mdcsel mdc frequency 20 mhz 0x4 2.5 mhz 25 mhz 0x5 2.5 mhz 33 mhz 0x7 2.36 mhz 40 mhz 0x8 2.5 mhz 50 mhz 0xa 2.5 mhz chapter 11 ethernet media access controller (emacv1) mc9s12ne64 data sheet, rev. 1.1 326 freescale semiconductor 11.3.2.15 ethernet buffer con?uration (bufcfg) figure 11-16. ethernet buffer con?uration (bufcfg) read: anytime. write: see each ?ld description. bufmap ?buffer size and starting address mapping this 3-bit field can be written once after a hardware or software reset and only while emace is clear. any write to this field while emace is set is ignored. this field specifies the buffer size and the base address within system ram for the receive and transmit ethernet buffers. table 11-7 shows the mapping configuration for the system ram. the starting address of the system ram depends on its position within the on-chip system memory map. maxfl ?receive maximum frame length this 11-bit field can be written anytime, but the user must not change this field while emace is set. the 11-bit field specifies the maximum receive frame length in bytes. receive frames exceeding maxfl causes the breif event bit to set and an interrupt occurs if the breie is also set. written values equal-to or less-than 0x040 (64 decimal) use the minimum of 0x040. written values equal-to or greater-than 0x5ee (1518 decimal) use the maximum of 0x5ee. module base + $18 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r 0 bufmap 0 maxfl w reset: 0 1 0 0 0 1 0 1 1 1 1 0 1 1 1 0 = unimplemented or reserved table 11-7. buffer mapping con?uration on system ram bufmap system ram starting address rx buffer a size (bytes) rx buffer a address space rx buffer b size (bytes) rx buffer b address space tx buffer start address 0 0x0000 128 0x0000 - 0x007f 128 0x0080 - 0x00ff 0x0100 1 0x0000 256 0x0000 - 0x00ff 256 0x0100 - 0x01ff 0x0200 2 0x0000 512 0x0000 - 0x01ff 512 0x0200 - 0x03ff 0x0400 3 0x0000 1k 0x0000 - 0x03ff 1k 0x0400 - 0x07ff 0x0800 4 0x0000 1.5k 0x0000 - 0x05ff 1.5k 0x0600 - 0x0bff 0x0c00 5 ?7 reserved memory map and register descriptions mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 327 11.3.2.16 receive a end-of-frame pointer (rxaefp) figure 11-17. receive a end-of-frame pointer (rxaefp) read: anytime. write: never. the receive a end-of-frame pointer (rxaefp) 11-bit ?ld speci?s the address offset of the last byte was that written to the receive buffer a. the base address of receive buffer a is determined by bufmap. rxaefp is valid only while rxacif is set. 11.3.2.17 receive b end-of-frame pointer (rxbefp) figure 11-18. receive b end-of-frame pointer (rxbefp) read: anytime. write: never. the receive b end-of-frame pointer (rxbefp) 11-bit ?ld speci?s the address offset of the last byte that was written to the receive buffer b. the base address of receive buffer b is determined by bufmap. rxbefp is valid only while rxbcif is set. 11.3.2.18 transmit end-of-frame pointer (txefp) figure 11-19. transmit end-of-frame pointer (txefp) read: anytime. module base + $1a 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r 0 0 0 0 0 rxaefp w reset: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = unimplemented or reserved module base + $1c 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r 0 0 0 0 0 rxbefp w reset: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = unimplemented or reserved module base + $1e 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r 0 0 0 0 0 txefp w reset: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = unimplemented or reserved chapter 11 ethernet media access controller (emacv1) mc9s12ne64 data sheet, rev. 1.1 328 freescale semiconductor write: anytime, but the user must not change this ?ld while txact is set. the transmit end-of-frame pointer (txefp) 11-bit ?ld speci?s the address offset of the last frame byte that was stored in the transmit buffer. the base address of the transmit buffer is determined by bufmap. 11.3.2.19 multicast hash table (mchash) the multicast hash table (mchash) contains the 64-bit hash table used in the address recognition process for receive frames with a multicast address. section 11.4.2.1.4, ?ulticast filter , explains how to con?ure this register. read: anytime. write: anytime, but the user must not change this ?ld while emace is set. figure 11-20. multicast hash table (mchash) mchash ?multicast hash table index 11.3.2.20 mac unicast address (macad) the mac unicast address (macad) registers contain the 48-bit address used for identifying an exact match in the address recognition process by comparing the 48-bit address with the destination address ?ld of unicast receive frames. in addition, the 48-bit address is used in the 6-byte source address ?ld while transmitting pause frames. these registers are write-once after reset. the ethernet mac address must be a unique number for each device. ethernet mac addresses are assigned by the ieee standards association (ieee-sa). this address module base + $20 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r mchash[63:48] w reset: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 module base + $22 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r mchash[47:32] w reset: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 module base + $24 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r mchash[31:16] w reset: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 module base + $26 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r mchash[15:0] w reset: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 memory map and register descriptions mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 329 is normally stored in nonvolatile memory and copied to the mac address register during initialization by user software. read: anytime. write: once after a hardware or software reset, but the user must not change this ?ld while emace is set. figure 11-21. mac address (macad) macad ?mac unicast address 11.3.2.21 miscellaneous (emisc) the miscellaneous (emisc) register provides visibility of internal counters used by the emac. read: anytime. write: anytime for the index ?ld and never for the misc ?ld. figure 11-22. miscellaneous (emisc) index ?miscellaneous index this 3-bit field selects different counters to be read in the misc field. module base + $28 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r macad[47:32] w reset: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 module base + $2a 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r macad[31:16] w reset: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 module base + $2c 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r macad[15:0] w reset: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 module base + $2e 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 r index 0 0 misc w reset: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = unimplemented or reserved chapter 11 ethernet media access controller (emacv1) mc9s12ne64 data sheet, rev. 1.1 330 freescale semiconductor txbyt ?transmit frame byte counter this11-bit read-only field indicates the number of bytes of the current frame that have been read from the transmit buffer by the emac transmitter. this register does not include transmitted pad data that is added to frames if less than the minimum amount of data is transmitted nor the fcs data that is appended to the end of transmit frames. while sending pause frames with the pause command, this register is ignored. bslot ?backoff slot time counter this 10-bit read-only field indicates the number of slot times (512 bit times) in progress during the backoff delay. this counter clears at the end of backoff delay, which is set by the random algorithm. the misc[10] bit reads 0. retx ?retransmission counter this 4-bit read-only field indicates the current retransmission count if retransmission takes place due to collision. the misc[10:4] bits read 0. random ?backoff random number this10-bit read-only random number is generated for use by the backoff logic. the value returned when reading this field is random if the transmitter is enabled. the misc[10] bit reads 0. 11.4 functional description the emac provides a 10/100 mbps ethernet media access control (mac) function and is designed to connect to a phy device supporting mii. the emac is an 802.3 compliant ethernet controller speci?ally optimized for 8-/16-bit embedded processors. the main components of the emac are the receiver, transmitter, mac ?w control, mii management, and receive and transmit ethernet buffer interfaces. 11.4.1 ethernet frame in an ethernet network, information is received or transmitted in the form of a frame. the frame format used for ethernet consists of preamble (pa), start frame delimiter (sfd), destination address (da), source address (sa), type/length ?ld, data ?ld, and frame check sequence (fcs). see table 11-9 . table 11-8. miscellaneous fields index field unit 0-2 none read 0s 3 txbyt bytes 4 bslot slot time 5 retx retransmissions 6 random n/a 7 reserved reserved table 11-9. ethernet frame structure preamble start frame delimiter destination address source address type/ length data frame check sequence 7 bytes 1 bytes 6 bytes 6 bytes 2 bytes 46 to 1500 bytes 4 bytes functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 331 the frame length is de?ed to be 64 bytes at minimum and 1518 bytes at maximum, excluding the preamble and sfd. transmission and reception of each byte of data is performed one nibble at a time across the mii interface with the order of nibble as shown in figure 11-23 figure 11-23. mii nibble/byte-to-byte/nibble mapping 11.4.1.1 preamble and sfd the preamble is a 56-bit ?ld that consists of a ?ed pattern of alternating 1s and 0s. 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 the left-most 1 value represents the byte lsb and the right-most 0 value represents the byte msb. the sfd ?ld is the sequence 10101011 and immediately follows the preamble pattern. the preamble and sfd are used to allow the ethernet interfaces on the network to synchronize themselves with the incoming data stream before the data ?lds arrive. the emac does not require any preamble before the sfd byte. if a preamble is detected, the preamble must be a valid preamble pattern until the sfd or else the frame is dropped. 11.4.1.2 address fields each frame contains two address ?lds: the destination address ?ld and the source address ?ld, in that order. the destination address ?ld speci?s the network node(s) for which the frame is intended. the source address ?ld speci?s the network node that sent the frame. a 48-bit address is written as 12 hexadecimal digits with the digits paired in groups of two, representing a byte of information. the byte order of transmission on the network is from the most- to least-signi?ant byte. the transmission order within the byte, however, is starting from the least-signi?ant bit (lsb) of the byte through the most-signi?ant bit (msb). for example, an ethernet address that is written as the d0 d1 d2 d3 d4 d5 d6 d7 d0 d1 d2 d3 lsb msb first bit lsb first nibble second nibble msb mii nibble chapter 11 ethernet media access controller (emacv1) mc9s12ne64 data sheet, rev. 1.1 332 freescale semiconductor hexadecimal string f0-4e-77-8a-35-1d is equivalent to the following sequence of bits, sent over the network from left to right: 0000 1111 0111 0010 1110 1110 0101 0001 1010 1100 1011 1000 if the lsb of the most-signi?ant byte of the destination address ?ld is a 0, the address ?ld contains an individual (unicast) address. if the lsb is a 1, the address ?ld contains a group (multicast) address that identi?s none, one or more, or all network nodes connected. there is a special case of the multicast address known as the broadcast address, which is the 48-bit address of all 1s. 11.4.1.3 type/length field this 16-bit ?ld takes one of two meanings depending on its numeric value and is transmitted and received with the high order byte ?st. if the value in this ?ld is numerically equal-to or less-than the maximum data size in bytes of 1500 decimal (0x05dc hex), the ?ld is being used as a length ?ld. in this case, the value in the ?ld indicates the number of bytes contained in the subsequent data ?ld of the frame. when receiving this type frame, a compare of the value in the type/length ?ld is made to the actual number of bytes received in the data ?ld of the frame and an error is reported if there is not an exact match. if the value in this ?ld is numerically greater-than or equal-to 1536 decimal (0x0600 hex), the ?ld is being used as a type ?ld. in this case, the hexadecimal identi?r in the ?ld is used to indicate the type of protocol data being carried in the data ?ld of the frame. for example, the hexadecimal value of 0x0800 has been assigned as the identi?r for the internet protocol (ip). when receiving this type frame, no comparison of the value in the type/length ?ld is made to the actual number of bytes received in the data ?ld of the frame. if the value in this ?ld is between 1501 and 1535, this frame is invalid but is not automatically rejected. when receiving this type frame, no comparison of the value in the type/length ?ld is made to the actual number of bytes received in the data ?ld of the frame. when transmitting, if the length of the data ?ld is less than the minimum required for the data ?ld of the frame, bytes of pad data are automatically added at the end of the data ?ld but before the fcs ?ld to make the data ?ld meet the minimum length requirement. the content of pad data is all 0s. upon reception of a frame, the length ?ld stored in the receive buffer is used to determine the length of valid data in the data ?ld, and any pad data is discarded by software. 11.4.1.4 data field this ?ld must contain a minimum of 46 bytes of data, and may range up to a maximum of 1500 bytes of data. 11.4.1.5 frame check sequence this 32-bit ?ld contains the value that is used to check the integrity of the various bits in the frame ?lds excluding the preamble and sfd. this value is computed using the cyclic redundancy check (crc), which is a polynomial calculated using the contents of the destination address, source address, type/length, and data ?lds. functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 333 while the frame is being generated by the transmitting network node, the crc value is simultaneously being calculated. the 32 bits of the crc value are placed in the fcs ?ld while the frame is sent. the x 31 coef?ient of the crc polynomial is sent as the ?st bit of the ?ld and the x 0 coef?ient as the last bit. the crc is calculated again by the receiving network node while the frame is read in. the result of this second calculation is compared with the value sent in the fcs ?ld by the originating network node. if the two values are identical, the receiving network node is provided with a high level of assurance that no errors have occurred during transmission over the network. 11.4.1.6 end-of-frame delimiter the end-of-frame (eof) delimiter is indicated by the de-assertion of the mii_txen signal for data on mii_txd. this informs the phy to send a special eof symbol on the ethernet. for data on the mii_rxd signal, the de-assertion of mii_rxdv constitutes an end-of-frame delimiter. 11.4.1.7 interframe the interframe period provides an observation window for a speci?d amount of time during which no data activity occurs on the mii. the de-assertion of mii_rxdv on the receive path and the de-assertion of mii_txen in the transmit path indicate the absence of data activity. 11.4.2 receiver the emac receiver is designed to work with very little intervention from the cpu. when the emac is enabled, it immediately starts processing receive frames as long as one of the receive buffer complete interrupt ?gs is clear. if both rxacif and rxbcif are clear, receive buffer a is used ?st. if one ?g is set, reception occurs on the buffer with the cleared ?g. if both ?gs are set, no data is stored to the received buffers. when mii_rxdv asserts, the receiver ?st checks for a valid pa/sfd sequence. if the pa/sfd is valid, it is stripped and the frame is processed by the receiver. if a valid pa/sfd is not found, the frame is ignored. the receiver checks for at least one byte matching the sfd (10101011). zero or more pa bytes sent before the sfd byte are acceptable, but if an invalid pa is detected prior to the sfd byte, the frame is ignored. following the sfd, the emac converts the nibble stream to a byte data stream. see figure 11-23 . after the ?st six bytes of the frame have been received, the emac performs address recognition on the frame. see section 11.4.2.1, address recognition . if address recognition rejects the frame, the receiver goes idle, the receive buffer stops receiving data, and the receive end-of-frame pointer is invalid. if address recognition accepts the frame, the receive buffer continues to receive data. after the ?st 14 bytes of the frame have been received, the emac performs type/length recognition on the frame. see section 11.4.2.2, ?ype/length recognition . if type/length recognition rejects the frame, the receiver goes idle, the receive buffer stops receiving data, and the receive end-of-frame pointer is invalid. if type/length recognition accepts the frame, the receive buffer continues to receive data. chapter 11 ethernet media access controller (emacv1) mc9s12ne64 data sheet, rev. 1.1 334 freescale semiconductor if a receive frame length is less than 64 bytes, the receive frame is considered a fragment and is dropped. most fragments are the result of a collision, and as such are a completely normal and expected event on an ethernet. if a receive frame length exceeds 1518, the receive frame is considered too long and is an error. the rxeif bit becomes set and if not masked (rxeie set to 1), the emac generates the receive error interrupt. if mii_rxer is asserted during reception, indicating a media error, the rxeif bit becomes set and if not masked (rxeie set to 1), the emac generates the receive error interrupt. if the type/length ?ld is less-than or equal-to 1500 (but greater than 46), a length mismatch error occurs if the receive frame data ?ld length does not match the length speci?d in the type/length ?ld. if the type/length ?ld is less than or equal to 46, a length mismatch error occurs if the receive frame data ?ld length is not 46. if a length mismatch error occurs, the rxeif bit becomes set and if not masked (rxeie set to 1), the emac generates the receive error interrupt. the emac receiver automatically calculates a 4-byte frame check sequence from the receive frame and compares it with the crc data suf?ed to the receive frame. if a crc error occurs, the rxeif bit becomes set and if not masked (rxeie set to 1), the emac generates the receive error interrupt. after the end of frame delimiter, the received frame is truncated to the nearest byte boundary. if there is an extra nibble, this dribble nibble is discarded. if the crc value in the received frame is correct, the frame is accepted as valid. if the crc value is incorrect and there is a dribble nibble, an alignment error has occurred and the rxeif bit becomes set and if not masked (rxeie set to 1), the emac generates the receive error interrupt. frames that exceed the maxfl ?ld in byte length are not truncated. however, the breif bit becomes set and if not masked (breie set to 1), the emac generates the babbling receive error interrupt. if a receive frame exceeds the receive buffer size, the corresponding receive overrun error ?g is set. in the overrun error event, the frame is not accepted and neither the corresponding complete ?g nor the receive error ?g is set. a babbling receive error condition is ignored if it occurs after a buffer overrun event and thus breif does not become set. upon mac ow control pause frame reception, the rfcif bit in the ievent register is asserted. if not masked (rfcie is set), a receive ?w control interrupt is pending while this ?g is set. pause frames may be accepted even if both receive buffers are full. the frame is accepted and the rfcif ?g is set only if there no receive error. when frame reception to either receive buffer a or receive buffer b is complete, the corresponding receive buffer complete ?g is set, the value in the corresponding receive end-of-frame pointer is valid. if not masked (corresponding receive buffer complete interrupt enable is set to 1), the emac generates the corresponding receive buffer complete interrupt. the receiver buffer complete ?g is set only if there are no receive errors and the frame has not been accepted as a mac ?w control pause frame. if both receiver buffer complete ?gs are set, new receive frames are dropped until one of the complete ?gs is cleared. the receiver receives back-to-back frames with a minimum spacing of at least 96 bit times. if an interframe gap between receive frames is less than 96 bit times, the latter frame is not guaranteed to be accepted by the receiver. functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 335 11.4.2.1 address recognition the emac executes ?tering by using the destination address of a receive frame and eliminates a frame that does not satisfy a given condition. see figure 11-24 for the address recognition algorithm. 11.4.2.1.1 promiscuous mode if the prom bit is set, promiscuous mode is enabled and all frames are accepted regardless of address. the prom bit does not affect any other ?tering in the emac. 11.4.2.1.2 unicast filter unless the prom bit is set, the 48-bit mac address (macad) is compared for an exact match with the destination address of a receive frame with an individual address (group bit is 0). if the unicast address of the receive frame matches macad, the frame is accepted; otherwise, it is rejected. 11.4.2.1.3 broadcast filter a broadcast frame (48-bit address of all 1s) is accepted if the bcrej bit is 0 and rejected if the bcrej bit is 1 unless the prom bit is set. 11.4.2.1.4 multicast filter if the conmc bit is set to 0, all multicast frames are accepted. if the conmc bit is 1 and the prom bit is 0, only multicast frames with the hash table match are accepted. the hash table algorithm operates as follows. the 48-bit destination address is mapped into one of 64 bits, which are represented by the 64 bits stored in mchash. this mapping is performed by passing the 48-bit address through the 32-bit crc generator and selecting the 6 most signi?ant bits of the crc-encoded result to generate a number between 0 and 63. if the crc generator selects a bit that is set in the hash table, the frame is accepted; otherwise, it is rejected. to set the hash table, the crc of a multicast address must be calculated and the corresponding bit must be set in advance. 11.4.2.1.5 pause destination address if the emac is in full-duplex mode and the rfce bit is set, the receiver detects incoming pause frames. a pause frame has a 48-bit destination multicast address of 01-80-c2-00-00-01 or unique da. upon detection of a pause frame, the frame is temporarily accepted for further type/length recognition. chapter 11 ethernet media access controller (emacv1) mc9s12ne64 data sheet, rev. 1.1 336 freescale semiconductor figure 11-24. receive address recognition algorithm 11.4.2.2 type/length recognition the emac executes ?tering by using the type/length ?ld of a receive frame and rejects a frame that does not meet acceptance criteria. see figure 11-25 for the type/length recognition algorithm. tr u e tr u e group bit = 1 ? prom = 1 ? ? broadcast address bcrej = 1 ? hash search group table match ? receive address recognition tr u e false false reject frame false false tr u e false tr u e false tr u e ? pause or exact address rfce = 1 and full duplex ? conmc = 1 ? false exact match ? tr u e tr u e tr u e false pass to type/length algorithm pass to type/length algorithm false functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 337 figure 11-25. receive type/length recognition algorithm 11.4.2.2.1 ethertype filter while any of the etctl register bits are set, the ethertype ?ter is enabled to reject frames that are not standard ethernet protocols. in this case, the collection of set bits determines which ethertypes are accepted; all other ethertypes are rejected. if all bits of the etctl register are clear, ethertype ?tering is receive type/length recognition tr u e accept frame reject frame etctl = 0 ? fipv6 = 1 ? fipv4 = 1 ? farp = 1 ? fieee = 1 ? type = ? 0x86dd type = ? 0x0806 type = ? 0x0800 tr u e false false tr u e false false tr u e false false tr u e false false type = - 0x05dc? 0x0000 tr u e tr u e tr u e tr u e false accept as mac control frame false femw = 1 ? type = ? 0x8876 tr u e false false tr u e fpet = 1 ? type = ? etype tr u e false false tr u e false false tr u e ? pause or exact address rfce = 1 and full duplex ? tr u e = 0x0001 type mac control opcode ? = 0x8808 and tr u e chapter 11 ethernet media access controller (emacv1) mc9s12ne64 data sheet, rev. 1.1 338 freescale semiconductor not performed. if the fpet bit is set, frames with ethertype matching the value in the etype register are accepted. if the femw bit is set, frames with emware ethertype are accepted. if the fipv6 bit is set, frames with internet protocol version 6 ethertype are accepted. if the farp bit is set, frames with address resolution protocol ethertype are accepted. if the fipv4 bit is set, frames with internet protocol ethertype are accepted. if the fieee bit is set, frames with valid ieee 802.3 length ethertype are accepted. 11.4.2.2.2 pause mac control type if the emac is in full-duplex mode and the rfce bit is set, the receiver detects incoming pause frames. after a pause destination address has been detected, the type/length ?ld is checked looking for a type value of 0x8808. if the type/length ?ld does not contain this value, the frame is rejected; otherwise, the mac control function reads the frame looking for mac control operation codes carried in the data ?ld. for more information on the function of mac control, see section 11.4.5.1, ?ac flow control . 11.4.3 transmitter the transmit data, which the user must write to the transmit buffer, consists of the destination address followed by the source address, type/length ?ld, and the data ?ld. the emac transmitter automatically appends the preamble, sfd, and fcs necessary for a transmit frame. it also automatically appends pad data to extend the data length to the 46-byte minimum frame length. after a frame has been written to the transmit buffer and the corresponding transmit end-of-frame pointer has been initialized, the emac transmitter is ready to transmit on the network. when a start command is executed by writing to the tcmd ?ld, the emac transmit logic asserts mii_txen and starts transmitting the preamble sequence, the start frame delimiter, and then the frame information from the transmit buffer. the emac transmits bytes least signi?ant nibble ?st. in half-duplex operation, the emac transmitter defers transmission if the network is busy and data transmission is started after the interframe gap interval. in full-duplex mode, the carrier sense is ignored, and data transmission is started after the interframe gap interval. see section 11.4.3.1, ?nterframe gap , and section 11.4.3.2, ?eferring . if a collision occurs within the collision window of 64 bytes during transmission of the frame (half-duplex mode), the emac transmitter follows the speci?d backoff procedures and attempts to retransmit the frame until the retry limit threshold is reached. see section 11.4.3.3, ?ollision detection and backoff . if the carrier sense is lost during transmission and no collision is detected in the frame, the emac sets the cslf status bit. the frame is transmitted normally and no retries are performed as a result of a cslf error. after the transmit frame is complete, the txcif bits are set. if not masked (txcie set to 1), the emac generates the frame transmission complete interrupt. 11.4.3.1 interframe gap when the network becomes idle, a network node waits for a brief period called the interframe gap (ifg), and then transmits its frame. this is provided to allow a brief recovery time between frame reception for the ethernet interfaces. the minimum interframe gap time for back-to-back transmission is 96 bit times. functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 339 11.4.3.2 deferring in half-duplex mode, if there is a carrier (the network is busy), the network node continues to listen until the carrier ceases (network is idle). this is known as deferring to the passing traf?. as soon as the network becomes idle (which includes waiting for the interframe gap interval), the network node may begin transmitting a frame. the transmitter waits for the carrier sense to be negated for 60 bit times and then begins transmit after another 36 bit times. 11.4.3.3 collision detection and backoff the collision detection and backoff feature is a normal part of the operation of ethernet 802.3 mac protocol, and results in fast and automatic rescheduling of transmissions. this feature enables independent network nodes to compete for network access in a fair manner. it provides a way for network nodes to automatically adjust their behavior in response to the load of the network. 11.4.3.3.1 collision window the collision window period is set to 64 byte times (512 bit times) starting after the sfd. if a collision occurs within the collision window period, the retry process is initiated. if a late collision occurs (that is, a collision after the collision window period), no retransmission is performed, the lcif bit sets to 1, the transmit retry counter is cleared, and transmission is aborted. if not masked (lcie is set), the emac generates a late collision interrupt. due to latency associated with synchronizing the mii_col signal, assertions in the last three mii_txclk cycles of a normally completed transmission (during the fcs) are ignored and a collision event is not recognized. 11.4.3.3.2 jam period if a collision is detected anytime during transmission, the emac transmitter continues to transmit 32 bits of data (called the collision enforcement jam signal) so that other devices on the ethernet network, including the offending transmitter, can detect the collision. if the collision is detected very early in the frame transmission, the emac transmitter continues sending until it has completed the preamble of the frame, after which it sends the 32 bits of jam data. if the collision is detected during the fcs, up to and including the transfer of the last nibble of fcs data, the 32 bit jam is still sent. 11.4.3.3.3 backoff generator after a collision occurs within the collision window period, the delay time that the emac transmitter waits before attempting to retransmit the frame data is set at a multiple of the 512-bit ethernet slot time. the amount of total backoff delay is calculated by multiplying the slot time by a pseudo-randomly chosen integer. the backoff algorithm uses the following formula to determine the integer r , which is used to multiply the slot time and generate a backoff delay. 0r 2 k < chapter 11 ethernet media access controller (emacv1) mc9s12ne64 data sheet, rev. 1.1 340 freescale semiconductor the exponent k is assigned a value that is equal to either the number of transmission attempts or the number 10, whichever is less. the coef?ient r of the slot time is an integer randomly selected from a range of integers from 0 to one less than the value of two to the exponent k . table 11-10 shows the range of backoff times that may occur on a channel. the random ?ld in the emisc register contains the 10-bit random number generated by the random generator in the backoff logic. if the ssb bit is set, the transmitter backoff logic forces a single slot backoff time of 512 bit times instead of following the random backoff algorithm. 11.4.3.3.4 retry counter the emac transmitter has a retry counter, retx, that counts the number of collisions within the collision window period that occur while attempting to send a single frame. the retry counter increments by 1 after each collision and resets to 0 when each frame is successfully transmitted. retx is held at 0 when txact is clear. the emac transmitter attempts to retransmit up to 15 times. if a collision occurs when retx is 15, the excessive collision interrupt ?g (ecif) is set to 1, the entire transmit frame is discarded, and the retry counters resets to 0. if not masked (ecie set to 1), the emac generates the excessive collision interrupt. the txact bit in txcts will be asserted for the entire duration of the retry process. the next transmission can start as soon as txact is clear. 11.4.4 ethernet buffers there are two receive ethernet buffers and one transmit ethernet buffer allocated within the system ram. the size and starting address for each buffer is con?ured by the bufmap ?ld in the bufcfg register. see section 11.3.2.15, ?thernet buffer con?uration (bufcfg) . 11.4.4.1 receive ethernet buffer upon reception, the receive ethernet buffers store the destination address (da), the source address (sa), the type/length ?ld, the data ?ld, and the frame check sequence (fcs). if the receiver has data to put into a receive buffer and the receive buffers are full, the receive frame is dropped. if the length of the receive frame is larger than the receive buffer, the corresponding receive buffer overrun ?g bit is set to 1, and if table 11-10. backoff times collision on attempt number range of random numbers range of backoff times (10 mbps) range of backoff times (100 mbps) 1 0...1 0...51.2 s 0...5.1 s 2 0...3 0...153.6 s 0...15.4 s 3 0...7 0...358.4 s 0...35.8 s 4 0...15 0...768.0 s 0...76.8 s 5 0...31 0...1.59 ms 0...158.7 s 6 0...63 0...3.23 ms 0...322.6 s 7 0...127 0...6.50 ms 0...650.2 s 8 0...255 0...13.06 ms 0...1.31 ms 9 0...511 0...26.16 ms 0...2.62 ms 10-15 0...1023 0...52.38 ms 0...5.24 ms 16 n/a discard frame discard frame functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 341 not masked (corresponding receive buffer overrun interrupt enable bit is set to 1), the emac generates an overrun interrupt. in the receive buffer overrun event, buffer storage is halted and adjacent storage buffers are not corrupted. 11.4.4.2 transmit ethernet buffer only the destination address (da), the source address (sa), the type/length ?ld, and the data ?ld must be stored in the transmit ethernet buffer. the transmitter automatically appends the frame check sequence. it also automatically appends pad data to extend the data length to 46 bytes if the data length of the frame written to the transmit buffer is less than the minimum data length. the value of the transmit end-of-frame pointer must correspond to the last byte in the data ?ld byte, not including pad data. 11.4.5 full-duplex operation the ieee 802.3x standard de?es a second mode of operation, called full duplex , that bypasses the csma/cd (carrier sense multiple access/collision detect) protocol. the csma/cd protocol is half duplex, meaning two or more network nodes share a common transmission medium implying that a network node may either transmit data, or receive data, but never both at the same time. full-duplex mode allows exactly two network nodes to simultaneously exchange data over a point-to-point link that provides independent transmit and receive paths. because each network node can simultaneously transmit and receive data, the aggregate throughput of the link is effectively doubled. because there is no contention for a shared medium, collisions cannot occur and the csma/cd protocol is unnecessary. 11.4.5.1 mac flow control full-duplex mode includes an optional ?w control mechanism for real-time control and manipulation of the frame transmission and reception process. this mechanism allows a receiving node that is becoming congested to request the sending node to stop sending frames for a selected short period of time. this is performed through the use of a pause frame. if the congestion is relieved before the requested wait has expired, a second pause frame with a zero time-to-wait value can be sent to request resumption of transmission. mac control frames are identi?d by the exclusive assigned type value of 0x8808 (hex). they contain operational codes (opcodes) in the ?st two bytes of the data ?ld. the mac control opcode ?ld for a pause command is 0x0001 (hex). the next two bytes of the data ?ld are the mac control parameters field, which is a 16-bit value that specifies the duration of the pause event in units of 512 bit times. valid values are 0x0000 to 0xffff (hex). if an additional pause frame arrives before the current pause time has expired, its parameter replaces the current pause time, so a pause frame with parameter 0 allows traffic to resume immediately. a 42-byte reserved field (transmitted as all 0s) is required to pad the length of the pause frame to the minimum ethernet frame size. the destination address of the pause frame must be set to the globally assigned multicast address 01-80-c2-00-00-01 (hex) or to the unique da. this multicast address has been reserved by the ieee 802.3 standard for use in mac control pause frames. chapter 11 ethernet media access controller (emacv1) mc9s12ne64 data sheet, rev. 1.1 342 freescale semiconductor 11.4.5.2 hardware generated pause control frame transmission as long as there is no transmission in progress and emac is in full-duplex mode, a pause command can be launched by writing to the tcmd ?ld. the emac builds a pause frame according to table 11-11 using the parameter value in the ptime ?ld and then transmits this frame. the da ?ld is set to 01-80-c2-00-00-01 (hex). when the transmitted pause frame is complete, the txcif bit is set. if not masked (txcie set to 1) the emac generates the frame transmission complete interrupt. note to transmit a mac ?w control pause frame using a unique da, the user must construct a valid pause frame in the transmit buffer, con?ure the txefp register, and issue a start command. however, whenever issuing pause frames in this manner, the command is suspended while the received pause time counter value (ptime) is nonzero and is sent after the time has expired. 11.4.5.3 pause control frame reception while rfce bit is set, the receiver detects pause frames in full-duplex mode. upon pause frame detection, the rfcif bit in the ievent register is asserted and the emac transmitter stops transmitting data frames for a duration after the current transmission is complete. the duration is given by the pause time parameter in the received frame. if not masked (rfcie is set), a receive ?w control interrupt is pending while this ?g is set. although the reception of a pause frame stops transmission of frames initiated with a start command, it does not prevent transmission of pause control frames. pause frames may be accepted even if both receive buffers are full. 11.4.6 mii management mii management access to a phy is via the mii_mdc and mii_mdio signals. mii_mdc has a maximum clock rate of 2.5 mhz. mii_mdio is bidirectional and can be connected to 32 external devices or the internal phy. when using the internal phy, the mii_mdc and mii_mdio signals are not visible to the user. table 11-11. ethernet pause frame structure preamble sfd da sa type/length mac control opcode mac control parameters reserved fcs 7 bytes 1 byte 6 bytes = (01-80-c2-00-00-01) or unique da 6 bytes 2 bytes = mac control (88-08) 2 bytes = (00-01) 2 bytes = (00-00 to ff-ff) 42 bytes = all 0s 4 bytes functional description mc9s12ne64 data sheet, rev. 1.1 freescale semiconductor 343 11.4.6.1 frame structure a transmitted mii management frame uses the mii_mdio and mii_mdc pins. this frame has the following format:
|
Price & Availability of MC9S12NE64VTUE
![]() |
|
|
All Rights Reserved © IC-ON-LINE 2003 - 2022 |
[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy] |
Mirror Sites : [www.datasheet.hk]
[www.maxim4u.com] [www.ic-on-line.cn]
[www.ic-on-line.com] [www.ic-on-line.net]
[www.alldatasheet.com.cn]
[www.gdcy.com]
[www.gdcy.net] |