Part Number Hot Search : 
MC74LV AN2136SC HLB121I 33000 167BG ZMD100 UR810 BPC5010
Product Description
Full Text Search
 

To Download MC68HC11G5 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  MC68HC11G5 mc68hc11g7 mc68hc711g5 technical data
MC68HC11G5 mc68hc11g7 mc68hc711g5 high-density complementary metal oxide semiconductor (hcmos) microcontroller unit ? motorola ltd., 1991 motorola reserves the right to make changes without further notice to any products herein to improve reliability, function or d esign. motorola does not assume any liability arising out of the application or use of any product or circuit described herein; neithe r does it convey any license under its patent rights nor the rights of others. motorola products are not designed, intended, or author ized for use as components in systems intended for surgical implant into the body, or other applications intended to support or sust ain life, or for any other application in which the failure of the motorola product could create a situation where personal injury or death may occur. should buyer purchase or use motorola products for any such unintended or unauthorized application, buyer shall indemnify and hold motorola and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims , costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or dea th associated with such unintended or unauthorized use, even if such claim alleges that motorola was negligent regarding the desig n or manufacture of the part. motorola and are registered trademarks of motorola, inc. motorola, inc. is an equal opportunity/ affirmative action employer.
motorola i MC68HC11G5 table of contents (continued) paragraph page number title number table of contents paragraph page number title number section 1 introduction 1.1 general ........................................................................................................ 1-1 1.2 features of the motorola MC68HC11G5 mcu ............................................ 1-1 section 2 operating modes and signal description 2.1 operating modes ......................................................................................... 2-1 2.1.1 single chip operating mode .................................................................. 2-2 2.1.2 expanded non-multiplexed operating mode ......................................... 2-2 2.1.3 bootstrap operating mode ..................................................................... 2-2 2.1.4 test operating mode .............................................................................. 2-2 2.1.4.1 factory test register (test1) ......................................................... 2-4 2.2 signal description ........................................................................................ 2-5 2.2.1 input power (vdd) and ground (vss) ................................................... 2-5 2.2.2 reset (reset) ....................................................................................... 2-6 2.2.3 crystal driver (xtal) and external clock input (extal) ...................... 2-7 2.2.4 e-clock output (e) .................................................................................. 2-7 2.2.5 read/write (r/w) ................................................................................... 2-7 2.2.6 interrupt request (irq) .......................................................................... 2-7 2.2.7 non-maskable interrupt (xirq) .............................................................. 2-7 2.2.8 halt (halt) ............................................................................................ 2-7 2.2.9 mode a/load instruction register (moda/lir) and mode b/standby voltage (modb/vkam) ........................................................................... 2-8 2.2.10 a/d converter reference voltages (vrl, vrh) ......................................... 2-8 2.2.11 port signals ............................................................................................ 2-8
motorola ii MC68HC11G5 table of contents (continued) paragraph page number title number section 3 memory and control/status registers 3.1 rom ............................................................................................................. 3-1 3.2 bootstrap rom ............................................................................................ 3-1 3.3 ram ............................................................................................................. 3-1 3.4 memory map ................................................................................................ 3-2 3.4.1 single chip mode ................................................................................... 3-2 3.4.2 expanded non-multiplexed mode .......................................................... 3-3 3.4.3 special bootstrap mode ......................................................................... 3-4 3.4.4 special test mode .................................................................................. 3-4 3.4.5 changing modes .................................................................................... 3-4 3.5 system configuration ................................................................................... 3-4 3.5.1 ram and i/o mapping register (init) ................................................... 3-5 3.5.2 configuration control register (config) .............................................. 3-6 3.6 control/status registers .............................................................................. 3-6 section 4 input/output ports 4.1 mode dependencies .................................................................................... 4-1 4.2 general purpose i/o (ports a, c, d, g, h, and j) ....................................... 4-2 4.3 fixed direction i/o (ports b, e, and f) ........................................................ 4-2 4.4 port a ........................................................................................................... 4-2 4.4.1 data register (porta ) ......................................................................... 4-3 4.4.2 data direction register (ddra ) ............................................................ 4-3 4.5 port b ........................................................................................................... 4-4 4.5.1 data register (portb) .......................................................................... 4-4 4.6 port c ........................................................................................................... 4-4 4.6.1 data register (portc) ......................................................................... 4-5 4.6.2 data direction register (ddrc) ............................................................ 4-5 4.7 port d ........................................................................................................... 4-5 4.7.1 data register (portd) ......................................................................... 4-6 4.7.2 data direction register (ddrd) ............................................................ 4-6 4.8 port e ........................................................................................................... 4-7 4.8.1 data register (porte) .......................................................................... 4-7 4.9 port f ........................................................................................................... 4-8 4.9.1 data register (portf) .......................................................................... 4-8
motorola iii MC68HC11G5 table of contents (continued) paragraph page number title number 4.10 port g ........................................................................................................... 4-8 4.10.1 data register (portg) ......................................................................... 4-9 4.10.2 data direction register (ddrg) ............................................................ 4-9 4.11 port h ........................................................................................................... 4-9 4.11.1 data register (porth) ......................................................................... 4-10 4.11.2 data direction register (ddrh) ............................................................ 4-10 4.12 port j ............................................................................................................ 4-11 4.12.1 data register (portj) ......................................................................... 4-11 4.12.2 data direction register (ddrj) ............................................................ 4-11 4.13 expanded bus (ports b, c, f) ...................................................................... 4-12 4.13.1 r/w ........................................................................................................ 4-12 4.13.2 memory ready (mrdy) ......................................................................... 4-13 4.13.3 options register 2 (opt2) ..................................................................... 4-13 section 5 resets, interrupts and low power modes 5.1 resets .......................................................................................................... 5-1 5.1.1 reset pin ............................................................................................. 5-1 5.1.2 power-on-reset (por) ............................................................................ 5-1 5.1.3 computer operating properly (cop) reset ........................................... 5-2 5.1.4 clock monitor reset ............................................................................... 5-2 5.1.5 configuration options register (option) ............................................. 5-3 5.1.6 state after reset .................................................................................... 5-4 5.2 interrupts ...................................................................................................... 5-6 5.2.1 interrupt vector assignments ................................................................. 5-6 5.2.2 software interrupt (swi) ......................................................................... 5-8 5.2.3 illegal opcode trap ................................................................................ 5-8 5.2.4 real time interrupt ................................................................................. 5-8 5.2.5 interrupt mask bits in condition code register ..................................... 5-9 5.2.6 priority and masking structure ............................................................... 5-9 5.2.7 highest priority i interrupt and miscellaneous register (hprio) ........ 5-15 5.3 low power modes ....................................................................................... 5-17 5.3.1 wait ...................................................................................................... 5-17 5.3.2 stop ...................................................................................................... 5-17
motorola iv MC68HC11G5 table of contents (continued) paragraph page number title number section 6 programmable timer, real time interrupt and pulse accumulator 6.1 programmable timer ................................................................................... 6-1 6.1.1 counters ................................................................................................. 6-1 6.1.2 prescalers .............................................................................................. 6-2 6.1.3 input capture functions ......................................................................... 6-2 6.1.4 output compare functions .................................................................... 6-2 6.1.5 programmable input capture/output compares .................................... 6-3 6.2 real time interrupt ...................................................................................... 6-4 6.3 pulse accumulator ....................................................................................... 6-4 6.4 timer, rti and pulse accumulator registers .............................................. 6-5 6.4.1 count registers (tcnt1 and tcnt2) ................................................... 6-5 6.4.2 prescaler register (tpre) ..................................................................... 6-6 6.4.3 input capture registers (tic1 C tic3) .................................................. 6-7 6.4.4 output compare registers (toc1 C toc4) .......................................... 6-8 6.4.5 output compare 5/input capture 4 register (to5i4) ............................ 6-9 6.4.6 output compare 6/input capture 5 register (to6i5) ............................ 6-9 6.4.7 output compare 7/input capture 6 register (to7i6) ............................ 6-10 6.4.8 output compare 1 action mask register (oc1m) ................................. 6-10 6.4.9 output compare 1 action data register (oc1d) .................................. 6-11 6.4.10 compare force register (cforc) ........................................................ 6-11 6.4.11 control register 1 (tctl1) .................................................................... 6-12 6.4.12 timer control register 2 (tctl2) .......................................................... 6-12 6.4.13 timer control register 3 (tctl3) .......................................................... 6-13 6.4.14 control register 4 (tctl4) .................................................................... 6-14 6.4.15 main timer interrupt mask register 1 (tmsk1) ..................................... 6-15 6.4.16 main timer interrupt flag register 1 (tflg1) ....................................... 6-15 6.4.17 miscellaneous timer interrupt mask register 2 (tmsk2) ...................... 6-16 6.4.18 miscellaneous timer interrupt flag register 2 (tflg2) ........................ 6-17 6.4.19 count register (pacnt) ........................................................................ 6-18 6.4.20 pulse accumulator control register (pactl) ....................................... 6-19
motorola v MC68HC11G5 table of contents (continued) paragraph page number title number section 7 serial communications interface 7.1 overview and features ................................................................................ 7-1 7.1.1 sci two-wire system features: ............................................................. 7-1 7.1.2 sci receiver features ........................................................................... 7-1 7.1.3 sci transmitter features ....................................................................... 7-2 7.2 functional description ................................................................................. 7-2 7.3 data format ................................................................................................. 7-4 7.4 receiver wake-up operation ....................................................................... 7-4 7.4.1 idle line wake-up .................................................................................. 7-5 7.4.2 address mark wake-up .......................................................................... 7-5 7.5 receive data (rxd) ..................................................................................... 7-5 7.6 start bit detection ........................................................................................ 7-6 7.7 transmit data (txd) .................................................................................... 7-8 7.8 sci registers ............................................................................................... 7-8 7.8.1 serial communications data register (scdat) .................................... 7-8 7.8.2 serial communications control register 1 (sccr1) ............................. 7-8 7.8.3 serial communications control register 2 (sccr2) ............................. 7-9 7.8.4 serial communications status register (scsr) ................................... 7-11 7.8.5 baud rate register (baud) ................................................................... 7-12 section 8 serial peripheral interface 8.1 overview and features ................................................................................ 8-1 8.2 spi signal descriptions ............................................................................... 8-1 8.2.1 master in slave out (miso) ................................................................... 8-2 8.2.2 master out slave in (mosi) ................................................................... 8-2 8.2.3 serial clock (sck) ................................................................................. 8-2 8.2.4 slave select (ss) ................................................................................... 8-3 8.3 functional description ................................................................................. 8-4 8.4 spi registers ............................................................................................... 8-5 8.4.1 control register (spcr) ........................................................................ 8-5 8.4.2 status register (spsr) .......................................................................... 8-7 8.4.3 data i/o register (spdat) .................................................................... 8-8
motorola vi MC68HC11G5 table of contents (continued) paragraph page number title number section 9 analog-to-digital converter 9.1 conversion process ..................................................................................... 9-2 9.2 channel assignments .................................................................................. 9-2 9.3 single channel operation ............................................................................ 9-3 9.3.1 4-conversion, single scan ..................................................................... 9-3 9.3.2 4-conversion, continuous scan ............................................................. 9-3 9.3.3 8-conversion, single scan ..................................................................... 9-4 9.3.4 8-conversion, continuous scan ............................................................. 9-4 9.4 multiple channel operation ......................................................................... 9-4 9.4.1 4-channel single scan ........................................................................... 9-4 9.4.2 4-channel continuous scan .................................................................. 9-4 9.4.3 8-channel single scan ........................................................................... 9-4 9.4.4 8-channel continuous scan .................................................................. 9-5 9.5 power-up and clock select .......................................................................... 9-5 9.6 operation in stop and wait modes .......................................................... 9-5 9.7 registers ...................................................................................................... 9-6 9.7.1 a/d control and status register (adctl) ............................................. 9-6 9.7.2 result registers (adr1 C adr8) .......................................................... 9-7 section 10 pulse width modulation timer 10.1 general overview ........................................................................................ 10-1 10.2 clock selection ............................................................................................ 10-3 10.3 16-bit pwm function ................................................................................... 10-3 10.4 boundary cases .......................................................................................... 10-4 10.5 pwm registers ............................................................................................ 10-4 10.5.1 counter registers (pwcntx) ................................................................ 10-4 10.5.2 period registers (pwperx) .................................................................. 10-5 10.5.3 duty registers (pwdtyx) ...................................................................... 10-5 10.5.4 clock select register (pwclk) ............................................................. 10-6 10.5.5 polarity select register (pwpol) .......................................................... 10-8 10.5.6 scale register (pwscal) ..................................................................... 10-9 10.5.7 enable register (pwen) ........................................................................ 10-10
motorola vii MC68HC11G5 table of contents (continued) paragraph page number title number section 11 event counter 11.1 introduction .................................................................................................. 11-1 11.2 mode 0: 8-bit pwm with selectable phase shift .......................................... 11-3 11.2.1 operation of pwm and pa unit in mode 0 ............................................. 11-3 11.2.2 register functions in mode 0 ................................................................. 11-4 11.2.2.1 counter 1 (evcnt1) ........................................................................ 11-4 11.2.2.2 compare register 1a (ecmp1a); (y) .............................................. 11-4 11.2.2.3 compare register 1b (ecmp1b); (x) ............................................. 11-4 11.2.2.4 counter 2 (evcnt2) ........................................................................ 11-5 11.2.2.5 compare register 2a (ecmp2a); (x) .............................................. 11-5 11.2.2.6 compare register 2b (ecmp2b) ..................................................... 11-5 11.2.2.7 input unit 1 (evi1) ............................................................................ 11-5 11.2.2.8 input unit 2 (evi2) ............................................................................ 11-5 11.2.2.9 output unit (evo) ............................................................................. 11-5 11.3 mode 1: 8-bit pwm and pulse accumulator ................................................ 11-6 11.3.1 operation of pulse width modulation unit in mode 1 ............................. 11-7 11.3.2 operation of pulse accumulator unit in mode 1 .................................... 11-7 11.3.3 register functions in mode 1 ................................................................. 11-7 11.3.3.1 counter 1 (evcnt1) ........................................................................ 11-7 11.3.3.2 compare register 1a (ecmp1a) ..................................................... 11-8 11.3.3.3 compare register 1b (ecmp1b) ..................................................... 11-8 11.3.3.4 counter 2 (evcnt2) ........................................................................ 11-8 11.3.3.5 compare register 2a (ecmp2a) ..................................................... 11-8 11.3.3.6 compare register 2b (ecmp2b) ..................................................... 11-8 11.3.3.7 input unit 1 (evi1) ............................................................................ 11-8 11.3.3.8 input unit 2 (evi2) ............................................................................ 11-8 11.3.3.9 output unit (evo) ............................................................................. 11-9 11.4 mode 2: 8-bit pwm with period counter ...................................................... 11-9 11.4.1 operation of pulse width modulation unit in mode 2 ............................. 11-10 11.4.2 operation of pulse accumulator unit in mode 2 .................................... 11-10 11.4.3 register functions in mode 2 ................................................................. 11-10 11.4.3.1 counter 1 (evcnt1) ........................................................................ 11-10 11.4.3.2 compare register 1a (ecmp1a) ..................................................... 11-11 11.4.3.3 compare register 1b (ecmp1b) ..................................................... 11-11 11.4.3.4 counter 2 (evcnt2) ........................................................................ 11-11 11.4.3.5 compare register 2a (ecmp2a) ..................................................... 11-11 11.4.3.6 compare register 2b (ecmp2b) ..................................................... 11-11 11.4.3.7 input unit 1 (evi1) ............................................................................ 11-11 11.4.3.8 input unit 2 (evi2) ............................................................................ 11-11 11.4.3.9 output unit (evo) ............................................................................. 11-11
motorola viii MC68HC11G5 table of contents (continued) paragraph page number title number 11.5 mode 3: 8-bit pwm with 256 clock prescaler .............................................. 11-12 11.5.1 operation of pulse width modulation unit in mode 3 ............................. 11-12 11.5.2 operation of pulse accumulator unit in mode 3 .................................... 11-13 11.5.3 register functions in mode 3 ................................................................. 11-14 11.5.3.1 counter 1 (evcnt1) ........................................................................ 11-14 11.5.3.2 compare register 1a (ecmp1a) ..................................................... 11-14 11.5.3.3 compare register 1b (ecmp1b) ..................................................... 11-14 11.5.3.4 counter 2 (evcnt2) ........................................................................ 11-14 11.5.3.5 compare register 2a (ecmp2a) ..................................................... 11-14 11.5.3.6 compare register 2b (ecmp2b) ..................................................... 11-14 11.5.3.7 input unit 1 (evi1) ............................................................................ 11-14 11.5.3.8 input unit 2 (evi2) ............................................................................ 11-15 11.5.3.9 output unit (evo) ............................................................................. 11-15 11.6 event counter registers .............................................................................. 11-15 11.6.1 counter clock register (evclk) ........................................................... 11-15 11.6.2 counter control register (evctl) ......................................................... 11-16 11.6.3 counters enable/interrupt mask register (evmsk) .............................. 11-17 11.6.4 interrupt flag register (evflg) ............................................................ 11-18 11.6.5 counter registers (evcntx) ................................................................. 11-18 11.6.6 counter compare registers (ecmpx) ................................................... 11-19 11.7 pwm using the event counter ..................................................................... 11-19 11.8 effective range of the set up values .......................................................... 11-19 11.9 boundary conditions of the pwm function ................................................. 11-20 section 12 cpu, addressing modes and instruction set 12.1 programming model and cpu registers ..................................................... 12-1 12.1.1 accumulators a and b ............................................................................ 12-2 12.1.2 index register x (ix) .............................................................................. 12-2 12.1.3 index register y (iy) .............................................................................. 12-2 12.1.4 stack pointer (sp) .................................................................................. 12-2 12.1.5 program counter (pc) ........................................................................... 12-2 12.1.6 condition code register (ccr) ............................................................. 12-2 12.2 addressing modes ....................................................................................... 12-3 12.2.1 immediate addressing (imm) ................................................................. 12-3 12.2.2 direct addressing (dir) ......................................................................... 12-3 12.2.3 extended addressing (ext) ................................................................... 12-4 12.2.4 indexed addressing (ind, x; ind, y) ..................................................... 12-4 12.2.5 inherent addressing (inh) ...................................................................... 12-4 12.2.6 relative addressing (rel) ..................................................................... 12-4
motorola ix MC68HC11G5 table of contents (continued) paragraph page number title number 12.3 instruction set .............................................................................................. 12-4 12.3.1 accumulator and memory instructions ................................................... 12-5 12.3.1.1 loads, stores and transfers ............................................................ 12-5 12.3.1.2 arithmetic operations ....................................................................... 12-6 12.3.1.3 multiply and divide ............................................................................ 12-7 12.3.1.4 logical operations ............................................................................ 12-7 12.3.1.5 data testing and bit manipulation .................................................... 12-8 12.3.1.6 shifts and rotates ............................................................................ 12-9 12.3.2 stack and index register instructions .................................................... 12-10 12.3.3 condition code register instructions ..................................................... 12-11 12.3.4 program control instructions .................................................................. 12-12 12.3.4.1 branches ........................................................................................... 12-12 12.3.4.2 jumps ............................................................................................... 12-14 12.3.4.3 subroutine calls and returns (bsr, jsr, rts) .............................. 12-14 12.3.4.4 interrupt handling (rti, swi, wai) .................................................. 12-14 12.3.4.5 miscellaneous (nop, stop, test) ................................................. 12-15 section 13 electrical specifications 13.1 maximum ratings ........................................................................................ 13-1 13.2 thermal characteristics ............................................................................... 13-1 13.3 power considerations .................................................................................. 13-2 13.4 dc electrical characteristics ........................................................................ 13-3 13.5 control timing .............................................................................................. 13-7 13.6 peripheral port characteristics .................................................................... 13-12 13.7 timer characteristics ................................................................................... 13-14 13.8 a/d converter characteristics ..................................................................... 13-16 13.9 expansion bus timing ................................................................................. 13-17 13.10 serial peripheral interface (spi) timing ...................................................... 13-19 13.11 event counter characteristics ..................................................................... 13-22 section 14 mechanical data 14.1 ordering information .................................................................................... 14-1 14.2 pin assignments .......................................................................................... 14-2 14.3 package dimensions ................................................................................... 14-3
motorola x MC68HC11G5 table of contents (continued) paragraph page number title number appendix a mc68hc11g7 high-performance mcu with 24 kbyte rom appendix b mc68hc711g5 high-performance mcu with 16 kbyte eprom table of contents (concluded) paragraph page number title number
list of tables (continued) paragraph page number title number motorola xi MC68HC11G5 list of illustrations page number title number 1-1 functional block diagram ............................................................................ 1-2 2-1 oscillator circuits: (a) external oscillator connections .................................. 2-6 2-1 oscillator circuits: (b) one crystal driving two mcus ................................... 2-6 2-1 oscillator circuits: (c) common crystal connections .................................... 2-6 3-1 memory map ................................................................................................ 3-3 3-2 control and status registers (page 1) ........................................................ 3-7 3-2 control and status registers (page 2) ........................................................ 3-8 3-2 control and status registers (page 3) ........................................................ 3-9 3-2 control and status registers (page 4) ........................................................ 3-10 5-1 interrupt stacking order ............................................................................... 5-8 5-2 processing flow out of resets .................................................................... 5-10 5-2 processing flow out of resets (contd) ........................................................ 5-11 5-3 interrupt priority resolution ......................................................................... 5-12 5-3 interrupt priority resolution (contd) ............................................................. 5-13 5-4 interrupt source resolution within sci ........................................................ 5-14 7-1 serial communications interface block diagram ......................................... 7-3 7-2 rate generator division ............................................................................... 7-4 7-3 data format ................................................................................................. 7-4 7-4 sampling technique used on all bits ......................................................... 7-6 7-5 examples of start bit sampling techniques ................................................ 7-7 7-6 sci artificial start following a framing error .............................................. 7-8 7-7 sci start bit following a break .................................................................... 7-8 8-1 data clock timing diagram ......................................................................... 8-2 8-2 serial peripheral interface block diagram ................................................... 8-4 8-3 serial peripheral interface master-slave interconnection ............................ 8-5 10-1 pwm timer module block diagram ............................................................. 10-2 11-1 event counter operating modes ................................................................. 11-2 11-2 8-bit pwm with selectable phase shift (mode 0) ........................................ 11-3 11-3 8-bit pwm and pulse accumulator (mode 1) ............................................... 11-6 11-4 8-bit pwm with period counter (mode 2) .................................................... 11-9 11-5 8-bit pwm with 256 clock prescaler (mode 3) ............................................ 11-13 12-1 programming model ..................................................................................... 12-2
motorola xii MC68HC11G5 13-1 test methods ............................................................................................... 13-4 13-2 run idd vs bus frequency (single chip mode C 4.5v, 5.5v) ..................... 13-5 13-3 run idd vs bus frequency (expanded mode C 4.5v, 5.5v) ....................... 13-5 13-4 wait idd vs bus frequency (single chip mode C 4.5v, 5.5v) .................... 13-6 13-5 wait idd vs bus frequency (expanded mode C 4.5v, 5.5v) ...................... 13-6 13-6 por external reset timing diagram ........................................................ 13-8 13-7 stop recovery timing diagram ................................................................. 13-8 13-8 wait recovery from interrupt timing diagram ........................................... 13-9 13-9 interrupt timing diagram ............................................................................. 13-9 13-10 memory ready timing diagram .................................................................. 13-10 13-11 entering halt ............................................................................................. 13-10 13-12 exiting halt ................................................................................................ 13-11 13-13 port write timing diagram ........................................................................... 13-12 13-14 port read timing diagram .......................................................................... 13-13 13-15 timer inputs timing diagram ....................................................................... 13-14 13-16 output compare timing diagram ................................................................ 13-15 13-17 input capture timing diagram ..................................................................... 13-15 13-18 non-multiplexed expanded bus ................................................................... 13-18 13-19 spi master timing (cpha = 0) .................................................................... 13-20 13-20 spi master timing (cpha = 1) .................................................................... 13-20 13-21 spi slave timing (cpha = 0) ...................................................................... 13-21 13-22 spi slave timing (cpha = 1) ...................................................................... 13-21 13-23 event counter mode 1, 2, 3 C clock input timing diagram ......................... 13-22 13-24 event counter mode 1, 2, 3 C clock gate input timing diagram ................ 13-23 a-1 mc68hc11g7 functional block diagram ................................................... a-1 a-2 mc68hc11g7 memory map ....................................................................... a-2 b-1 mc68hc711g5 functional block diagram ................................................. b-1 b-2 mc68hc711g5 memory map ..................................................................... b-2 b-3 block diagram of mc68hc711g5 in prog mode ...................................... b-3 list of illustrations (concluded) paragraph page number title number
list of tables (continued) paragraph page number title number motorola xiii MC68HC11G5 2-1 mode select summary ................................................................................. 2-1 2-2 bootstrap mode jump vectors ..................................................................... 2-3 2-3 port signal functions: (a) expanded non-multiplexed and test modes ..... 2-9 2-3 port signal functions: (b) single chip and bootstrap modes ...................... 2-9 5-1 cop timeout periods .................................................................................. 5-2 5-2 interrupt vector masks and assignments .................................................... 5-7 5-3 special mode select and mode select a table ........................................... 5-15 5-4 priority select bits table .............................................................................. 5-16 6-1 real time interrupt rates ............................................................................ 6-20 7-1 first prescaler stage ................................................................................... 7-14 7-2 second prescaler stage .............................................................................. 7-14 8-1 spi rate selection ....................................................................................... 8-7 9-1 channel assignments .................................................................................. 9-2 9-1 channel assignments (continued) ............................................................... 9-3 12-1 loads, stores and transfers ........................................................................ 12-5 12-2 arithmetic operations .................................................................................. 12-6 12-3 multiply and divide ....................................................................................... 12-7 12-4 logical operations ....................................................................................... 12-7 12-5 data testing and bit manipulation ............................................................... 12-8 12-6 shifts and rotates ........................................................................................ 12-9 12-7 stack and index register instructions ......................................................... 12-10 12-8 condition code register instructions .......................................................... 12-11 12-9 branches ...................................................................................................... 12-13 12-10 jumps ........................................................................................................... 12-14 12-11 subroutine calls and returns (bsr, jsr, rts) ......................................... 12-14 12-12 interrupt handling (rti, swi, wai) .............................................................. 12-14 13.1 clock input (required limit) ........................................................................ 13-22 13.2 clock input (guaranteed limit) .................................................................... 13-22 13.3 clock gate input (guaranteed limit) ........................................................... 13-23 b-1 operations in prog mode .......................................................................... b-4 list of tables page number title number
motorola xiv MC68HC11G5 this page intentionally left blank
MC68HC11G5 introduction motorola 1-1 section 1 introduction 1.1 general the MC68HC11G5, which includes 16 kilobytes of on-board rom, is a member of the m68hc11 family of advanced capability mcus. this device has 512 bytes of on-board static ram and a non- multiplexed expanded bus for accessing external memory. the original mc68hc11 timer system is expanded to contain 3 input capture ports, 4 output compare ports and 3 software selectable input capture or output compare ports. a new 4-channel pulse width modulation timer has been added and there is also an event counter timer system. the serial i/o system consists of an asynchronous nrz serial communications interface (sci) plus a synchronous serial peripheral interface (spi). the a/d converter is enhanced to 10 bits. the MC68HC11G5 also includes a real time interrupt circuit and a computer operating properly (cop) watchdog system, as on the original mc68hc11a8. the mc68hc11g7, which is similar to the MC68HC11G5 but with 24 kilobytes of rom instead of 16 kilobytes, is described in appendix a. the mc68hc711g5, again similar to the MC68HC11G5 but with 16 kilobytes of eprom instead of rom, is described in appendix b. this section outlines the general characteristics and special features of the MC68HC11G5 high- density complementary metal oxide semiconductor (hcmos) microcontroller unit (mcu). 1.2 features of the motorola MC68HC11G5 mcu ? low-power/high-performance m68hc11 cpu core ? 16 kilobytes of rom ? 256 bytes of bootstrap rom ? 512 bytes of static ram ? ram, registers and i/o mappable to any 4k boundary
motorola introduction MC68HC11G5 1-2 ? expanded non-multiplexed data/address buses give access to a total address space of 64 kilobytes ? maximum of seven 8-bit, one 6-bit and one 4-bit i/o ports ? 2 separate 16-bit timers, each with its own e-clock divider circuitry ? external clock option on timer 2 ? 4 output compare (oc), 3 input capture (ic) and 3 selectable oc/ic channels ? 4 pwm timers, each with its own counter and programmable period and duty cycle ? dual event counter featuring phase-shifter, pulse accumulator, periodic timer and 256 clock divider ? 8-channel, 10-bit a/d converter with 1, 4 and 8-channel scanning modes ? cop watchdog timer and clock monitor ? serial i/o system incorporating asynchronous nrz and synchronous spi ? single chip, expanded, bootstrap and test modes of operation ? 84-pin plcc package (quad surface mount plastic) interrupts mode select oscillator periodic interrupt cop watchdog timer pulse accumulator a/d converter ddr a por t a ddr e por t e pe7/an8 pe0/an1 pe6/an7 pe4/an5 pe5/an6 pe3/an4 pe2/an3 pe1/an2 pa7/pai pa0/ic3 pa6/oc2 pa4/oc4 pa5/oc3 pa3/oc5/ic4 pa2/ic1 pa1/ic2 pai ic3 oc2 oc 4 oc 3 oc5/ic4 ic1 ic2 oc1 v v por t f pf7/a7 pf0/a0 pf6/a6 pf4/a4 pf5/a5 pf3/a3 pf2/a2 pf1/a1 por t b pb7/a15 pb0/a8 pb6/a14 pb4/a12 pb5/a13 pb3/a11 pb2/a10 pb1/a9 non-multiplexed address/data bus pg7 pg0 pg6 pg4 pg5 pg3 pg2 pg1 por t g ddr g ph7/mrdy ph0/pw1 ph6/evo ph4/evi2 ph5/evi1 ph3/pw4 ph2/pw3 ph1/pw2 por t h ddr h mrdy ev0 pw1 ev1 ev2 pw4 pw3 pw2 event counter pwm timer moda/lir modb/v xtal extal e pd0/rxd pd4/sck pd5/ss pd3/mosi pd2/mis o pd1/txd por t d ddr d ss sck miso mosi txd rxd spi sci 3 x v 3 x v rom 16k bytes ram 512 bytes ddr c por t c pc7/d7 pc0/d0 pc6/d6 pc4/d4 pc5/d5 pc3/d3 pc2/d2 pc1/d1 r/w m68hc11 cpu ddr j por t j pj0/tck pj3 pj2/oc7/ic6 pj1/oc6/ic5 oc7/ic6 tck oc6/ic5 reset halt xirq irq kam dd ss r h r l figure 1-1. functional block diagram
MC68HC11G5 operating modes and signal description motorola 2-1 section 2 operating modes and signal description this section describes the operating modes and signals of the MC68HC11G5 mcu. 2.1 operating modes during reset the MC68HC11G5 uses two mode select pins, moda and modb, to select one of two normal modes or one of two special operating modes. the normal operating modes are the single chip mode, which allows maximum use of the pins for on-chip peripheral functions, and the expanded non-multiplexed mode which allows access to the 64 kbytes of memory space including the internal ram, rom (if present), and register spaces. the special operating modes are the bootstrap mode (which causes all vectors to be fetched from the on-chip bootstrap rom), and the test mode (which is an expanded mode allowing special testing functions on the mcu subsystems). the special operating modes have access to certain privileged control bits which are not available in the normal operating modes. mode selection, according to the values encoded on the mode select pins (moda and modb), is shown in table 2-1. the states of moda and modb, captured during reset determine the logic state of the special mode (smod) and the mode a select (mda) control bits in the hprio register. table 2-1. mode select summary input pins latched at reset moda modb mode selected smod mda 0 1 single chip 0 0 1 1 expanded non-multiplexe d 01 0 0 bootstrap 1 0 1 0 test 1 1
motorola operating modes and signal description MC68HC11G5 2-2 2.1.1 single chip operating mode in single chip mode, the mcu functions as a self-contained microcontroller and has no external address or data bus. this mode provides maximum use of the pins for on-chip peripheral functions (66 pins). in single chip mode the r/w line is always high (read) to facilitate changing mode. 2.1.2 expanded non-multiplexed operating mode in the expanded non-multiplexed mode, the mcu can address up to 64 kbytes of address space. high order address bits are output on port b and low order address bits are output on port f. the bidirectional data bus is on port c and the r/w pin is used to control the direction of data transfer on this bus. 2.1.3 bootstrap operating mode this is a very versatile operating mode since there are essentially no limitations on the special purpose program that can be loaded into internal ram. the resident bootstrap program, contained in the bootstrap rom, uses the sci to read a variable length program into on-chip ram. program control is passed to ram at location $0000 when an idle line of at least four characters occurs. the MC68HC11G5 communicates through the sci port. after reset in bootstrap mode, the sci runs at e/16 (7812 baud for e-clock = 2 mhz). a break condition is output on the sci transmitter. for normal use of the bootstrap program, the user must send $ff to the sci receiver at either e/16 or e/104 (1200 baud for e-clock = 2 mhz). note: the $ff is not echoed through the sci transmitter. in this mode all interrupt vectors are mapped to pseudo-vectors in ram (refer to table 2-2). this allows programmers to use their own service-routine addresses. each pseudo-vector is allowed three bytes of space, rather than the two bytes for normal vectors, because an explicit jump (jmp) opcode is needed to cause the desired jump to the users service-routine address. since the smod control bit is initialized to one, all of the privileged control bits are accessible in this mode. this allows the bootstrap mode to be used for test and diagnostic functions on completed modules. mode switching can occur under program control by writing to the smod and mda bits of the hprio register. 2.1.4 test operating mode this special expanded mode is primarily intended for factory testing. in this mode the reset and interrupt vectors are fetched externally from locations $bffe C $bfff. the smod bit in the hprio register will be set, indicating that a special mode is in effect and allowing the user to write to certain privileged control bits which are normally read-only bits. also, a special register, test1, is enabled which allows several factory test functions to be invoked. it is also possible to change from the test mode to a normal operating mode by writing a zero to the smod bit. once this bit is cleared, it cannot be changed back to one without going through a reset sequence.
MC68HC11G5 operating modes and signal description motorola 2-3 table 2-2. bootstrap mode jump vectors address pseudo-vecto r 00b 5 event 2 00b 8 event 1 00b b timer overflow 2 00b e timer output compare 7 / input capture 00c1 timer output compare 6 / input capture 00c 4 sci 00c 7 sp i 00c a pulse accumulator input edg e 00c d pulse accumulator overflo w 00d 0 timer overflow 1 00d 3 timer output compare 5 / input capture 00d 6 timer output compare 4 00d 9 timer output compare 3 00d c timer output compare 2 00d f timer output compare 1 00e 2 timer input capture 3 00e 5 timer input capture 2 00e 8 timer input capture 1 00e b real time interrup t 00ee irq 00f1 xirq 00f 4 swi 00f 7 illegal op-cod e 00f a cop fai 00f d clock monito r bf4 0 rese t
motorola operating modes and signal description MC68HC11G5 2-4 2.1.4.1 factory test register (test1) tilop tpwsl occr cbyp1 disr fcm fcop cbyp2 test1 $103 e 76543210 00000000 reset: read: any time (always zero if not in a test mode) write: only while smod = 1 (test or boot modes) tilop test illegal opcode 0 C normal operation (trap on illegal opcodes) 1 C stop giving lir when an illegal opcode is found this test mode allows testing of all illegal opcodes serially without servicing an interrupt after each illegal opcode is received. lir (inactive for illegal opcodes) is used to monitor correct cpu operation. tpwsl pulse width modulation scaled clock 0 C normal operation 1 C clock s (scaled) from the pwm timer is output to and readable on the pwscal register. normal writing of the pwscal register will still function. occr output condition code register status to timer port 0 C normal operation 1 C the condition code bits h, n, z, v, and c are driven out of the 5 most significant bits (bits 3 C 7, respectively) of the timer i/o port to allow the test system to monitor cpu operation. cbyp1 timer counter 1 divider chain by-pass 0 C normal operation 1 C 16-bit free running timer counter 1 is divided into 8-bit halves and the prescaler is by-passed. the system e-clock drives both halves directly. disr disable resets from cop and clock monitor 0 C normal operation 1 C regardless of other control bit states, cop and clock monitor will not generate a system reset. when the device is reset in test or bootstrap mode (smod = 1), the disr bit is initialized to 1 so that resets from the cop and clock monitor are disabled. when reset in normal modes, the disr bit is initialized to 0. fcm force clock monitor failure 0 C normal operation 1 C immediately generates a clock monitor failure reset. note that the cme bit must also be set for the reset to be forced.
MC68HC11G5 operating modes and signal description motorola 2-5 fcop force cop watchdog failure 0 C normal operation 1 C immediately generates a cop failure reset. note that cop must be otherwise enabled for the reset to be generated; nocop = 0. cbyp2 timer counter 2 chain by-pass 0 C normal operation 1 C 16-bit free running timer counter 2 is divided into 8-bit halves and the prescaler is by-passed. the system e-clock drives both halves directly. the disr control bit has priority over the fcm and fcop control bits such that, if disr is set to one, no reset results even when fcm or fcop is set to one. 2.2 signal description the following table shows the pin usage for the MC68HC11G5. 5 volt supply (v dd , v ddl , v ddr )3 ground (v ss , v ssl , v ssr )3 reset 1 oscillator (xtal, extal) 2 e1 r/w 1 irq 1 xirq 1 halt 1 mode select (v kam & lir) 2 analog reference (v rh , v rl )2 8-bit ports (7) 56 6-bit port (1) 6 4-bit port (1) 4 total 84 pins the following paragraphs describe the input/output signals used by the various functions of the mcu. 2.2.1 input power (v dd ) and ground (v ss ) power is supplied to the mcu via three positive supply pins (v dd ) and three ground pins (v ss ). note that, for ease of identification, the v dd pins on the left and right sides of the device package are called v ddl and v ddr , respectively. similarly, the v ss pins on the left and right sides of the device package are called v ssl and v ssr .
motorola operating modes and signal description MC68HC11G5 2-6 2.2.2 reset (reset) this active low bidirectional control signal pin is used as an input to initialize the MC68HC11G5 to a known start-up state, and as an open-drain output to indicate an internal computer operating properly (cop) watchdog circuit or clock monitor failure. this reset signal is significantly different from the reset signal used on other motorola mcus. refer to section 5: resets, interrupts and low power modes before designing circuitry to generate or monitor this signal. mcu extal xta l nc or 10k ?100 load 4 x e cmos compatible external oscillato r figure 2-1. oscillator circuits: (a) external oscillator connections 220 first mcu extal xta l 10m 25 pf* 25 pf* 4 x e crysta l * this value contains all stray capacitanc e nc or 10k ?100 k load second mcu extal xta l figure 2-1. oscillator circuits: (b) one crystal driving two mcus first mcu extal xta l 10m 25 pf* 25 pf* 4 x e crysta l * this value contains all stray capacitanc e figure 2-1. oscillator circuits: (c) common crystal connections
MC68HC11G5 operating modes and signal description motorola 2-7 2.2.3 crystal driver (xtal) and external clock input (extal) these two pins provide the interface for either a crystal or a cmos compatible clock to control the internal clock generator circuitry. the frequency applied to these pins must be four times higher than the desired e-clock rate. when a crystal is used, a 25 pf capacitor should be connected from each of the xtal and extal pins to ground to ensure reliable start-up operation. when an external cmos compatible clock is used as an input to the extal pin, the xtal pin should be left disconnected. however, a 10 k w to 100 k w load resistor to ground may be used to reduce rfi noise emission. (see figure 2-1.) 2.2.4 e-clock output (e) the e-clock pin provides an output for the internally generated e-clock, which can be used as a timing reference. the frequency of the e-clock output is one quarter of the input frequency at the xtal and extal pins. when the e-clock output is low, an internal process is taking place; when high, data is being accessed. the signal is halted when the mcu is in stop mode. 2.2.5 read/write (r/w) this pin is used to control the direction of transfers on the external data bus in expanded non- multiplexed mode. a logic zero level indicates that data is being written to the external data bus; a logic one level indicates that a read cycle is in progress. r/w stays high during single-chip and bootstrap modes to maintain the read state for systems which switch modes. 2.2.6 interrupt request (irq) the irq pin provides the capability to apply asynchronous interrupts to the MC68HC11G5. it is software selectable, (using the irqe bit in the option register) with a choice of either negative edge sensitive or level sensitive triggering, and is always configured to level sensitive by reset. this pin requires an external pull-up resistor connected to v dd . 2.2.7 non-maskable interrupt (xirq) the xirq pin provides the capability for applying asynchronous non-maskable interrupts, after reset initialization, to the MC68HC11G5. during reset, the x-bit in the condition code register is set and any interrupt is masked until the mcu software enables it. the xirq input is level sensitive, and requires an external pull-up resistor to v dd . 2.2.8 halt (halt) this pin is used as a clean way to force the processor bus into a tri-state condition by means of an external signal. when halt is pulled low the processor completes execution of the present instruction and then tri-states the address and data bus. when the halt pin is released, the processor continues normal execution. the halt pin can also be used as a clean way to put the part into reset. once pulled into halt, reset can be pulled low, ensuring that the processor will be reset on an instruction boundary rather than in the middle of an instruction.
motorola operating modes and signal description MC68HC11G5 2-8 2.2.9 mode a/load instruction register (moda/lir) and mode b/standby voltage (modb/v kam ) during reset, moda and modb are used to select one of the four basic operating modes. refer to table 2-1 for mode selection and to paragraph 2.1: operating modes for additional details. after the operating mode has been selected, the open drain lir pin goes to an active low level during the first e-clock cycle of each instruction. the lir pin can be used as an aid to program debugging. the v kam signal is used as the input for ram standby power and will retain the ram contents during power down. 2.2.10 a/d converter reference voltages (v rl , v rh ) these two pins provide the reference high and low voltages to the internal analog-to-digital converter circuitry. refer to section 9: analog-to-digital converter . 2.2.11 port signals the 66 input/output (i/o) lines are arranged into seven 8-bit ports (ports a, b, c, e, f, g and h), one 6-bit port (port d) and one 4-bit port (port j). most of these ports serve more than one purpose, depending on the operating mode or peripheral functions selected. table 2-3 shows the different functions of each port pin in the four operating modes. for more detailed information on i/o ports refer to section 4: input/output ports.
MC68HC11G5 operating modes and signal description motorola 2-9 table 2-3. port signal functions: (a) expanded non-multiplexed and test modes port bit a b c d e f g h j 0 1 2 3 4 5 6 7 pa0/ic3 pa1/ic2 pa2/ic1 pa3/ic4/oc5 (and/or oc1) pa4/oc4 (and/or oc1) pa5/oc3 (and/or oc1) pa6/oc2 (and/or oc1) pa7/pa1 (and/or oc1) a8 a9 a10 a11 a12 a13 a14 a15 d0 d1 d2 d3 d4 d5 d6 d7 pd0/rxd pd1/txd pd2/miso pd3/mosi pd4/sck pe0/an1 pe1/an2 pe2/an3 pe3/an4 pe4/an5 pe5/an6 pe6/an7 pe7/an8 a0 a1 a2 a3 a4 a5 a6 a7 pg0 pg1 pg2 pg3 pg4 pg5 pg6 pg7 ph0/pw1 ph1/pw2 ph2/pw3 ph3/pw4 ph4/evi2 ph5/evi1 ph6/evo ph7/mrdy pj0/tck pj1/ic5/oc6 pj2/ic6/oc7 pj3 pd5/ ss table 2-3. port signal functions: (b) single chip and bootstrap modes port bit a b c d e f g h j 0 1 2 3 4 5 6 7 pa0/ic3 pa1/ic2 pa2/ic1 pa3/ic4/oc5 (and/or oc1) pa4/oc4 (and/or oc1) pa5/oc3 (and/or oc1) pa6/oc2 (and/or oc1) pa7/pa1 (and/or oc1) pb0 pb1 pb2 pb3 pb4 pb5 pb6 pb7 pc0 pc1 pc2 pc3 pc4 pc5 pc6 pc7 pd0/rxd pd1/txd pd2/miso pd3/mosi pd4/sck pd5/ pe0/an1 pe1/an2 pe2/an3 pe3/an4 pe4/an5 pe5/an6 pe6/an7 pe7/an8 pf0 pf1 pf2 pf3 pf4 pf5 pf6 pf7 pg0 pg1 pg2 pg3 pg4 pg5 pg6 pg7 ph0/pw1 ph1/pw2 ph2/pw3 ph3/pw4 ph4/evi2 ph5/evi1 ph6/evo ph7 pj0/tck pj1/ic5/oc6 pj2/ic6/oc7 pj3 ss
motorola operating modes and signal description MC68HC11G5 2-10 this page intentionally left blank
MC68HC11G5 memory and control/status registers motorola 3-1 section 3 memory and control/status registers this section describes the memory, memory subsystems mapping, and the mapping of the control and status registers of the MC68HC11G5 mcu. 3.1 rom the internal 16 kilobytes of rom occupy the highest 16k addresses in the memory map ($c000 C $ffff). on coming out of reset, this rom is enabled in the single chip, test and bootstrap modes. this rom is disabled when the romon bit in the config register is clear. this register bit is only writable in the special modes, bootstrap and test. for normal single chip mode, the rom is on (romon = 1). in expanded mode the rom is off (romon = 0) thus allowing the user to execute a program in the external memory space. (see also section 3.4.5: changing modes. ) 3.2 bootstrap rom the 256 bytes of bootstrap rom are located at memory locations $bf00 C $bfff. the reset and interrupt vectors, while in this mode, are addressed at $bfc0 C $bfff. the interrupt vectors point to pseudo-vectors located in ram (see section 2.1.3 and table 2-2). 3.3 ram using the init control register, the 512 byte block of static ram is mappable to the start of any 4 kilobyte boundary in memory. the reset default position of the ram is located at $0000 to $01ff. if the internal registers are mapped in the same 4 kilobyte block as ram, the registers will have higher priority. the ram is implemented with static cells and retains its contents during wait, halt and stop modes. the contents of the ram can also be retained during power-down, by supplying a low current back-up power source to the v kam pin (modb).
motorola memory and control/status registers MC68HC11G5 3-2 3.4 memory map each of the normal and special operating modes of the MC68HC11G5 has a default initial memory map. in addition, there is a control register (config) which can be used to remove (disable) the rom from the memory map. after reset the init register (which is reset to $01 independent of mode and may only be written under specific circumstances) can alter the mapping of ram and internal i/o resources under software control. while in bootstrap mode, the restart and interrupt vectors are fetched from an alternate memory area ($bfc0 C $bfff) in an internal bootstrap rom. in the test mode, vectors are also fetched from the alternate area ($bfc0 C $bfff), however, since the bootstrap rom is not enabled, these vectors reside in external memory. figure 3-1 shows the memory maps for all four modes of operation: single chip, expanded non- multiplexed, bootstrap and test. on-board memory locations are shown by the shaded areas and the contents of these areas are described on the right. 3.4.1 single chip mode this normal operating mode is established by having a logic one level on the modb/v kam pin and a logic zero level on the moda/lir pin at the rising edge of reset. the romon bit in the config register is a one out of reset in this mode, so that the user rom appears in the map. the initial memory map which results is also controlled by the state of three bits (rboot, smod, and mda) in the hprio control register which are initialized automatically by hardware prior to the rising edge on reset. initial conditions affecting the memory map are: romon = 1, rboot = 0, smod = 0, mda = 0
MC68HC11G5 memory and control/status registers motorola 3-3 $ffff $0000 $2000 $3000 $4000 $5000 $6000 $7000 $8000 $9000 $a000 $b000 $c000 $d000 $e000 $f000 $ffff $1000 single chip expanded non-multiplexed bootstrap test external external $1000 $107f $bf00 $bfff $bfc0 $bfff $c000 $ffc0 $ffff external external 512 byte ram (may be remapped to any 4k boundary by the init register) 128-byte register block (may be remapped to any 4k boundary by the init register) 256 bytes bootstrap rom special modes interrupt vectors 16k rom normal modes interrupt vectors $0000 $01ff normal modes special modes figure 3-1. memory map 3.4.2 expanded non-multiplexed mode this normal operating mode is established by having a logic one level on both the modb/v kam pin and the moda/lir pin at the rising edge of reset. the romon bit in the config register is a zero in this mode so that the user rom does not appear in the map. the initial memory map which results is also controlled by the state of three bits (rboot, smod, and mda) in the hprio control register which are initialized automatically by hardware prior to the rising edge on reset. initial conditions affecting the memory map are: romon = 0, rboot = 0, smod = 0, mda = 1
motorola memory and control/status registers MC68HC11G5 3-4 3.4.3 special bootstrap mode this special mode is established by having a logic zero level on both the modb/v kam pin and the moda/lir pin at the rising edge of reset. the romon bit in the config register is a one out of reset in this mode, so that the user rom appears in the map. the initial memory map which results is also controlled by the state of three bits (rboot, smod, and mda) in the hprio control register which are initialized automatically by hardware prior to the rising edge on reset. initial conditions affecting the memory map are: romon = 1, rboot = 1, smod = 1, mda = 0 3.4.4 special test mode this special mode is established by having a logic zero level on the modb/v kam pin and a logic one level on the moda/lir pin at the rising edge of reset. the romon bit in the config register is a one out of reset in this mode, so that the user rom appears in the map. the initial memory map which results is actually controlled by the state of three bits (rboot, smod, and mda) in the hprio control register which were initialized automatically by hardware prior to the rising edge on reset. initial conditions affecting the memory map are: romon = 1, rboot = 0, smod = 1, mda = 1 3.4.5 changing modes changing the operating mode and the bits described above is subject to some restrictions in normal modes. first of all, romon, rboot and smod will stay in their reset state. these bits cannot be changed in the normal operating modes. in order to allow a user to have an expanded mode system with the rom on, the user is allowed to change mda once only. this means that the user can bring the device out of reset in single chip mode, and then write mda to a 1, thus putting the part into expanded mode with the rom on (romon = 1). if the user does not intend to change modes after coming out of reset, he may wish to write mda one time to the same state. as mda may be written to only once; this will prevent an accidental write from changing the mode at some later time. in the special operating modes, romon, rboot and mda may be written at any time to either 0 or 1. smod cannot be written back to a 1 after being written to a 0, because the part will no longer be in a special mode. 3.5 system configuration the MC68HC11G5 allows the user to configure the mcu system to his specific requirements via hard wired options, such as the mode select pins, and via internal software programmable control
MC68HC11G5 memory and control/status registers motorola 3-5 registers. two special internal registers (init and config) require further explanation. the init control register allows the ram and internal register block to be repositioned in the memory map during software initialization. the config control register controls the presence of rom in the memory map as well as the nocop watch-dog system enable. 3.5.1 ram and i/o mapping register (init) the init register is a special purpose 8-bit register that is used during initialization to change the default locations of ram and control registers within the mcu memory map. it can be written to only once, within the first 64 e-clock cycles after a reset, and thereafter becomes a read-only register. ram3 ram2 ram1 ram0 reg3 reg2 reg1 reg0 init $ 1 03d 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 1 reset: read: any time write: if smod = 0, may be written once only, and only during the first 64 cycles: after this time the register becomes read-only. if smod = 1 (test or bootstrap mode), writes are always permitted. ram3, ram2, ram1, ram0 ?internal ram map position these four bits specify the four most significant bits of the 16-bit ram address. reg3, reg2, reg1, reg0 ?register block map position. these four bits specify the four most significant bits of the 16-bit internal register space address. for more details refer to the memory map. since the init register is set to $01 by reset, the default starting address is $0000 for ram and $1000 for the 128 byte control and status register block. the upper four bits of the init register specify the starting address for the 512 byte ram, while the lower four bits specify the starting address for the control and status register block. in each case, the four bits define the four most significant bits of the 16-bit address. if relocation conflicts occur between the ram and the rom, the ram takes priority over the rom which simply becomes inaccessible at those locations. similarly, if the control and status registers are located so that they conflict with the ram and/or rom, the registers take priority and the ram and/or rom at those locations become inaccessible. also, if an internal resource conflicts with an external device, no harmful conflict occurs. (data from the external device is not applied to the internal data bus, thus it cannot interfere with the internal read.)
motorola memory and control/status registers MC68HC11G5 3-6 note: there are unused register locations in the 128 byte control and status register block. reads of these unused registers return data from the undriven internal data bus, not from another source that happens to be located at the same address. 3.5.2 configuration control register (config) the config control register is used for system configuration control functions including removal of rom from the memory map, and enabling of the cop watch-dog system. nocop romon config $ 1 03f 7 6 5 4 3 2 1 0 see text reset: nocop ?cop system disable read: any time write: if smod = 0, may be written once only, and only during the first 64 cycles: after this time the bit becomes read-only. if smod = 1 (test or bootstrap mode), writes are always permitted. reset: 0 (cop on) for smod = 0; 1 (cop off) for smod = 1 0 cop system enabled (forces reset on timeout) 1 cop system does not force reset on timeout romon ?rom enable read: any time write: may not be written if smod = 0. if smod = 1, bit is writable at any time. reset: 1 (rom on) for single chip, bootstrap and test modes; 0 (rom off) for normal expanded mode 1 rom is present in the memory map (at $c000 ?$ffff) 0 rom is disabled from the memory map 3.6 control/status registers the control and status registers used to control the operation of the mcu are contained in a 128 byte block which can be relocated to any 4 kilobyte boundary in memory. throughout this document, control and status register addresses are displayed with the high order digit shown as a bold 1 to indicate that the register block may be relocated to some 4 kilobyte memory page other than its default position of $ 1 000. figure 3-2 is provides a complete list of the control and status registers and reserved locations in this block of memory.
MC68HC11G5 memory and control/status registers motorola 3-7 i/o port a data direction for port a i/o port g data direction for port g i/o port b i/o port f i/o port c data direction for port c i/o port d data direction for port d i/o port e compare force register oc1 action mask register oc1 action data register timer counter register 1 input capture 1 register input capture 2 register input capture 3 register output compare 1 register output compare 2 register output compare 3 register output compare 4 register output compare 5/ input capture 4 register $ 1 00 0 pa7 pa6 pa5 pa4 pa3 pa2 pa1 pa0 porta $ 1 001 dda7 dda6 dda5 dda4 dda3 dda2 dda1 dda0 ddra $ 1 00 2 pg7 pg6 pg5 pg4 pg3 pg2 pg1 pg0 portg $ 1 00 3 ddg7 ddg6 ddg5 ddg4 ddg3 ddg2 ddg1 ddg0 ddrg $ 1 00 4 pb7 pb6 pb5 pb4 pb3 pb2 pb1 pb0 portb $ 1 00 5 pf7 pf6 pf5 pf4 pf3 pf2 pf1 pf0 portf $ 1 00 6 pc7 pc6 pc5 pc4 pc3 pc2 pc1 pc0 portc $ 1 00 7 ddc7 ddc6 ddc5 ddc4 ddc3 ddc2 ddc1 ddc0 ddrc $ 1 00 8 0 0 pd5 pd4 pd3 pd2 pd1 pd0 portd $ 1 00 9 0 0 ddd5 ddd4 ddd3 ddd2 ddd1 ddd0 ddrd $ 1 00 a pe7 pe6 pe5 pe4 pe3 pe2 pe1 pe0 porte $ 1 00 b foc1 foc2 foc3 foc4 foc5 foc6 foc7 0 cforc $ 1 00c oc1m7 oc1m6 oc1m5 oc1m4 oc1m3 0 0 0 ocim $ 1 00d oc1d7 oc1d6 oc1d5 oc1d4 oc1d3 0 0 0 ocid $ 1 00 e bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 tcnt1 $ 1 00f bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $ 1 01 0 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 tic1 $ 1 011 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $ 1 01 2 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 tic2 $ 1 01 3 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $ 1 01 4 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 tic3 $ 1 01 5 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $ 1 01 6 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 toc1 $ 1 01 7 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $ 1 01 8 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 toc2 $ 1 01 9 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $ 1 01 a bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 toc3 $ 1 01 b bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $ 1 01c bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 toc4 $ 1 01d bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $ 1 01 e bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 to5i4 $ 1 01f bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 figure 3-2. control and status registers (page 1)
motorola memory and control/status registers MC68HC11G5 3-8 $ 1 02 0 om2 ol2 om3 ol3 om4 ol4 om5 ol5 tctl1 timer control register 1 $ 1 021 edg4b edg4a edg1b edg1a edg2b edg2a edg3b edg3a tctl2 timer control register 2 $ 1 02 2 oc1i oc2i oc3i oc4i 4/5i ic1i ic2i ic3i tmsk1 main timer interrupt mask register 1 $ 1 02 3 oc1f oc2f oc3f oc4f 4/5f ic1f ic2f ic3f tflg1 main timer interrupt flag register 1 $ 1 02 4 to1i rtii paovi paii to2i 5/6i 6/7i 0 tmsk2 misc. timer interrupt mask register 2 $ 1 02 5 to1f rtif paovf paif to2f 5/6f 6/7f 0 tflg2 misc. timer interrupt flag register 2 $ 1 02 6 0 paen pamod pedge i4/o5 rtr2 rtr1 rtr0 pactl pulse accumulator control register $ 1 02 7 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pacnt pulse accumulator count register $ 1 02 8 spie spe dwom mstr cpol cpha spr1 spr0 spcr spi control register $ 1 02 9 spif wcol 0 modf 0000 spsr spi status register $ 1 02 a bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 spdat spi data register $ 1 02 b tclr 0 scp1 scp0 rckb scr2 scr1 scr0 baud sci baud rate control $ 1 02c r8 t8 0 m wake 0 0 0 sccr1 sci control register 1 $ 1 02d tie tcie rie ilie te re rwu sbk sccr2 sci control register 2 $ 1 02 e tdre tc rdrf idle or nf fe 0 scsr sci status register $ 1 02f bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 scdat sci data (read rdr, write tdr) $ 1 03 0 ccf conv8 scan mult cd cc cb ca adctl a/d control register $ 1 0310000pj3pj2pj1pj0 portj i/o port j $ 1 03 2 0000 ddj3 ddj2 ddj1 ddj0 ddrj data direction for port j $ 1 03 3 ph7 ph6 ph5 ph4 ph3 ph2 ph1 ph0 porth i/o port h $ 1 03 4 ddh7 ddh6 ddh5 ddh4 ddh3 ddh2 ddh1 ddh0 ddrh data direction for port h $ 1 03 5 00000000 reserved $ 1 03 6 00000000 reserved $ 1 03 7 00000000 reserved $ 1 03 8 gwom cwom 0 irv 0 0 mrdy nhalt opt2 system configuration options 2 reg. $ 1 03 9 adpu csel irqe dly cme 0 cr1 cr0 option system configuration options $ 1 03 a bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 coprst arm/reset cop timer circuitry $ 1 03 b 00000000 reserved $ 1 03c rboot smod mda psel4 psel3 psel2 psel1 psel0 hprio highest priority i-bit interrupt and misc. $ 1 03d ram3 ram2 ram1 ram0 reg3 reg2 reg1 reg0 init ram and i/o mapping register $ 1 03 e tilop tpwsl occr cbyp1 disr fcm fcop cbyp2 test1 factory test control register $ 1 03f00000 nocop romon 0 config cop and rom enables figure 3-2. control and status registers (page 2)
MC68HC11G5 memory and control/status registers motorola 3-9 output compare 6/ input capture 5 register output compare 7/ input capture 6 register tedgb edg5b ct2sp $ 1 040 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 adr1 a/d result register 1 $ 1 041 bit 7 bit 6 000000 $ 1 042 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 adr2 a/d result register 2 $ 1 043 bit 7 bit 6 000000 $ 1 04 4 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 adr3 a/d result register 3 $ 1 04 5 bit 7 bit 6 000000 $ 1 04 6 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 adr4 a/d result register 4 $ 1 04 7 bit 7 bit 6 000000 $ 1 04 8 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 adr5 a/d result register 5 $ 1 04 9 bit 7 bit 6 000000 $ 1 04 a bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 adr6 a/d result register 6 $ 1 04 b bit 7 bit 6 000000 $ 1 04c bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 adr7 a/d result register 7 $ 1 04d bit 7 bit 6 000000 $ 1 04 e bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 adr8 a/d result register 8 $ 1 04f bit 7 bit 6 000000 $ 1 05 0 edg5a edg6b edg6a om6 ol6 om7 ol7 tctl3 timer control register 3 $ 1 051 ct1sp 0000 i5/o6 i6/o7 tctl4 timer control register 4 $ 1 05 2 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 tcnt2 timer counter register 2 $ 1 05 3 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $ 1 05 4 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 to6i5 $ 1 05 5 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $ 1 05 6 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 to7i6 $ 1 05 7 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 $ 1 05 8 tedga pr2b pr2a 0 0 pr1b pr1a tpre timer prescaler register $ 1 05 9 00000000 reserved $ 1 05 a 00000000 reserved $ 1 05 b 00000000 reserved $ 1 05c00000000 reserved $ 1 05d00000000 reserved $ 1 05 e 00000000 reserved $ 1 05f00000000 reserved figure 3-2. control and status registers (page 3)
motorola memory and control/status registers MC68HC11G5 3-10 pcka2 pcka1 pckb3 pckb2 pwen4 pwen3 pwen2 pwen1 evmdb evmda evckc evckb evcka evcen $ 1 06 0 con3 4 con12 0 pckb1 pwclk pwm timer clock select $ 1 061 pclk4 pclk3 pclk2 pclk1 ppol4 ppol3 ppol2 ppol1 pwpol pwm timer polarity $ 1 06 2 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pwscal pwm timer prescaler $ 1 06 3 0000 pwen pwm timer enable $ 1 06 4 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pwcnt1 pwm timer counter 1 $ 1 06 5 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pwcnt2 pwm timer counter 2 $ 1 06 6 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pwcnt3 pwm timer counter 3 $ 1 06 7 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pwcnt4 pwm timer counter 4 $ 1 06 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pwper1 pwm timer period 1 $ 1 06 9 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pwper2 pwm timer period 2 $ 1 06 a bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pwper3 pwm timer period 3 $ 1 06 b bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pwper4 pwm timer period 4 $ 1 06c bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pwdty1 pwm timer duty 1 $ 1 06d bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pwdty2 pwm timer duty 2 $ 1 06 e bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pwdty3 pwm timer duty 3 $ 1 06f bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pwdty4 pwm timer duty 4 $ 1 07 0 00 0 evclk event counter clock select $ 1 071 evoen evpo l evi2c evi2b evi2a evi1c evi1b evi1a evctl event counter control register $ 1 07 2 00000 ev2i ev1i evmsk event counter interrupt mask register $ 1 07 3 000000 ev2f ev1f evflg event counter interrupt flag register $ 1 07 4 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 evcnt1 event counter count register 1 $ 1 07 5 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 evcnt2 event counter count register 2 $ 1 07 6 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ecmp1a event counter compare register 1a $ 1 07 7 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ecmp2a event counter compare register 2a $ 1 07 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ecmp1b event counter compare register 1b $ 1 07 9 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ecmp2b event counter compare register 2b $ 1 07 a 00000000 reserved $ 1 07 b 00000000 reserved $ 1 07c00000000 reserved $107d 00000000 reserved $107e 00000000 reserved $ 1 07f00000000 reserved figure 3-2. control and status registers (page 4)
MC68HC11G5 input/output ports motorola 4-1 section 4 input/output ports there are seven 8-bit i/o ports, one 6-bit i/o port and one 4-bit i/o port on the MC68HC11G5. most of the 66 i/o pins serve multiple purposes depending on the configuration of the mcu system (see table 2-3). the configuration is controlled in turn, by hardware mode selection as well as by several internal control registers. ports a, c, d, g, h, and j may be used as general purpose input and/or output pins as specified by ddra, ddrc, ddrd, ddrg, ddrh, and ddrj. ports b, e, and f have fixed data direction and thus do not require ddr control registers. port signals can always be sensed (read) even if they are configured as general purpose outputs or are dedicated to on-chip peripheral functions. reading the port address returns the sensed logic level at the pin when the pin is configured as an input, and the logic sense at the input to the pin driver is sensed when the pin is configured as an output. i/o pins default to being general purpose i/o lines unless an internal function which uses that pin is specifically enabled. when a pin is dedicated to an internal peripheral function the associated ddr bit in some cases still controls whether the line is an input or an output. the spi, timer input captures and pulse accumulator follow this rule. several functions override the state of the ddrs. the sci forces the i/o state of the two associated port d lines. the timer also forces the i/o state of each associated port a line when an output compare using a port a or port j line is enabled. both the pwm timer and the event counter also override the associated ddr bits. in these cases the data direction bits will have no effect on these lines. when a pin is dedicated to an on-chip peripheral function, writes to the associated portx bit do not affect the pin but are stored in an internal latch such that, if the pin becomes available for general purpose output, the driven level will be the last value written to the portx bit. 4.1 mode dependencies the mcu mode is controlled by two mode select bits (smod and mda) in the hprio register which are in turn controlled by the two mode select pins (moda and modb). in the expanded modes (normal expanded and test), ports b, c, e and f, r/w, and lir are dedicated to address, data, and control signals and may not be used for alternate i/o functions. in order to
motorola input/output ports MC68HC11G5 4-2 preserve the port functions that are displaced by the expanded modes, these functions become externally accessible functions so that they may be emulated with external hardware, if required. the internal register addresses that become external accesses are portb, ddrc, portc and portf. 4.2 general purpose i/o (ports a, c, d, g, h, and j) as general purpose i/o lines, each pin has associated with it a bit in a portx data register and a bit in the corresponding position in a ddrx register. the data direction register (ddrx) is used to specify the primary direction of data on the i/o pin. however, specification of a line as an output does not prevent reading of the line as an input. when a bit configured as an output is read, there are two kinds of data which may be returned, depending on the internal circuitry of the port. reading port a, port h, or port j returns the values sensed at the pins. reading port c, port d, or port g returns the values at the inputs to the pin drivers. when a line is configured as an input by clearing the ddrx bit, the pin becomes a high impedance input. if a write is executed to a line that is configured as an input, the value will not affect the i/o pin but the bit will be stored in an internal latch so that, if the line is later reconfigured as an output, this value will appear at the i/o pin. this operation can be used to preset a value for an output port prior to configuring it as an output, thereby avoiding glitches on the outputs which may be detrimental to the operation of the external system. ports c, d, and g each have a wired-or mode of operation which is controlled by the cwom, dwom, and gwom bits, respectively. if the corresponding xwom bit is set, the p-channel drivers in the output buffers are disabled. note: bits 6 and 7 of port d and bits 4 through 7 of port j are not implemented. 4.3 fixed direction i/o (ports b, e, and f) the pins for ports b, e, and f have fixed data directions and consequently do not have data direction registers associated with them. when ports b and f are being used for general purpose i/o, they are configured as output only ports and reading them returns the levels sensed at the inputs of the pin drivers. port e supports the eight a/d channel inputs but these pins may also be used as general purpose digital inputs. writing to the port e address has no meaning or effect. 4.4 port a port a is an 8-bit bidirectional port. port a pins can be used as general purpose i/o or for timer functions. each pin behaves as a general purpose i/o bit by default, unless a timer function using that bit is specifically enabled. as general purpose i/o, the data direction of port a pins are determined by the corresponding ddra bits. the directions of port a bits 0, 1, and 2 are always
MC68HC11G5 input/output ports motorola 4-3 controlled by the ddra bits whether ic3, ic2, and ic1 are enabled or not. port a bits 3 C 7 are controlled by the ddra bits only when the associated output compare functions are disabled. enabling an output compare function forces the corresponding port bit to be an output, irrespective of the state of the ddra bit. using any pins of port a for timer functions has no effect on the ability to read these pins as inputs (because input sensing logic is always connected to the port pins). the oc2, oc3, oc4, and oc5 lines out of port a are enabled by pairs of control bits in the tctl1 register. the output compare 1 function is unique in that it allows automatic timer control of any combination of the five most significant bits of port a regardless of whether or not they are being used for another timer function. the oc1 function gains control of port a bits by setting the corresponding bits in the oc1m control register. the ic1, ic2, ic3, and ic4 input of port a are enabled by pairs of control bits in the tctl2 register. (see section 6: programmable timer, real time interrupt and pulse accumulator .) the ic4 function and oc5 function share the same port a bit and they are selected by the i4/o5 bit in the pactl register. the pulse accumulator system is enabled, on port a bit 7 as an input, by setting the paen bit in the pactl register. even while the pulse accumulator is enabled, port a bit 7 may be configured as an output controlled by oc1 or as a general purpose output. 4.4.1 data register (porta ) pa7 pa6 pa5 pa4 pa3 pa2 pa1 pa0 porta $ 1 000 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: alternate pin function: and/or: pa1 oc2 oc3 oc4 oc5/ic4 ic1 ic2 ic3 oc1 oc1 oc1 oc1 oc1 read: any time (inputs return pin levels; outputs return pin driver input levels). write: data stored in an internal latch. (drives pins only if configured as outputs.) reset: general purpose high impedance inputs ($00). note: writes do not change pin state when pin is configured for timer output. 4.4.2 data direction register (ddra ) dda7 dda6 dda5 dda4 dda3 dda2 dda1 dda0 ddra $ 1 001 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: read: any time. write: any time. reset: $00 (all general purpose i/o configured for input only). 0 C bits set to zero configure the corresponding i/o pins as inputs. 1 C bits set to one configure the corresponding i/o pins as outputs.
motorola input/output ports MC68HC11G5 4-4 note: the timer forces each port a line associated with an enabled output compare to be an output. in such cases the data direction bits will not be changed but will have no effect on these lines. ddra will revert to controlling the i/o state of a pin when the associated timer output compare is disabled. 4.5 port b port b is an 8-bit general purpose output port which also supports the external address bus. in the expanded modes (normal expanded and test), these pins act as the high order address output pins. during each mcu cycle, bits 8 through 15 of the address are driven out of bits 0 through 7 of port b. when the nhalt bit in the opt2 register is cleared and the halt input is pulled low, all output buffers of port b bits go tri-state. in the single chip modes (normal and bootstrap), the port b pins are general purpose output only pins. reading port b in these modes returns the sensed levels at the inputs to the port b pin drivers. the port b data register is cleared at reset and all port b bits output logic zeros. 4.5.1 data register (portb) pb7 pb6 pb5 pb4 pb3 pb2 pb1 pb0 portb $ 1 004 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: alternate pin function: a15 a14 a13 a12 a11 a10 a9 a8 read: any time (returns levels sensed at inputs of port b pin drivers). write: data stored in internal latch (drives pins only if configured as general purpose outputs). reset: in single chip modes, all port b pins are general purpose output only pins (all zeros). in expanded modes, all port b pins are high order address signal outputs. 4.6 port c port c is an 8-bit bidirectional port. port c pins serve one of two basic functions depending on the mcu mode selected; bidirectional data lines or general purpose i/o pins. in either mode, if the cwom bit in the opt2 register is set, the p-channel drivers in the output buffers are disabled (wired- or mode). in the expanded modes (normal expanded and test), these pins act as bidirectional data pins. during the cpu read cycle, data on the port c pins are latched internally on the falling edge of e. during the cpu write cycle, the internal data is driven out of port c and is valid at the falling edge of e. during an internal address read cycle with the irv bit in the opt2 register set, the internal data is also driven out of port c and is valid at the falling edge of e. if the mcu is in the halt state, all port c bits become tri-state.
MC68HC11G5 input/output ports motorola 4-5 in the single chip modes (normal and bootstrap), the port c pins are general purpose i/o pins. bits 0 C 7 are input or output pins depending on the corresponding bit of ddrc. while a bit is configured as an output, reading the bit returns the sensed level at the input to the port c pin driver. at reset, all ddrc bits are cleared and all port c bits are configured as inputs. 4.6.1 data register (portc) pc7 pc6 pc5 pc4 pc3 pc2 pc1 pc0 portc $ 1 006 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: alternate pin function: d7 d6 d5 d4 d3 d2 d1 d0 read: any time (inputs return pin level; outputs return pin driver input level). write: data stored in internal latch (drives pins only if configured as outputs) reset: in single chip modes all port c pins are configured as general purpose inputs. in expanded modes, port c is configured as the data bus. 4.6.2 data direction register (ddrc) ddc7 ddc6 ddc5 ddc4 ddc3 ddc2 ddc1 ddc0 ddrc $ 1 007 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: read: any time. write: any time. reset: $00 (all general purpose i/o configured for input only). 0 C bits set to zero configure the corresponding i/o pins as inputs. 1 C bits set to one configure the corresponding i/o pins as outputs. 4.7 port d port d is a 6-bit bidirectional port which also supports the sci and spi systems. when the sci or spi is not needed the associated pins may be used for general purpose i/o. port d pins serve several functions depending on the mcu mode and various internal control registers. if the dwom bit in the spcr register is set, the p-channel drivers in the output buffers are disabled (wired-or mode). port d bit 0 becomes the receive data input (rxd) when the sci receiver is enabled (re bit in the sccr2 register set to one). when the re bit is clear, port d bit 0 defaults to being a general purpose i/o pin controlled by ddrd.
motorola input/output ports MC68HC11G5 4-6 port d bit 1 becomes the transmit data output (txd) when the sci transmitter is enabled (te bit in the sccr2 register set to one). when the te bit is clear, port d bit 1 defaults to being a general purpose i/o pin controlled by ddrd. note that the transmit logic will retain control of port d bit 1 after te is cleared until all transmit operations have finished, including completion of transmission of data from the serial shifter, a queued idle, or queued break. in a test mode, the rckb test bit in the baud register may be set. when rckb is set, the 16x receiver baud rate clock and the 1x transmitter clock are exclusive-ored and driven out of the port d bit 1 pin. the rckb bit can be written only in the test or bootstrap modes and it overrides any other use of the port d bit 1 pin. bits 2 C 5 of port d are dedicated to the serial peripheral interface function (spi) whenever the spe bit in the spcr register is set (spi enabled). note that port d bit 5 still responds to ddrd bit 5 such that, if the ddr bit is set, the port d bit 5 pin is given up by the spi system to become a general purpose output pin if and only if the spi is in master mode. when the spe bit is clear, bits 2 C 5 of port d default to being general purpose i/o pins controlled by ddrd. the four spi interface lines are described in greater detail in section 8: serial peripheral interface. 4.7.1 data register (portd) 0 0 pd5 pd4 pd3 pd2 pd1 pd0 portd $ 1 008 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: alternate pin function: ss sck mosi miso txd rxd read: any time (inputs return pin level; outputs return pin driver input level). bits 6 and 7 always read as zeros. write: data stored in internal latch (drives pins only if configured as outputs). writes to bit 6 and 7 have no meaning or effect. reset: bits 0 C 5 are configured as general purpose inputs. 4.7.2 data direction register (ddrd) 0 0 ddd5 ddd4 ddd3 ddd2 ddd1 ddd0 ddrd $ 1 009 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: read: any time (reads of bits 6 and 7 always return zeros). write: any time (writes to bits 6 and 7 have no meaning or effect).
MC68HC11G5 input/output ports motorola 4-7 reset: $00 (all general purpose i/o configured for input only). 0 C bits set to zero configure the corresponding i/o pins as inputs. 1 C bits set to one configure the corresponding i/o pins as outputs. bit 5 of port d is dedicated as the active low slave select (ss) input, when the spi system is enabled. in spi slave mode, ddrd bit 5 has no meaning or effect. in spi master mode, ddrd bit 5 determines whether port d bit 5 is an error detect input to the spi (ddrd bit clear) or a general purpose output line (ddrd bit set). for bits 2, 3, & 4 (miso, mosi, & sck): if the spi is enabled and expects the bit to be an input, it will be an input regardless of the state of the ddrd bit; if the spi is enabled and expects the bit to be an output, it will be an output only if the ddrd bit is set. 4.8 port e port e is an 8-bit port which supports the 8-channel a/d converter. any channels not used for a/d may be used as general purpose inputs. since there is no output drive logic associated with port e there is no ddre register. port e pins are capable of withstanding negative 1 volt transients (current limited by an external 10 k w or greater resistor) without affecting mcu operation, other than possible loss of the a/d input sample for a conversion being performed at the time of the transient. using port e pins as a/d inputs does not affect the ability to read these pins as static inputs. however, reading port e during an a/d conversion sequence may inject noise into the analog input signals and may result in reduced accuracy of the a/d result. note that performing a digital read of port e, with levels other than v dd or v ss on the port e pins, will result in greater power dissipation during the read cycle. 4.8.1 data register (porte) pe7 pe6 pe5 pe4 pe3 pe2 pe1 pe0 porte $ 1 00a 7 6 5 4 3 2 1 0 u u u u u u u u reset: alternate pin function: an7 an6 an5 an4 an3 an2 an1 an0 read: any time (returns sensed levels at port e pins). write: has no meaning or effect. reset: does not affect this address.
motorola input/output ports MC68HC11G5 4-8 4.9 port f port f is an 8-bit general purpose output port which also supports the external address bus. in the expanded modes (normal expanded and test), these pins act as the low order address output pins. during each mcu cycle, bits 0 C 7 of the address are driven out of bits 0 C 7 of port f. when the nhalt bit in the opt2 register is cleared and the halt input is pulled low, all output buffers on port f pins go tri-state. in the single chip modes (normal and bootstrap), the port f pins are general purpose output only pins. reading port f in these modes returns the sensed levels at the inputs to the port f pin drivers. the port f data register is cleared at reset and all port f bits output logic zeros. 4.9.1 data register (portf) pf7 pf6 pf5 pf4 pf3 pf2 pf1 pf0 portf $ 1 005 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: read: any time (returns sensed levels at inputs of port f pin drivers). write: data stored in internal latch (drives pins only if configured as general purpose outputs). reset: in single chip modes, all port f pins are general purpose output only pins (all zeros). in expanded modes, all port f pins are low order address signal outputs. 4.10 port g port g is an 8-bit bidirectional port. port g pins serve one of two basic functions depending on the mcu mode selected; bidirectional data lines or general purpose i/o pins. in either mode, if the gwom bit in the opt2 register is set, the p-channel drivers in the output buffers are disabled (wired- or mode). port g may be programmed as an input or an output under software control. the data direction of each pin is determined by the state of the corresponding bit in the port g data direction register (ddrg). a pin is configured as an output if its corresponding ddrg bit is set to a logic one; a pin is configured as an input if its corresponding ddrg bit is cleared. at reset, all ddrg bits are cleared, which configure all port g pins as inputs. during the programmed output state, a read of port g actually reads the value of output data latch and not the pin level. when the gwom bit in opt2 is set, the p-channel drivers of output buffers are disabled (wired-or mode).
MC68HC11G5 input/output ports motorola 4-9 4.10.1 data register (portg) pg7 pg6 pg5 pg4 pg3 pg2 pg1 pg0 portg $ 1 002 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: read: any time (inputs return pin levels; outputs return pin driver input levels). write: data stored in an internal latch (drives pins only if configured as outputs). reset: general purpose high impedance inputs ($00) 4.10.2 data direction register (ddrg) ddg7 ddg6 ddg5 ddg4 ddg3 ddg2 ddg1 ddg0 ddrg $ 1 003 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: read: any time. write: any time. reset: $00 (all general purpose i/o configured for input only). 0 C bits set to zero configure the corresponding i/o pins as inputs. 1 C bits set to one configure the corresponding i/o pins as outputs. 4.11 port h port h is an 8-bit general purpose i/o port. three of the pins are used for the event counter (see section 11: event counter ). four of the remaining pins are used for the 4-channel pwm timer (see section 10: pulse width modulation timer ). the remaining pin is used for the memory ready input signal (mrdy). any pins not used for these functions may be used as general purpose i/o. when the pwenx bit in the pwen register is set, the associated port h bit is forced to be a pwm output regardless of the state of the ddrh bit. this does not change the state of the ddrh bit. when the pwenx bit in the pwen register is cleared, the pin defaults to being a general purpose i/o. the data direction of the pin is determined by the state of the corresponding ddrh bit. bits 4 and 5 of port h are used as the evi2 and evi1 inputs or as general purpose i/o. the data direction of port h bits 4 and 5 is always under the control of ddrh bits 4 and 5, whether evi2 and evi1 are enabled or not. if the pin is configured as an output by its ddrh bit, the output data of the port h register is also the input data of the event counter.
motorola input/output ports MC68HC11G5 4-10 bit 6 of port h is used as the event output (evo) or as general purpose i/o. when the evoen bit in the evctl register is set, bit 6 of port h becomes evo regardless of the state of ddrh bit 6. this does not change the state of ddrh bit 6. when the evoen bit in the evctl register is cleared, the data direction of the pin is under the control of ddrh bit 6. in the expanded non-multiplexed and test modes, bit 7 of port h is used as the memory ready signal (mrdy) or as general purpose i/o. when the mrdy bit in the opt2 register is set, bit 7 of port h becomes the memory ready input regardless of the state of ddrh bit 7. when the mrdy bit in the opt2 register is cleared, the data direction of the pin is under the control of ddrh bit 7. in the single chip and bootstrap modes, bit 7 of port h is a general purpose i/o pin and the data direction of the pin is determined by the state of ddrh bit 7. reading port h reads the levels sensed at the pins regardless of the ddrh, pwenx, and evoen bits. all ddrh bits are cleared at reset. 4.11.1 data register (porth) ph7 ph6 ph5 ph4 ph3 ph2 ph1 ph0 porth $ 1 033 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: alternate pin function: mrdy evo evi1 evi2 pw4 pw3 pw2 pw1 read: any time (inputs return pin levels, outputs return pin driver input levels). write: data stored in an internal latch (drives pins only if configured for output). reset: general purpose high impedance inputs ($00). 4.11.2 data direction register (ddrh) ddh7 ddh6 ddh5 ddh4 ddh3 ddh2 ddh1 ddh0 ddrh $ 1 034 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: read: any time write: any time reset: $00 (all general purpose i/o configured for input only) 0 C bits set to zero configure the corresponding i/o pins as inputs. 1 C bits set to one configure the corresponding i/o pins as outputs. note: the pulse width modulation timer forces the i/o state to be an output for each port h line associated with an enabled pwm. in such cases, the data direction bits will not be changed but have no effect on these lines. ddrh will revert to controlling the i/o state of a pin when the associated function is disabled. the event counter does not force the state of any of the associated pins.
MC68HC11G5 input/output ports motorola 4-11 4.12 port j port j is a general purpose 4-bit i/o port which also supports some of the timer functions (see section 6: programmable timer, real time interrupt and pulse accumulator ). two of the pins are used for input capture/output compare. one of the pins is used as a clock input for the timer counter registers. the one remaining pin is for general purpose i/o. any channels not used for timers may be used as general purpose i/o. bit 0 of port j is used as the tck input or for general purpose i/o. the data direction is always under the control of ddrj bit 0, whether tck is enabled or not. if the pin is configured as an output by ddrj bit 0, the output data in port j bit 0 becomes the input data to tck. bits 1 and 2 of port j is used for output compare or input capture or as general purpose i/o. if the associated output compare is not enabled, the data directions of these pins are dependent on ddrj bits 1 and 2. if an output compare is enabled, the associated pin is configured automatically as an output. if a pin is programmed as an output and input capture is enabled, the output data becomes the input data to the input capture. bit 3 of port j is a general purpose i/o pin and the data direction of the pin is determined by the state of ddrj bit 3. all ddrj bits are cleared at reset. 4.12.1 data register (portj) 0 0 0 0 pj3 pj2 pj1 pj0 portj $ 1 031 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: alternate pin function: o7/i6 o6/i5 tck read: any time (inputs return pin levels, outputs return pin driver input levels). write: data stored in an internal latch (drives pins only if configured as outputs). reset: general purpose high impedance inputs ($00). 4.12.2 data direction register (ddrj) 0 0 0 0 ddj3 ddj2 ddj1 ddj0 ddrj $ 1 032 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: read: any time. write: any time. reset: $00 (all general purpose i/o configured for input only). 0 C bits set to zero configure the corresponding i/o pins as inputs. 1 C bits set to one configure the corresponding i/o pins as outputs.
motorola input/output ports MC68HC11G5 4-12 note: the timer forces the i/o state to be an output if output compare 6 is enabled on port j bit 1 (om6 or ol6 is a 1 and i5/o6 is a 0). the timer also forces the i/o state to be an output if output compare 7 is enabled on port j bit 2 (om7 or ol7 is a 1 and i6/o7 is a 0). in this case, the data direction bit is not changed but has no effect on this line. the ddrj bit will revert to controlling the i/o state of the pin when timer output compare 6 is disabled. tck does not force the state of the line associated with it. 4.13 expanded bus (ports b, c, f) the MC68HC11G5 has a non-multiplexed expansion bus. this simplifies system design, as demultiplexing circuitry is not required. it also eliminates the need for an address strobe line. the user gains three additional ports when the part is used in single chip mode. port b provides the high order addresses in expanded mode, but may be used as a general purpose output port in single chip mode. similarly, port f provides the low order addresses, but may be used as a general purpose output port in single chip mode. port c is the data bus in expanded mode, but may be used as general purpose i/o in single chip mode. port c has a data direction register for use in single chip mode. in order to allow emulation of all MC68HC11G5 functions, even in the expanded modes, the functions displaced by specification of the expanded mode become externally addressed functions. the registers which become external accesses are portc, ddrc, portb and portf. 4.13.1 r/w the read/write output signal (r/w) is a dedicated function when the MC68HC11G5 is in normal expanded mode or test mode. the timing of this signal is the same as the timing for a port b address output, except for the hold time from the falling edge of e, which is extended so that no special circuitry is needed in a multi-board expanded system. this output reflects the state of the internal cpu r/w signal. in the single chip and bootstrap modes, the r/w pin is a dedicated output which is always high (read). this permits changing from one of these modes to an expanded mode, without the risk that the r/w line might have been in the write state, causing bus conflicts or inadvertent external memory changes.
MC68HC11G5 input/output ports motorola 4-13 4.13.2 memory ready (mrdy) a memory ready function is available on the MC68HC11G5. this allows interfacing to slow peripherals and dual ported ram, and to dynamic ram without a hidden refresh. when the memory ready function is enabled, mrdy is used to stretch the cpu timing and e-clock to allow a longer access time. note that internal clocks to timers and baud rate generators continue to run at the normal rate so that the timer and serial systems are not affected. port h bit 7 is used as the memory ready line (mrdy). when this line is low, an external access will be stretched until the line goes high. during the stretch time the address lines will be held and e will be kept in the high state. for write operations the data will be held and for read operations the data bus lines will be inputs. when mrdy goes high, e will fall thus ending the cycle, and will continue at a normal rate until the next external access during which mrdy is low. note that the bus will only stretch for integral numbers of e-clock cycles. 4.13.3 options register 2 (opt2) gwom cwom 0 irv 0 0 mrdy nhalt opt2 $ 1 038 7 6 5 4 3 2 1 0 0 0 0 0 0 0 1 reset: gwom port g wired-or mode read: any time. write: any time. 0 C port g operates normally. 1 C port g outputs are open drain (used to facilitate testing). cwom port c wired-or mode read: any time. write: any time. 0 C port c operates normally. 1 C port c outputs are open drain (used to facilitate testing).
motorola input/output ports MC68HC11G5 4-14 irv internal read visibility read: any time. write: if smod=1, any time. if smod=0, only one write is allowed. reset: test and bootstrap modes C 1; single chip and expanded modes C 0. 0 C no visibility of internal reads on external bus. 1 C data from internal reads is driven out on the external data bus. mrdy memory ready enable read: any time. write: any time. 0 C memory ready is disabled, port h bit 7 is general purpose i/o. 1 C memory ready is enabled, port h bit 7 is forced to be an input used as the mrdy line. external bus accesses will be stretched as long as this line is held low. nhalt enable halt function read: any time write: any time 0 C halt enabled (a logic low level detected on the halt pin will cause the part to go into the halt state at the completion of the present instruction). 1 C halt disabled.
MC68HC11G5 resets, interrupts and low power modes motorola 5-1 section 5 resets, interrupts and low power modes this section describes the internal and external resets and interrupts of the MC68HC11G5 and its two low power consumption modes. 5.1 resets the mcu can be reset in four ways: 1. an active-low input to the reset pin 2. a power-on-reset function 3. a clock monitor failure 4. a computer operating properly (cop) watchdog timer timeout the reset input circuitry includes a schmitt trigger which senses the reset line logic level. 5.1.1 reset pin the reset pin is used to reset the mcu and allow an orderly software startup procedure. when a reset condition is sensed, this pin is driven low by an internal device for four e-clock cycles, then released, and two e-clock cycles later it is sampled. if the pin is still low, it means that an external reset has occurred. if the pin is high, it implies that the reset was initiated internally by either the watchdog timer (cop) or the clock monitor. this method of differentiation between internal and external reset conditions assumes that the reset pin will rise to a logic one in less than two e-clock cycles once it is released, and that an externally generated reset should stay active for at least eight e-clock cycles. 5.1.2 power-on-reset (por) power-on-reset occurs when a positive transition is detected on v dd . this reset is used strictly for power turn-on conditions and should not be used to detect any drop in the power supply voltage. if the external reset pin is low at the end of the power-on-reset delay time, the processor remains in the reset state until reset goes high.
motorola resets, interrupts and low power modes MC68HC11G5 5-2 5.1.3 computer operating properly (cop) reset the mcu contains a watchdog timer which automatically times out unless it is reset within a specific time by a program reset sequence. if the cop watchdog timer is allowed to timeout, a reset is generated which drives the reset pin low to reset the mcu and the external system. the cop reset function can be enabled by programming the nocop control bit in the system configuration register (config). once programmed, this control bit remains set (or cleared), even when no power is applied, and the cop function is enabled or disabled independent of resident software. protected control bits cr0 and cr1 in the configuration options register (option) allow the user to select one of four cop timeout periods. table 5-1 shows the relationship between cr0 and cr1 and the timeout period for various system clock frequencies. table 5-1. cop timeout periods cr1 cr0 ? e 2 15 divided by xtal = 2 23 timeout ? 0 / + 15.6 ms xtal = 8.0 mhz timeout ? 0 / + 16.4 ms xtal = 4.9152 mhz timeout 0 / + 26.7 ms xtal = 4.0 mhz timeout 0 / + 32.8 ms xtal = 3.6864 mhz timeout ? 0 / + 35.6 ms 0 0 1 15.625 ms 16.384 ms 26.667 ms 32.768 ms 35.556 ms 0 1 4 62.5 ms 65.536 ms 106.67 ms 131.07 ms 142.22 ms 1 0 16 250 ms 262.14 ms 426.67 ms 524.29 ms 568.89 ms 1 1 64 1 s 1.049 s 1.707 s 2.1 s 2.276 s e = 2.1 mhz 2.0 mhz 1.2288 mhz 1.0 mhz 921.6 khz the sequence for resetting the watchdog timer is as follows: 1) write $55 to the cop reset register (coprst) 2) write $aa to the cop reset register (coprst) both writes must occur in this sequence prior to the timeout, but any number of instructions can be executed between the two writes. 5.1.4 clock monitor reset the mcu contains a clock monitor circuit which measures the e-clock frequency. the clock monitor function is enabled by the cme control bit in the option register. upon detection of a slow or absent clock, the clock monitor circuit (if enabled by cme = 1) will cause a system reset to be generated. if the e-clock input rate is above approximately 200 khz, then the clock monitor does not generate a reset. if the e-clock is lost or its frequency falls below 10 khz, then a reset is generated, and the reset pin is driven low to reset the external system.
MC68HC11G5 resets, interrupts and low power modes motorola 5-3 special considerations are needed when using stop and the clock monitor in the same system. since the stop function causes the clocks to be halted, the clock monitor function will generate a reset sequence if it is enabled prior to the stop mode being entered. for systems which do not expect or want a stop function, this interaction can be useful to detect the unauthorized execution of a stop instruction which could not be detected by the cop watchdog system. on the other hand, in systems which utilise both the stop and clock monitor functions, this interaction means that the cme bit must be written to zero just prior to executing a stop instruction and should be written back to one as soon as the mcu resumes execution. 5.1.5 configuration options register (option) the bits in this register control certain configuration options, most of which can be changed only during the first 64 cycles after reset in normal operating modes. adpu csel irqe dly cme 0 cr1 cr0 option $ 1 039 7 6 5 4 3 2 1 0 0 0 0 1 0 0 0 0 reset: read: any time. write: bits 3, 6, and 7 may be written at any time. bits 0, 1, 4, and 5 may be written once only in the normal operating modes, and only during the first 64 cycles after reset. after this time the bits are read-only in the normal operating modes (smod = 0). in the special test and bootstrap modes (smod = 1), writes are always permitted. reset: $10. adpu ?a/d power up 0 a/d system powered down to save supply current. 1 a/d system powered up (allow about 100 m s for stabilization). csel clock select this bit should be set to one if the e-clock is less than 1 mhz. 0 C a/d uses the system e-clock (must be 1.0 mhz or greater). 1 C a/d uses an internal r-c clock source (about 1.5 mhz). irqe irq select edge sensitive only 0 C irq configured for low level recognition. 1 C irq configured to respond only to falling edges. dly enable oscillator start-up delay on exit from stop 0 C no stabilization delay imposed on exit from stop mode. 1 C a stabilization delay is imposed before processing resumes after stop. this bit is set during reset and controls whether or not a relatively long stabilization delay is imposed before processing can resume after a stop period. if an external clock signal
motorola resets, interrupts and low power modes MC68HC11G5 5-4 is supplied, this delay can be inhibited so that processing can be resumed within a few cycles of a wake-up from stop mode. when dly is set, a 4064 e-clock cycle delay is imposed to allow oscillator stabilization. cme clock monitor enable 0 C clock monitor disabled; a slow clock may be used. 1 C slow or stopped clocks will cause a clock failure reset sequence. in order to use both stop and the clock monitor, the cme bit should be written to zero prior to executing a stop instruction and rewritten to one after recovery from stop. cr1 and cr0 cop timer rate select bits the cop system is driven by a constant frequency of e divided by 215. cr1 and cr0 specify an additional divide-by factor to arrive at the cop timeout rate (see table 5-1). 5.1.6 state after reset the mcu mode is a function of the state of the two mode select pins. enable bits for the rom and the cop system are contained in the config register, which is initialized during reset, and are dependent on the mode which has been selected. in the single chip, bootstrap and test modes, the rom is on; in expanded mode the rom is off. in the single chip and expanded modes the cop is on; in bootstrap and test modes the cop is off. the remainder of the system configuration is controlled via registers. most of these registers and control bits are forced to a specific state during reset. if a user requires a different configuration, he must write different information into these registers. most of the configuration state after reset is independent of the mcu mode selected. those features which are specifically dependent on the mode are described in the following paragraphs. cpu the cpu fetches the restart vector from $fffe, $ffff ($bffe, $bfff in bootstrap mode or test mode) during the first two cycles after reset and begins executing instructions. the stack pointer and other cpu registers are indeterminate immediately after reset, except for the x and i interrupt mask bits in the ccr, which are set so that interrupt requests will be masked, and the s bit, also in the ccr, which is set so that the stop instruction is disabled. memory map immediately after reset the internal memory map of the MC68HC11G5 has 16 kilobytes of rom located at the top of memory from $c000 C $ffff (except in expanded mode where the rom is disabled and these bytes are external accesses), 512 bytes of ram located at the bottom of memory ($0000 C $01ff) and 128 bytes of internal register and i/o space located at ($1000 C $107f). if the bootstrap mode is selected, the memory map is the same except for the addition of a small internal bootstrap rom which is located at $bf00 C $bfff. when a vector fetch occurs in bootstrap mode, the a14 bit is forced low so that the vectors in the bootstrap rom are selected. in the test mode, a14 is also forced low during vector fetches but the bootstrap rom is not enabled so vectors are fetched from external memory located at $bfc0 C $bfff. parallel i/o if reset in an expanded mode, the pins used by the parallel i/o functions are dedicated to the expansion bus and the parallel i/o functions become externally accessed functions to allow emulation. if reset in single chip mode, the cwom bit is initialized to zero (port c not wired-or
MC68HC11G5 resets, interrupts and low power modes motorola 5-5 mode). port c is initialized as an input port (ddrc = $00). ports b and f are general purpose output ports with all bits initialized to zero. r/w outputs a logic high level all the time. ports a, d, g, h, and j are configured as general purpose high-impedance inputs. port e pins are configured as inputs. timer the timer system is initialized during reset to a count of $0000. the prescaler bits are cleared (to zero) so that the count rate equals the e-clock rate. all output compare registers are initialized to $ffff to guarantee the maximum time before any successful compare. all input capture registers are indeterminate after reset. the oc1m register is cleared so successful oc1 compares will not affect any i/o pins. the other output compare functions are configured so as not to affect any i/o pins on successful compares. all input capture edge detector circuits are configured for capture disabled operation. the timer overflow interrupt flag and all timer function interrupt flags are cleared and all timer interrupts are disabled by their mask bits being cleared. real time interrupt the real time interrupt flag is cleared and automatic hardware interrupts are masked by the rtii bit being clear. the rate control bits rtr1, rtr0 are cleared to zero, thus selecting the shortest real time interrupt period. pulse accumulator the pulse accumulator system is disabled at reset. the paif and paovf flags are cleared to indicate no pulse accumulator interrupts pending. the paii and paovi interrupt enable bits are cleared to inhibit pulse accumulator interrupts. cop the cop watchdog system is enabled if the nocop control bit is a zero and disabled if nocop is one. the cop rate is set for the shortest duration timeout. if a different rate is required then it must be initialized within 64 e-clock cycles after reset. sci serial i/o the reset condition of the sci system is independent of the operating mode. at reset, the sci baud rate is indeterminate and must be established by a software write to the baud register (note that in bootstrap mode software in the bootstrap rom initializes the sci system and the baud rate). the frame format is configured for 8-bit data (m = 0). all transmit and receive interrupts are masked and both the transmitter and receiver are disabled (turned off) so the port pins associated with the sci default to being general purpose i/o lines. the send break and receiver wake-up functions are disabled. although the wake-up function is disabled (rwu = 0), the wake control bit is initialized to 0, thus selecting the idle line mode of wake-up. the tdre and tc status bits are both set to one indicating that there is no transmit data in either the transmit data register or the transmit serial shift register. the receiver related status bits rdrf, idle, or, nf, and fe are all cleared by reset. spi serial i/o the spi system is disabled during reset. the port pins associated with this function default to being general purpose i/o pins. a to d the a/d system is disabled by reset. both the adpu and csel bits are cleared to zero, disabling the analog circuitry of the a/d and the internal r-c oscillator. the bits in the adctl control register are indeterminate following reset. in any case, a write must be performed to this register in order to initiate a conversion sequence. system the highest priority i interrupt defaults to the external interrupt pin irq by psel4 C psel0 being set equal to 00110. the rboot, smod, and mda bits in the hprio register reflect the status of the modb and moda inputs at the rising edge of reset. the internal read visibility
motorola resets, interrupts and low power modes MC68HC11G5 5-6 control bit (irv) in the opt2 register is initialized to zero in normal modes to protect the system from potential bus conflict with the external system. irv is initialized to one if the MC68HC11G5 is reset in a special mode (smod = 1) to enable internal read visibility for test and debug purposes. the irq pin is configured for level sensitive operation (for wired-or systems). the dly control bit in the option register is set to specify that an oscillator start-up delay will be imposed upon recovery from stop mode. the clock monitor system is disabled by the cme bit in the option register being set to zero. when the system is reset in a special mode (smod = 1), the disr control bit in the test1 register is initialized to logic one so that cop and clock monitor failures will not generate a reset. in the normal modes (smod = 0), the disr control bit is cleared to allow normal operation of the cop and clock monitor systems. 5.2 interrupts excluding reset type interrupts, the MC68HC11G5 has 22 hardware interrupt sources and one software interrupt source. these interrupts can be divided into two categories, maskable and non- maskable. twenty of the interrupt sources can be masked using the i bit in the condition code register (ccr). all the on-chip hardware interrupts are individually masked by local control bits. the software interrupt (swi) is non-maskable. the external input to the xirq pin is considered a non- maskable interrupt because it cannot be masked by software once it is enabled. however, it is masked during reset and upon receipt of an interrupt signal at the xirq pin. illegal opcode is also a non-maskable interrupt. 5.2.1 interrupt vector assignments in all normal operating modes the interrupt vectors are located at the top of the address space ($ffc0 through $ffff). in the bootstrap mode the interrupt vectors are located at $bfc0 through $bfff so that they exist in the internal bootstrap rom. in the special test mode the interrupt vectors also reside at $bfc0 C $bfff but the internal bootstrap rom is disabled so vectors are fetched from external memory. table 5-2 provides a list of the interrupts with a vector location in memory for each, as well as the condition code register and control bits that mask each interrupt. figure 5-1 shows the interrupt stacking order.
MC68HC11G5 resets, interrupts and low power modes motorola 5-7 table 5-2. interrupt vector masks and assignments vector address interrupt source masked by priority (1= high) ffc0, ffc1 * * ffca, ffcb ffcc, ffcd ffce, ffcf reserved * * reserved event 2 event 1 i bit i bit 22 21 ffd0, ffd1 ffd2, ffd3 ffd4, ffd5 ffd6, ffd7 timer overflow 2 timer oc7/ic6 timer oc6/ic5 sci serial system i bit i bit i bit i bit 18 16 15 24 ffd8, ffd9 ffda, ffdb ffdc, ffdd ffde, ffdf spi serial transfer complete pulse accumulator input edge pulse accumulator overflow timer overflow 1 i bit i bit i bit i bit 23 20 19 17 ffe0, ffe1 ffe2, ffe3 ffe4, ffe5 ffe6, ffe7 timer oc5/ic4 timer output compare 4 timer output compare 3 timer output compare 2 i bit i bit i bit i bit 14 13 12 11 ffe8, ffe9 ffea, ffeb ffec, ffed ffee, ffef timer output compare 1 timer input capture 3 timer input capture 2 timer input capture 1 i bit i bit i bit i bit 10 9 8 7 fffo, fff1 fff2, fff3 fff4, fff5 fff6, fff7 real time interrupt swi i bit i bit x bit none 6 5 4 * fff8, fff9 fffa, fffb fffc, fffd fffe, ffff illegal opcode trap cop failure (reset) cop clock fail monitor (reset) none none none none * 3 2 1 irq (external pin) xirq pin ( pseudo nmi) reset
motorola resets, interrupts and low power modes MC68HC11G5 5-8 stack sp pcl ?sp before interrupt sp ?1 pch sp ?2 iyl sp ?3 iyh sp ?4 ixl sp ?5 ixh sp ?6 acca sp ?7 accb sp ?8 ccr sp ?9 sp after interrupt figure 5-1. interrupt stacking order 5.2.2 software interrupt (swi) swi is an instruction rather than a prioritized asynchronous interrupt source. it is non-maskable. in one sense it is lower in priority than any source, because once an interrupt sequence has begun, swi cannot override it. in another sense, it is higher in priority than any source except reset, because once the swi opcode is fetched, no other source can be serviced until after the first instruction in the swi service routine has been executed. swi causes the i mask bit in the ccr to be set. 5.2.3 illegal opcode trap since not all possible opcodes or opcode sequences are defined, an illegal opcode detection circuit has been included in the MC68HC11G5. when an illegal opcode is detected, an interrupt is requested to the illegal opcode vector. it is non-maskable and the illegal opcode vector should never be left uninitialized. 5.2.4 real time interrupt the real time interrupt (or periodic interrupt) feature on the MC68HC11G5 is configured and controlled by three bits in the pactl register (rtr2, rtr1 and rtr0 which select one of six interrupt rates based on the mcu e-clock), an interrupt status flag (rtif) in the tflg2 register, and a mask bit (rtii) in the tmsk2 register (which enables/inhibits hardware interrupts based on the rtif flag bit). after reset, one entire real time interrupt period will elapse before the rtif flag gets set for the first time. (see section 6: programmable timer, real time interrupt and pulse accumulator for more information on the real time interrupt.)
MC68HC11G5 resets, interrupts and low power modes motorola 5-9 5.2.5 interrupt mask bits in condition code register on reset, both the x bit and the i bit in the ccr are set to inhibit all maskable interrupts and xirq. after minimum system initialization, software may clear the x bit by a tap instruction, thus enabling xirq interrupts. thereafter, software cannot set the x bit. thus, an xirq is effectively a non- maskable interrupt. since the operation of the i bit related interrupt structure has no effect on the x bit, the internal xirq pin remains effectively non-masked. in the interrupt priority logic, the xirq interrupt is a higher priority than any source that is maskable by the i bit. all i bit related interrupts operate normally with their own priority relationships. when an i bit related interrupt occurs, the i bit is automatically set by hardware after stacking the ccr byte. the x bit is not affected. when an x bit related interrupt occurs, both the x and the i bit are automatically set by hardware after stacking the ccr byte. a return from interrupt (rti) instruction restores the x and i bits to their pre-interrupt request state. 5.2.6 priority and masking structure interrupts obey a fixed hardware priority circuit to resolve simultaneous requests. however, one i bit related interrupt source may be elevated to the highest i bit priority position in the resolution circuit. six interrupt sources are not masked by the i bit in the condition codes register and have the fixed priority relationship: 1. reset 2. clock failure monitor 3. cop failure 4. illegal opcode 5. swi 6. xirq swi is actually an instruction and has highest priority other than reset in the sense that once the swi opcode is fetched, no other interrupt can be honoured until after the first instruction in the swi service routine has been executed. the scenario is similar for the illegal opcode. each of these sources is an input to the priority resolution circuit. the highest i bit masked priority input to the resolution circuit is assigned under software control (via the hprio register) to be connected to any one of the remaining i bit related interrupt sources. in order to avoid timing races the hprio register may only be written while the i bit related interrupts are inhibited (i bit in ccr set). an interrupt which is assigned to this high priority position is still subject to masking by any associated control bits or by the i bit in the ccr. the address from which the interrupt vector is fetched is not affected by assigning a source to this higher priority position.
motorola resets, interrupts and low power modes MC68HC11G5 5-10 all interrupt sources from on-chip peripherals have software programmable interrupt mask bits which may be used to selectively inhibit automatic hardware response to each interrupt source. in addition the x and i bits in the condition code register act as class inhibit masks to inhibit all sources in the x bit and/or i bit class. figures 5-2, 5-3 and 5-4 summarize the priority structure and additional mask conditions that lead to the recognition of interrupt requests in the MC68HC11G5. 1b 1a highest lowest power-on reset (por) external reset clock monitor fail (with cme = 1) cop watchdog timeout (with nocop = 0) load program counter with contents of $fffa, fffb (vector fetch) delay 4064 e cycles set s, x, and i bits in ccr reset mcu hardware begin an instruction sequence stack cpu registers set x and i bits fetch vector $fff4, fff5 xirq pin low ? yes no yes no x bit in ccr set ? load program counter with contents of $fffc, fffd (vector fetch) load program counter with contents of $fffe, ffff (vector fetch) priority figure 5-2. processing flow out of resets
MC68HC11G5 resets, interrupts and low power modes motorola 5-11 any i bit interrupt pending ? stack cpu registers set x and i bits fetch vector $fff6, fff7 yes no i bit in ccr set ? 1a 1b yes no stack cpu registers set x and i bits fetch vector $fff8, fff9 fetch opcode stack cpu registers stack cpu registers set i bit execute this instruction restore cpu registers from stack resolve interrupt priority and fetch vector for highest pending source (see figure 5-3) start next instruction sequence rti ? swi ? wai ? legal opcode ? interrupt yet ? yes no no yes no yes no yes yes no figure 5-2. processing flow out of resets (contd)
motorola resets, interrupts and low power modes MC68HC11G5 5-12 no no no no no no no no no no no 2a begin set x bit in ccr fetch vector $fff4, fff5 x bit in ccr set ? yes xirq pin low ? yes no fetch vector highest priority interrupt ? yes irq ? yes fetch vector $fff2, fff3 fetch vector $fff0, fff1 rtii = 1 ? yes real-time interrupt ? yes no fetch vector $ffee, ffef ic1i = 1 ? yes timer ic1f ? yes no fetch vector $ffec, ffed ic2i = 1 ? yes timer ic2f ? yes no fetch vector $ffea, ffeb ic3i = 1 ? yes timer ic3f ? yes no fetch vector $ffe8, ffe9 oc1i = 1 ? yes timer oc1f ? yes no 2b fetch vector $ffe6, ffe7 oc2i = 1 ? yes timer oc2f ? yes no fetch vector $ffe4, ffe5 oc3i = 1 ? yes timer oc3f ? yes no fetch vector $ffe2, ffe3 oc4i = 1 ? yes timer oc4f ? yes no figure 5-3. interrupt priority resolution
MC68HC11G5 resets, interrupts and low power modes motorola 5-13 no no no no no no no no no no no fetch vector $ffe0, ffe1 4/5i = 1 ? yes timer 4/5f ? yes no fetch vector $ffde, ffdf to1i = 1 ? yes timer to1f ? yes no fetch vector $ffdc, ffdd paovi = 1 ? yes pulse accumulator paovf ? yes no fetch vector $ffda, ffdb paii = 1 ? yes yes no fetch vector $ffd8, ffd9 spie = 1 ? yes spif or modf ? yes no fetch vector $ffd6, ffd7 sci serial ? (see figure 5-4) yes 2a 2b end fetch vector $fff2, fff3 pulse accumulator paif ? spurious interrupt ?take irq vector fetch vector $ffd4, ffd5 5/6i = 1 ? yes timer 5/6f ? yes no fetch vector $ffd2, ffd3 6/7i = 1 ? yes timer 6/7f ? yes no fetch vector $ffd0, ffd1 to2i = 1 ? yes timer to2f ? yes no fetch vector $ffce, ffcf ev1i = 1 ? yes event counter ev1f ? yes no fetch vector $ffcc, ffcd ev2i = 1 ? yes yes no event counter ev2f ? figure 5-3. interrupt priority resolution (contd)
motorola resets, interrupts and low power modes MC68HC11G5 5-14 begin rdrf = 1 ? yes no or = 1 ? yes no rie = 1 ? yes no no valid sci request yes ?valid sci request re = 1 ? yes no tdre = 1 ? yes no tie = 1 ? yes no te = 1 ? yes no tc = 1 ? yes no tcie = 1 ? yes no idle = 1 ? yes no ilie = 1 ? yes no re = 1 ? yes no figure 5-4. interrupt source resolution within sci
MC68HC11G5 resets, interrupts and low power modes motorola 5-15 5.2.7 highest priority i interrupt and miscellaneous register (hprio) rboot smod mda psel4 psel3 psel2 psel1 psel0 hprio $ 1 03c 7 6 5 4 3 2 1 0 0 0 1 1 0 reset: rboot read bootstrap rom read: any time. write: only while smod = 1 (test or bootstrap modes). reset: set in bootstrap mode, cleared in all other modes. 0 C bootstrap rom disabled and not in memory map. 1 C bootstrap rom enabled in memory map at $bf00 through $bfff. smod and mda special mode select and mode select a read: any time. write: smod may only be written to a 0. mda may be written any time while smod = 1, but mda may only be written once while smod = 0. reset: these bits reflect the status of the modb and moda input pins at the rising edge of reset. an interpretation of the values of smod and mda is shown in table 5-3. note: smod cannot be written to a logic one after being cleared. table 5-3. special mode select and mode select a table input pins latched at reset moda modb mode selected smod mda 0 1 single chip 0 0 1 1 expanded non-multiplexed 0 1 0 0 bootstrap 1 0 1 0 test 1 1
motorola resets, interrupts and low power modes MC68HC11G5 5-16 psel4, psel3, psel2, psel1, psel0 priority select bits 4 C 0 read: any time. write: only while i bit in ccr is set (interrupts inhibited). these five bits are used to specify one i bit related interrupt source which will become the highest priority i bit related source (see table 5-4). table 5-4. priority select bits table psel4 psel3 psel2 psel1 psel0 interrupt source promoted 0 0 0 x x reserved (default to irq ) 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 0 1 0 1 reserved (default to irq ) reserved (default to irq ) irq (external pin or parallel i/o) real time interrupt 0 0 0 0 1 1 1 1 0 0 0 0 0 0 1 1 0 1 0 1 timer input capture 1 timer input capture 2 timer input capture 3 timer output compare 1 0 0 0 0 1 1 1 1 1 1 1 1 0 0 1 1 0 1 0 1 timer output compare 2 timer output compare 3 timer output compare 4 timer oc5/ic4 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 1 timer overflow 1 pulse accumulator overflow pulse accumulator input edge spi serial transfer complete 1 1 1 1 0 0 0 0 1 1 1 1 0 0 1 1 0 1 0 1 sci serial system timer oc6/ic5 timer oc7/ic6 timer overflow 2 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 0 1 0 1 event counter 1 event counter 2 reserved (default to irq ) reserved (default to irq ) 1 1 1 x x reserved (default to irq )
MC68HC11G5 resets, interrupts and low power modes motorola 5-17 5.3 low power modes the MC68HC11G5 has a wait mode to suspend processing and reduce power consumption to an intermediate level. the MC68HC11G5 also offers a stop mode which turns off all on-chip clocks and reduces power consumption to an absolute minimum while retaining the contents of all 512 bytes of ram. 5.3.1 wait wait mode is invoked by executing the wai opcode. the cpu registers are stacked and cpu processing is suspended until a qualified interrupt is detected. the interrupt can be an external irq, an xirq, or any of the internally generated interrupts such as the timer or serial interrupts. the on-chip crystal oscillator remains active throughout the wait standby period. the reduction of power in wait mode depends on how many internal clock signals driving on-chip peripheral functions can be shut down. the cpu is always shut down in wait mode. the free- running timer system is shut down in wait mode if, and only if, the i bit is set to one and the cop system is disabled by nocop being set to one. several other systems may also be in a reduced power consumption state depending upon the state of software controlled configuration control bits. power consumption by the a/d is not significantly affected by wait mode. however, the a/d current can be eliminated by writing the adpu bit to zero. the spi system is enabled or disabled by the spe control bit. the sci transmitter is enabled or disabled by the te bit, and the sci receiver is enabled or disabled by the re bit. the power consumption in wait mode is very dependent, therefore, on the particular application. 5.3.2 stop stop mode is invoked by executing the stop instruction while the s bit in the ccr is equal to zero. if the s bit is not zero then the stop opcode is treated as a no-op (nop). stop mode offers minimum power consumption because all clocks including the crystal oscillator are stopped while in this mode. to exit the stop mode and resume normal processing, a logic low level must be applied to one of the external interrupts (irq or xirq) or to the reset pin. a pending edge- triggered irq can also bring the cpu out of stop mode. since all clocks are stopped in this mode, all internal peripheral functions also stop. the data in the internal ram is retained as long as vdd power is maintained. the cpu state and i/o pin levels are static and are unchanged by the stop mode. therefore, when an interrupt comes to restart the system, the MC68HC11G5 resumes processing as if there were no interruption. if reset is used to restart the system a normal reset sequence results where all i/o pins and functions are also restored to their initial states. in order for the irq pin to be used as a means of recovering from the stop mode, the i bit in the ccr must be clear (irq not masked). the xirq input may be used to wake up the mcu from stop regardless of the state of the x bit in the ccr, although the recovery sequence depends on the state of the x bit. if x is set to zero (xirq not masked), the mcu will start up beginning with the stacking
motorola resets, interrupts and low power modes MC68HC11G5 5-18 sequence leading to normal service of the xirq request. if x is set to one (xirq masked or inhibited), then processing will continue with the instruction which immediately follows the stop instruction, and no xirq interrupt service will be requested or pending. since the oscillator is stopped in stop mode, a restart delay may be imposed to allow oscillator stabilization upon leaving the stop mode. if the internal oscillator is being used, this delay is required; however,if a stable external oscillator is being used, the dly control bit may be used to by-pass this start-up delay. the dly control bit is set by reset and may be optionally cleared during initialization. if the dly equal to zero option is used to avoid start-up delay on recovery from stop, then reset should not be used as the means of recovering from stop since this will cause dly to be set again by reset and the restart delay will be imposed. this same delay also applies to power- on-reset (regardless of the state of the dly control bit) but does not apply to a reset while the clocks are running.
MC68HC11G5 programmable timer motorola 6-1 section 6 programmable timer, real time interrupt and pulse accumulator this section describes the 16-bit programmable timer, the real time interrupt and the pulse accumulator system. in order to reduce the overhead required to service interrupts, the three timer overflows and the other twelve timer functions each have their own interrupt vector, and each of these interrupts is independently maskable. 6.1 programmable timer the timer system on the MC68HC11G5 has been derived from the original mc68hc11a8 timer. there are four fixed output compares (oc), three fixed input captures (ic) and three programmable input captures/output compares (ic/oc). secondly, there are two separate time-of-day type 16-bit free-running counters, each with its own prescaler. the first counter is associated with the four fixed output compares and two of the programmable input capture/output compares. the second counter is associated with the three fixed input captures and one programmable input capture/output compare. 6.1.1 counters the two 16-bit counters (tcnt1 and tcnt2) are clocked by the outputs of separate 3-stage prescalers (divide by 1, 2, 4, or 8) which are in turn driven by the mcu e-clock. (note that these prescaler values have been changed from the original mc68hc11a8 to include divide-by-2 and to exclude divide-by-16.) the second counter can also be driven by an external clock instead of the internal clock. an external clock cannot be used with counter 1 because this counter chain is also used to time the real time interrupt and the cop circuit. in addition, counter 2 can be cleared by software. this is accomplished by writing any value to the counter register. this forces a hardware reset of the counter, regardless of the value written. this feature is not available on counter 1 because counter 1 is also used to time the real time interrupt and the cop circuit.
motorola programmable timer MC68HC11G5 6-2 6.1.2 prescalers there are two prescalers, one for each of the timer counters. all of the prescaler select bits are included in one register (tpre). this allows the user to set both prescalers simultaneously so that both counters may be kept synchronized. the external clock edge selects for counter 2 are also included in this register. each prescaler is a 3-stage divider with the e-clock as its input, and each stage divides by two. the prescaler output is selectable as e, e/2, e/4, or e/8. after reset, the MC68HC11G5 is configured to use the e-clock as the input to both counters. initialization software may optionally reconfigure counter 1 to use one of the three prescale taps so that the e-clock is divided by 2, 4, or 8 before driving the free running counter. initialization software may, at the same time, optionally reconfigure counter 2 to use one of the three prescale taps so that the e-clock is divided by 2, 4, or 8 before driving the free-running counter, and may select the falling, rising or both edges of an external clock. if counter 2 uses the external clock, then the prescaler bits have no effect. 6.1.3 input capture functions the fixed input capture registers (tic1 C tic3) are 16-bit read-only registers which are not affected by reset and are used to latch the value of the free-running counter when a defined transition is sensed by the corresponding input capture edge detector. they optionally cause an interrupt in response to a detected edge event on an input pin. pairs of bits in the tctl2 register allow the user to specify that input capture will occur on rising edges only, falling edges only, rising and falling edges or to inhibit captures completely. registers tmsk1 and tflg1 provide interrupt enable and interrupt flag bits, respectively input captures ic1 C ic3 are associated with port a, bits 2 C 0, respectively. 6.1.4 output compare functions the fixed output compare registers (toc1 C toc4) are 16-bit read/write registers which are initialized to $ffff by reset and can be used for several purposes. possible applications include controlling an output waveform and indicating when a period of time has elapsed. the output compare registers are unique in that all bits are readable and writable and are not altered by the timer hardware (except during reset). if an output compare function is not utilized, the unused registers may be used simply as storage locations. output compares oc1 C oc4 are associated with port a bits 7 C 4, respectively. the output compare functions referred to above cause an output action and/or an interrupt when there is a match between a 16-bit output compare register and the free-running counter. at any time the bits controlled by the output compare functions may be read to determine the current state of the output pin. three of the fixed output compare functions (oc2, oc3 and oc4) and all of the programmable ones allow software to specify that the corresponding output pin should toggle, be set to one, be cleared to zero, or be disconnected from the output pin logic. this is controlled using the omx and oml bits in the timer control registers tctl1 and tctl3.
MC68HC11G5 programmable timer motorola 6-3 unlike the other output compare functions, oc1 can automatically affect any or all of the port a output pins associated with oc2 C oc5 (with oc5/ic4 configured for output compare), as a result of a successful compare between the oc1 register and the 16-bit free running counter. two 5-bit registers are used in conjunction with this function, the output compare 1 mask register (oc1m) and the output compare 1 data register (oc1d). the oc1m register specifies bit-for-bit which port a lines (bits 3 C 7) are to be affected and the oc1d register specifies what data is to be placed on the affected lines. by configuring the system so that both oc1 and another output compare function both control the same output line, output pulses can be generated with durations as short as one free running counter count. since the four other output compare functions (oc2 C oc5) optionally affect four bits of port a and the pulse accumulator optionally uses bit 7 of port a, there is an overlap of these functions with the oc1 output compare function. pins are made available to the oc1 function when other timer functions are not used or are used in a manner that does not require use of the i/o pin. a write-only register (cforc) is provided to allow the equivalent of a forced output compare function. writing a one to any bit in this register immediately has the same effect as a successful comparison on the corresponding output compare function. in some cases the values in the output compare register and the output action control bits must be changed after each successful comparison to control an output waveform or to establish a new elapsed timeout. due to the prescaler, the counter may not change value on each cycle of the e-clock and the comparison may be true for several consecutive e-clock cycles. in order to avoid multiple output actions, the output action is permitted to occur only during the e-clock low time immediately following the cycle during which the match first became true. an interrupt can also accompany a successful output compare provided that the corresponding interrupt enable bit (ocxi) in the tmsk1 register is set. in this event, the corresponding interrupt flag bit (ocxi) in the tflg1 register will be set. after writing to the tocx registers most significant byte, the output compare function is inhibited for one e-clock cycle, to allow writing two consecutive bytes before making the next comparison. if both bytes of the register are to be changed, a double byte write instruction should be used in order to take advantage of the compare inhibit feature. mpu writes can be made to either byte of the output compare register without affecting the other byte. when a compare occurs, the output action is taken regardless of whether or not the output compare flag (ocxf) was previously set. 6.1.5 programmable input capture/output compares there are three programmable input capture/output compares. each channel has a 16-bit register (to5i4, to6i5, to7i6) associated with it which acts as either an output compare register or an input capture register depending on which is specified. oc5/ic4 and oc6/ic5 are associated with counter 1 and oc7/ic6 is associated with counter 2. the selection of output compare or input capture for these functions is controlled by the i4/o5 bit in the pactl register and the i5/o6
motorola programmable timer MC68HC11G5 6-4 and i6/o7 bits in the tctl4 register. output compare actions are controlled by bits in tctl1, tctl3 and cforc. input capture control is via registers tctl2 and tctl3. registers tmsk1 and tmsk2 provide interrupt enable bits for input capture and output compare functions. tflg1 and tflg2 provide corresponding interrupt flag bits. 6.2 real time interrupt the real time interrupt feature on the MC68HC11G5 is configured and controlled using three bits (rtr2, rtr1 and rtr0) in the pactl register to select one of eight interrupt rates. the rtii bit in the tmsk2 register enables the interrupt capability. every timeout causes the rtif bit in tflg2 to be set, and if rtii is set, an interrupt request is generated. after reset, one entire real time interrupt period elapses before the rtif flag is set for the first time. 6.3 pulse accumulator the pulse accumulator is an 8-bit read/write counter (pacnt) which can operate in either of two modes (external event counting or gated time accumulation) depending on the state of the pamod control bit in the pactl register. in the event counting mode, the 8-bit counter is clocked to increasing values by an external pin input. the maximum clocking rate for the external event counting mode is e divided by 2. in the gated time accumulation mode a free-running e/64 clock drives the 8-bit counter, but only while the external pai input pin is in a selected state. although port a bit 7 would normally be configured as an input when being used for the pulse accumulator, it still drives the pulse accumulator system even when it is configured for use in its other functions. ddra bit 7 controls the data direction of port a bit 7. when ddra bit 7 is zero, port a bit 7 is an input only pin, unless oc1 is configured to control the pin. when ddra bit 7 is a one, port a bit 7 is an output but is still connected to the pulse accumulator input. paen in the pactl register enables/disables the pulse accumulator. pedge in the pactl register selects the active edge of the input signal on the pai pin. the paovf status bit in the tflg2 register is set when the counter overflows from $ff to $00. the paovi mask bit in the tmsk2 register controls whether or not a hardware interrupt will be generated when the paovf flag bit is set. the paif flag bit in the tflg2 register is set when an active edge is detected on the pai input pin. the paii mask bit in the tmsk2 register controls whether or not a hardware interrupt will be generated when the paif status bit is set.
MC68HC11G5 programmable timer motorola 6-5 6.4 timer, rti and pulse accumulator registers 6.4.1 count registers (tcnt1 and tcnt2) bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 tcnt1 $ 1 00e 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: 0 0 0 0 0 0 0 0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 $ 1 00f read: any time. write: has no effect for smod = 0; forces to $fff8 for smod = 1. reset: $0000. bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 tcnt2 $ 1 052 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: 0 0 0 0 0 0 0 0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 $ 1 053 read: any time. write: forces to $0000 for smod = 0; forces to $fff8 for smod = 1. reset: $0000. tcnt1 is associated with oc1 ?oc4, oc5/ic4 and oc6/ic5. note thatdue to the periodic interrupt and cop timer also using this counter as their clock source, an external clock cannot be used to drive this timer counter. tcnt2 is associated with ic1 ?ic3 and oc7/ic6. this counter differs from counter 1 in two ways: it can be driven by an external clock; and it can be reset under software control. a full counter read should first address the most significant byte. reading this address causes the least significant byte to be latched into a buffer for the next cpu cycle so that a double byte read will return the full 16-bit state of the counter at the time of the most significant byte read cycle. this buffer is not affected by reset and is accessed when reading the least significant byte of the counter. for double byte read instructions, these two accesses occur on consecutive bus cycles. the buffer is transparent except for the cycle following a most significant byte read so that reads of the least significant byte alone will return the current state of the counter. software can read the counter at any time without affecting its value. note that the counter is clocked and read during opposite half cycles of the e-clock. both counters are cleared to $0000 during reset. in the normal operating modes (smod = 0), writing to tcnt2 causes tcnt2 to be reset to $0000, whereas writing to tcnt1 has no effect. in the test and bootstrap modes only (smod = 1), any write to either counter? most significant byte causes
motorola programmable timer MC68HC11G5 6-6 the counter to be preset to $fff8 regardless of the data written. this preset capability is intended only for factory testing. because its width is 16 bits, the value in the free running counter repeats every 65,536 counts (prescaler timeouts). when the count changes from $ffff to $0000 the timer overflow flag bit (toxf), in the tflg2 register, is set. a timer overflow interrupt can be enabled by setting its interrupt enable bit (toxi), in the tmsk2 register. 6.4.2 prescaler register (tpre) tedgb tedga pr2b pr2a 0 0 pr1b pr1a tpre $ 1 058 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: read: any time. write: if smod = 0, may be written only once during the first 64 cycles. after this time, the bits become read-only. if smod = 1, writing is always permitted. tedgb, tedga timer external clock edge select these two bits determine which edge(s) of the external clock will cause timer counter 2 to increment. the external clock comes in via port j, bit 0. tedgb tedga configuration 0 0 counter 2 uses the internal clock and prescaler 0 1 count on rising edges only 1 0 count on falling edges only 1 1 count on any edge (rising or falling) note: the maximum frequency of the input clock must be less than e/2 when counting on only rising or falling edges and must be less than e/4 when counting on both edges.
MC68HC11G5 programmable timer motorola 6-7 pr2b, pr2a timer prescaler select these bits specify the number of divide-by-2 stages to be inserted between the e-clock and timer counter 2. note: these bits have no effect if the external clock is selected (tedgb or tedga = 1). pr2b pr2a prescale factor 00 1 01 2 10 4 11 8 pr1b, pr1a timer prescaler select these bits specify the number of divide-by-2 stages to be inserted between the e-clock and timer counter 1. pr1b pr1a prescale factor 00 1 01 2 10 4 11 8 6.4.3 input capture registers (tic1 C tic3) bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 tic1 $ 1 010 7 6 5 4 3 2 1 0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 $ 1 011 bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 tic2 $ 1 012 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 $ 1 013 bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 tic3 $ 1 014 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 $ 1 015
motorola programmable timer MC68HC11G5 6-8 read: any time. write: has no meaning or effect. reset: indeterminate (not initialized). these registers are used to latch the value of timer counter 2 when a defined transition is sensed by the corresponding input capture edge detector. the result obtained by an input capture corresponds to the value of the counter one cycle after the transition which triggered the edge detection logic. this delay is required for internal synchronization. after a read of the most significant byte of the register, counter transfer is inhibited during the next e-clock cycle. during double byte reads, this inhibited transfer will occur between consecutive read cycles of the most and least significant bytes. 6.4.4 output compare registers (toc1 C toc4) bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 toc1 $ 1 016 7 6 5 4 3 2 1 0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 $ 1 017 bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 toc2 $ 1 018 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 $ 1 019 bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 toc3 $ 1 01a bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 $ 1 01b bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 toc4 $ 1 01c bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 $ 1 01d read: any time. write: any time. reset: $ffff a write to a high order byte inhibits the compare for the next e-clock cycle. when the tocx register matches the tcnt1 register, the ocxf bit in the tflg1 register is set and the specified output action takes place. all output compare registers have a separate dedicated comparator for comparing against the free running counter. if a match is found, the corresponding output compare flag bit (ocxf) is set and a specified action is automatically taken. for output compare functions oc2, oc3 and oc4, the automatic action is controlled by pairs of bits in the tctl1 control register. each pair of control bits is encoded to specify the output action to be taken as a result of a successful ocx compare. output compare functions oc2, oc3 and oc4 are always associated with port a bits 6 C 4 respectively.
MC68HC11G5 programmable timer motorola 6-9 6.4.5 output compare 5/input capture 4 register (to5i4) this is a shared register which acts as the output compare oc5 register or as the input capture ic4 register depending on the state of the i4/o5 bit in the pactl register. this register is associated with timer counter 1 and with port a, bit 3. bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 to5i4 $ 1 01e 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: 0 0 0 0 0 0 0 0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 $ 1 01f read: any time. write: any time this register is configured for oc operation. reset: $ffff 6.4.6 output compare 6/input capture 5 register (to6i5) this is a shared register which acts as the output compare oc6 register or as the input capture ic5 register depending on the state of the i5/o6 bit in the tctl4 register. this register is associated with timer counter 1 and with port j, bit 1. bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 to6i5 $ 1 054 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: 0 0 0 0 0 0 0 0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 $ 1 055 read: any time. write: any time this register is configured for oc operation. reset: $ffff
motorola programmable timer MC68HC11G5 6-10 6.4.7 output compare 7/input capture 6 register (to7i6) this is a shared register which acts as the output compare oc7 register or as the input capture ic6 register depending on the state of the i6/o7 bit in the tctl4 register. this register is associated with timer counter 2 and with port j, bit 2. bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 to7i6 $ 1 056 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: 0 0 0 0 0 0 0 0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 $ 1 057 read: any time. write: any time this register is configured for oc operation. reset: $ffff there are both input control bits and output control bits associated with these functions. only the bits associated with the selected function (input or output) will affect the operation of the timer channel. 6.4.8 output compare 1 action mask register (oc1m) oc1m7 oc1m6 oc1m5 oc1m4 oc1m3 0 0 0 oc1m $ 1 00c 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: read: any time (bits 2 through 0 always return 0). write: any time (writes to bits 2 through 0 have no meaning or effect). reset: $00 (oc1 disconnected from port a logic). oc1m is used to specify which bits of port a (i/o and timer port) are to be affected as a result of a successful oc1 compare. the bits of oc1m correspond bit-for-bit with the bits of port a. for each bit to be affected by the successful oc1 compare, the corresponding bit in oc1m must be set to one. each port a line associated with an oc1mx bit which is set to one will be forced to be an output regardless of the state of the associated ddra bit. this does not change the state of the ddra bit.
MC68HC11G5 programmable timer motorola 6-11 6.4.9 output compare 1 action data register (oc1d) oc1d7 oc1d6 oc1d5 oc1d4 oc1d3 0 0 0 oc1d $ 1 00d 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: read: any time (bits 2 C 0 always return 0). write: any time (writes to bits 2 C 0 have no meaning or effect). reset: $00 oc1d is used to specify the data to be written to the affected bits of port a as the result of a successful oc1 compare. the bits of oc1d correspond bit-for-bit with the bits of port a (bits 3 C 7). when a successful oc1 compare occurs, for each bit that is set in oc1m, the corresponding data bit in oc1d is written to the corresponding bit of port a. if there is a conflicting situation where an oc1 compare and another output compare function occur during the same e-clock cycle, and both attempt to alter the same port a bit, the oc1 action will take priority. one reason for providing this special capability on oc1 is to allow control of multiple i/o pins automatically with a single output compare function. for example, if the oc2 and oc3 functions are being used for internal timing functions, their associated port a pins are free to be used for other purposes. these two pins could be controlled simultaneously as high speed timed outputs using the oc1 function by setting the two corresponding bits in the oc1m register to one. the special i/o pin control on the oc1 function also allows more than one output compare function to control a single i/o pin. for example, the oc1 function could be configured to affect only bit 3 of port a (by setting oc1m = $08). the oc5 function could set port a bit 3 to a logic one and the oc1 function could reset it to a logic low on the very next count of the free-running counter. 6.4.10 compare force register (cforc) foc1 foc2 foc3 foc4 foc5 foc6 foc7 cforc $ 1 00b 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: read: any time but will always return $00 (1 state is transient). write: any time (writes to bit 0 have no meaning or effect). reset: $00 (no actions forced). foc1 to foc7 force output compare x action writing a one to bit x in this register causes the action which is programmed for output compare x to occur at the next transition of the prescaled timer clock. the action taken is the same as if a successful comparison had just taken place with the tocx register, with the exception that the interrupt flag is not set.
motorola programmable timer MC68HC11G5 6-12 6.4.11 control register 1 (tctl1) om2 ol2 om3 ol3 om4 ol4 om5 ol5 tctl1 $ 1 020 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: read: any time. write: any time. reset: $00 omx output mode; 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 (oc2 C oc5). when either omx or olx is set, the pin associated with ocx becomes an output tied to ocx regardless of the state of the associated ddr bit. output compare oc5 only functions if the to5i4 register is programmed for output compare oc5 operation via the i4/o5 bit in the pactl register. omx olx action taken upon successful compare 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 6.4.12 timer control register 2 (tctl2) edg4b edg4a edg1b edg1a edg2b edg2a edg3b edg3a tctl2 $ 1 021 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: read: any time write: any time reset: $00 edgxb, edgxa input capture edge control the level transition which triggers counter transfer is defined by the corresponding input edge bits (edgxb, edgxa). these bit pairs are encoded to configure input captures ic1 C ic4 to occur on rising edges, falling edges, either edge, or to inhibit capture. input capture 4 only functions if the to5i4 register is programmed for input capture ic4 operation by the i4/o5 bit in the pactl register.
MC68HC11G5 programmable timer motorola 6-13 edgxb edgxa configuration 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) note: input captures do not force the direction of the associated port. if the port bit associated with an input capture is programmed to be an output, then input captures will occur on the appropriate changes of state caused by writing to the port. 6.4.13 timer control register 3 (tctl3) edg5b edg5a edg6b edg6a om6 ol6 om7 ol7 tctl3 $ 1 050 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: read: any time. write: any time. reset: $00 edgxb, edgxa input capture edge control these control bits configure the input capture edge detector circuits for input captures ic5 and ic6. edgxb edgxa configuration 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) input capture ic5 only functions if the to6i5 register is programmed for input capture ic5 operation by the i5/o6 bit in the tctl4 register being set to one. input capture ic6 functions only if the to7i6 register is programmed for input capture ic5 operation by the i6/o7 bit in the tctl4 register being set to one. omx, olx output mode, output level these control bits are encoded to specify the output action to be taken as a result of successful compares on oc6 and oc7. when either omx or olx is set to one, the pin associated with ocx becomes an output tied to ocx, regardless of the state of the associated ddr bit.
motorola programmable timer MC68HC11G5 6-14 omx olx action taken upon successful compare 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 output compare oc6 only functions if the to6i5 register is programmed for output compare oc6 operation by the i5/o6 bit in the tctl4 register being set to zero. output compare oc7 functions only if the to7i6 register is programmed for output compare oc7 operation by the i6/o7 bit in the tctl4 register being set to zero. 6.4.14 control register 4 (tctl4) ct2sp ct1sp 0 0 0 0 i5/o6 i6/o7 tctl4 $ 1 051 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: read: any time (bits 2 C 7 always read 0 if not in test mode). write: any time (writes to bits 2 C 7 have no meaning or effect if not in test or bootstrap mode). reset: $00 ct2sp timer counter 2 stop (used to facilitate testing) 0 C timer counter 2 is free-running. 1 C timer counter 2 is stopped if in test or bootstrap mode (smod = 1). ct1sp timer counter 1 stop (used to facilitate testing) 0 C timer counter 1 is free-running. 1 C timer counter 1 is stopped if in test or bootstrap mode (smod = 1). i5/o6 configure to6i5 register for input capture or output compare 0 C output compare 6 function enabled (no ic5). 1 C input capture 5 function enabled (no oc6). i6/o7 configure to7i6 register for input capture or output compare 0 C output compare 7 function enabled (no ic6). 1 C input capture 6 function enabled (no oc7).
MC68HC11G5 programmable timer motorola 6-15 6.4.15 main timer interrupt mask register 1 (tmsk1) the bits in tmsk1 correspond bit-for-bit with the bits in the tflg1 status register. a zero disables the corresponding flag from causing a hardware interrupt. a one enables the corresponding flag to cause a hardware interrupt. oc1i oc2i oc3i oc4i 4/5i ic1i ic2i ic3i tmsk1 $ 1 022 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: read: any time write: any time reset $00 oc1i, oc2i, oc3i, oc4i ?output compare ??interrupt enable 0 ?interrupt inhibited. 1 ?ocx interrupt requested when ocxf flag set 4/5i ?input capture 4/output compare 5 interrupt enable 0 ?interrupt inhibited. 1 ?ic4 or oc5 interrupt requested when 4/5f flag set ic1i, ic2i, ic3i ?input capture ??interrupt enable 0 ?interrupt inhibited. 1 ?icx interrupt requested when icxf flag set 6.4.16 main timer interrupt flag register 1 (tflg1) the main timer system flag register (tflg1) contains flag bits which are set by hardware when the corresponding timer interrupt condition occurs. any flag bits in the tflg1 register which are set will remain set until they are cleared by writing ones to those bits. oc1f oc2f oc3f oc4f 4/5f ic1f ic2f ic3f tflg1 $ 1 023 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: read: any time. write: used in clearing mechanism (writing ones to bits set cause these bits to be cleared). reset: $00
motorola programmable timer MC68HC11G5 6-16 oc1f, oc2f,oc3f, oc4f output compare x flag set when the 16-bit timer counter register matches the ocx compare register. these bits are cleared by writing to the tflg1 register with the corresponding bits (4C7) set. 4/5f input capture 4/output compare 5 flag set when an input capture occurs on ic4 or an output compare occurs on oc5. this bit is cleared by writing to the tflg1 register with bit 3 set. ic1f, ic2f, ic3f input capture x flag set when an input capture occurs on icx. these bits are cleared by writing to the tflg1 register with the corresponding bits (0C2) set. 6.4.17 miscellaneous timer interrupt mask register 2 (tmsk2) the bits in tmsk2 correspond bit-for-bit with the bits in the tflg2 status register. a zero inhibits the corresponding flag from causing a hardware interrupt. a one enables the corresponding flag to cause a hardware interrupt. to1i rtii paovi paii to2i 5/6i 6/7i 0 tmsk2 $ 1 024 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: read: any time. write: any time. reset: $00 to1i ?timer overflow 1 interrupt enable 0 ?interrupt inhibited. 1 ?hardware interrupt requested when to1f flag set. rtii ?rti interrupt enable 0 ?interrupt inhibited. 1 ?hardware interrupt requested when rtif flag set. paovi ?pulse accumulator overflow interrupt enable 0 ?interrupt inhibited 1 ?hardware interrupt requested when paovf flag set paii ?pulse accumulator input interrupt enable 0 ?interrupt inhibited 1 ?hardware interrupt requested when paif flag set
MC68HC11G5 programmable timer motorola 6-17 to2i timer overflow 2 interrupt enable 0 C interrupt inhibited 1 C hardware interrupt requested when to2f flag set 5/6i input capture 5/output compare 6 interrupt enable 0 C interrupt inhibited 1 C hardware interrupt requested when 5/6f flag set 6/7i input capture 6/output compare 7 interrupt enable 0 C interrupt inhibited 1 C hardware interrupt requested when 6/7f flag set 6.4.18 miscellaneous timer interrupt flag register 2 (tflg2) the miscellaneous timer system flag register (tflg2) contains flag bits which are set by hardware when the corresponding timer interrupt condition occurs. any flag bits in the tflg1 register which are set will remain set until they are cleared by writing ones to those bits. to1f rtif paovf paif to2f 5/6f 6/7f 0 tflg2 $ 1 025 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: read: any time. write: used in clearing mechanism (see above). reset: $00 to1f ?timer overflow 1 flag set when 16-bit free running timer 1 overflows from $ffff to $0000. this bit is cleared by writing to the tflg2 register with bit 7 set. rtif ?real time (periodic) interrupt flag set when the tap point selected becomes set. this bit is cleared by writing to the tflg2 register with bit 6 set. paovf ?pulse accumulator overflow flag set when the 8-bit pulse accumulator overflows from $ff to $00. this bit is cleared by writing to the tflg2 register with bit 5 set.
motorola programmable timer MC68HC11G5 6-18 paif pulse accumulator input edge flag set when the selected edge is detected at the pai 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 pai input pin triggers paif. this bit is cleared by writing to the tflg2 register with bit 4 set. to2f timer overflow 2 flag set when 16-bit free-running timer 2 overflows from $ffff to $0000. this bit is cleared by writing to the tflg2 register with bit 3 set. 5/6f input capture 5/output compare 6 flag set by input capture ic5 or output compare oc6, depending on which function is selected. this bit is cleared by writing to the tflg2 register with bit 2 set. 6/7f input capture 6/output compare 7 flag set by input capture ic6 or output compare oc7, depending on which function is selected. this bit is cleared by writing to the tflg2 register with bit 1 set. 6.4.19 count register (pacnt) pacnt is a read/write 8-bit counter register which is not initialized by reset. the pactl register contains four control bits which enable and configure the pulse accumulator system. the pulse accumulator uses port a bit 7 as its pai input but this pin can also serve as a general purpose i/o pin and as the timer output compare oc1 output. bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 pacnt $ 1 027 7 6 5 4 3 2 1 0 u u u u u u u u reset: read: any time (returns count from pulse accumulator counter). write: any time. reset: indeterminate.
MC68HC11G5 programmable timer motorola 6-19 6.4.20 pulse accumulator control register (pactl) 0 paen pamod pedge i4/o5 rtr2 rtr1 rtr0 pactl $ 1 026 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: read: any time. write: any time. reset: $00 paen pulse accumulator system enable when paen is zero, the pulse accumulator counter is disabled from counting and the paif and paovf flags cannot be set. the counter value and the states of the two flags are not altered by the state of the paen bit (writing paen to zero does not clear them). when paen is a one, the pulse accumulator counter and the setting mechanisms on the two pulse accumulator flags paif and paovf are enabled. 0 C pulse accumulator system disabled (no flags can become set and the counter is stopped). 1 C pulse accumulator system enabled pamod pulse accumulator mode the pamod control bit specifies event or gated time accumulation mode. 0 C event counter mode. 1 C gated time accumulation mode. pedge pulse accumulator edge control the pedge bit is used to specify the active edge for the pai input pin which is interpreted as the trailing edge for the pai gate enable input when the system is configured for gated time accumulation. pedge in event counter mode (pamod = 0): 0 C falling edges on pai pin cause the count to be incremented. 1 C rising edges on pai pin cause the count to be incremented. pedge in gated time accumulation mode (pamod = 1): 0 C pai input pin high enables e divided by 64 clock to pulse accumulator and the trailing falling edge on pai sets the paif flag. 1 C pai input pin low enables e divided by 64 clock to pulse accumulator and the trailing rising edge on pai sets the paif flag.
motorola programmable timer MC68HC11G5 6-20 i4/o5 configure to5i4 register for input capture or output compare 0 C output compare 5 function enabled (no ic4). 1 C input capture 4 function enabled (no oc5). rtr2, rtr1, rtr0 rti interrupt rate these bits select one of six rates for the real time periodic interrupt circuit (see table 6-1). reset clears these bits and after reset a full rti period elapses before the first rti interrupt occurs. table 6-1. real time interrupt rates rtr2 rtr1 rtr0 divide e by xtal = 2 23 xtal = 8.0mhz xtal = 4.9152mhz xtal = 4.0mhz xtal = 3.6864mhz 110 2 11 0.98 ms 1.02 ms 1.67 ms 2.05 ms 2.22 ms 111 2 12 1.95 ms 2.05 ms 3.33 ms 4.10 ms 4.44 ms 000 2 13 3.91 ms 4.10 ms 6.67 ms 8.19 ms 8.89 ms 001 2 14 7.81 ms 8.19 ms 13.33 ms 16.38 ms 17.78 ms 010 2 15 15.62 ms 16.38 ms 26.67 ms 32.77 ms 35.56 ms 011 2 16 31.25 ms 32.77 ms 53.33 ms 65.54 ms 71.11 ms e = 2.1mhz 2.0mhz 1.2288mhz 1.0mhz 921.6khz
MC68HC11G5 serial communications interface motorola 7-1 section 7 serial communications interface this section describes the uart type serial communications interface system (sci). the sci can be used, for example, to connect a crt terminal or personal computer to the mcu or to form a serial communication network connecting several widely distributed mcus. it should be noted that the sci is one of two independent serial i/o subsystems in the MC68HC11G5. the other serial i/o system on the MC68HC11G5, the serial peripheral interface (spi), provides for high speed synchronous serial communication to peripherals or other mcus (usually located on the same pc board as the MC68HC11G5). 7.1 overview and features the sci on the MC68HC11G5 is a full duplex uart type asynchronous system. the sci uses standard non-return-to-zero (nrz) format (one start bit, eight or nine data bits, and one stop bit). an on-chip baud rate generator derives standard baud rate frequencies from the mcu oscillator. both the transmitter and the receiver are double buffered so back-to-back characters can be handled easily, even if the cpu is delayed in responding to the completion of an individual character. the sci transmitter and receiver are functionally independent but use the same data format and baud rate. 7.1.1 sci two-wire system features: ? standard nrz (mark/space) format. ? advanced error detection method includes noise detection for noise duration of up to 1/16th bit time. ? full-duplex operation. ? software programmable for one of 32 different baud rates. ? software selectable word length (eight or nine bit words). ? separate transmitter and receiver enable bits. ? capable of being interrupt driven. ? four separate enable bits available for interrupt control. 7.1.2 sci receiver features ? receiver wake-up function (idle line or address bit). ? idle line detect.
motorola serial communications interface MC68HC11G5 7-2 ? framing error detect. ? noise detect. ? overrun detect. ? receiver data register full flag. 7.1.3 sci transmitter features ? transmit data register empty flag. ? transmit complete flag. ? send break. 7.2 functional description a block diagram of the sci is shown in figure 7-1. the user has option bits in serial control register 1 (sccr1) to select the wake-up method (wake bit) and data word length (m bit) of the sci. serial communications control register 2 (sccr2) provides control bits which individually enable/disable the transmitter or receiver (te and re, respectively), enable system interrupts (tie, tcie, ilie) and provide the wake-up enable bit (rwu) and the send break code bit (sbk). control bits in the baud rate register (baud) allow the user to select one of 32 different baud rates for the transmitter and receiver. data transmission is initiated by a write to the serial communications data register (scdr). provided the transmitter is enabled, data stored in the scdr is transferred to the transmit data shift register. this transfer of data sets the transmit data register empty flag (tdre) in the sci status register (scsr) and may generate an interrupt if the transmit interrupt is enabled. the transfer of data to the transmit data shift register is synchronized with the bit rate clock (figure 7-2). all data is transmitted least significant bit first. upon completion of data transmission, the transmission complete flag (tc) in the scsr is set (provided no pending data, preamble or break is to be sent), and an interrupt may be generated if the transmit complete interrupt is enabled. if the transmitter is disabled, and the data, preamble or break (in the transmit data shift register) has been sent, the tc bit will also be set. this will also generate an interrupt if the transmission complete interrupt enable bit (tcie) is set. if the transmitter is disabled in the middle of a transmission, that character will be completed before the transmitter gives up control of the txd pin. when scdr is read, it contains the last data byte received, provided that the receiver is enabled. the receive data register full flag bit (rdrf) in the scsr is set to indicate that a data byte has been transferred from the input serial shift register to the scdr, which can cause an interrupt if the receiver interrupt is enabled. the data transfer from the input serial shift register to the scdr is synchronized by the receiver bit rate clock. the or (overrun), nf (noise), or fe (framing) error flags in the scsr may be set if data reception errors occurred. an idle line interrupt is generated if the idle line interrupt is enabled and the idle bit (which detects idle line transmission) in scsr is set. this allows a receiver that is not in the wake-up mode to detect the end of a message or the preamble of a new message, or to resychronize with the transmitter. a valid character must be received before the idle line condition or the idle bit will not be set and and idle line interrupt will not be generated.
MC68HC11G5 serial communications interface motorola 7-3 sci interrupt internal bus transmit data register transmit data shift register (see note) receive data register (see note) receive data shift register rxd (pd0) $ 1 02f $ 1 02f $ 1 02d sccr2 tie tcie rie ilie te re sbk rwu wake-up unit fe nf or idle rdrf tc tdre 2 scsr $ 1 02e sbk te 7 transmit control flag control receive control internal processor clock rate generator $ 1 02b tclr 0 scp1 scp0 rckb scr2 scr1 baud $ 1 02c r8 t8 0 m wake 0 0 0 sccr1 scr1 txd (pd1) figure 7-1. serial communications interface block diagram note: the serial communications data register (scdat) is controlled by the internal r/w signal. it is the transmit data register when written and the receive data register when read.
motorola serial communications interface MC68HC11G5 7-4 + 4 scp0-scp1 prescaler control + n scr0-scr2 sci select rate control + m sci receive clock (rti) + 16 sci transmit clock (tx) oscillator frequency figure 7-2. rate generator division 7.3 data format receive data or transmit data is the serial data that is transferred to the internal data bus from the receive data input pin (rxd) or from the internal bus to the transmit data output pin (txd). the non- return-to-zero (nrz) data format shown in figure 7-3 is used and must meet the following criteria: 1) the idle line is brought to a logic one state prior to transmission/reception of a character. 2) a start bit (logic zero) is used to indicate the start of a frame. 3) the data is transmitted and received least significant bit first. 4) a stop bit (logic one) is used to indicate the end of a frame. a frame consists of a start bit, a character of eight or nine data bits, and a stop bit. 5) a break is defined as the transmission or reception of a low (logic zero) for at least one complete frame time. idle line start stop control bit "m" selects 8 or 9 bit data 012345678 0 start figure 7-3. data format 7.4 receiver wake-up operation the MC68HC11G5 receiver logic hardware also supports a receiver wake-up function which is intended for systems having more than one receiver. with this function a transmitting device directs messages to an individual receiver or group of receivers by passing addressing information as the initial byte(s) of each message. the wake-up function allows receivers not addressed to remain in in a dormant state for the remainder of the unwanted message. this eliminates any further software overhead to service the remaining characters of the unwanted message and thus improves system performance.
MC68HC11G5 serial communications interface motorola 7-5 the receiver is placed in wake-up mode by setting the receiver wake-up bit (rwu) in the sccr2 register. while rwu is set, all of the receiver related status flags (rdrf, idle, or, nf, and fe) are inhibited (cannot become set). note that the idle line detect function is inhibited while the rwu bit is set. although rwu may be cleared by a software write to sccr2, it would be unusual to do so. normally rwu is set by software and gets cleared automatically with hardware by one of the two methods described below. 7.4.1 idle line wake-up in idle line wake-up mode, a dormant receiver wakes up as soon as the rxd line becomes idle. idle is defined as a continuous logic high level on the rxd line for ten (or eleven) full bit times. systems using this type of wake-up must provide at least one character time of idle between messages to wake up sleeping receivers, but must not allow any idle time between characters within a message. 7.4.2 address mark wake-up in address mark wake-up, the most significant bit (msb) in a character is used to indicate that the character is an address (1) or a data (0) character. sleeping receivers will wake up whenever an address character is received. systems using this method for wake-up would set the msb of the first character of each message and leave it clear for all other characters in the message. idle periods may be present within messages and no idle time is required between messages for this wake-up method. 7.5 receive data (rxd) receive data is the serial data that is applied through the input line and the serial communications interface to the internal bus. the receiver circuitry clocks the input at a rate equal to 16 times the baud rate and this time is referred to as the rt clock. once a valid start bit is detected the start bit, each data bit and the stop bit are sampled three times at rt intervals 8 rt, 9 rt and 10 rt (1 rt is the position where the bit is expected to start), as shown in figure 7-4. the value of the bit is determined by voting logic which takes the value of the majority of the samples. rxd previous bit present bit samples next bit vvv 16 1 r t r t 16 1 r t r t 8910 r t r t r t figure 7-4. sampling technique used on all bits
motorola serial communications interface MC68HC11G5 7-6 7.6 start bit detection when the rxd input is detected low, it is tested for three more sample times (referred to as the start edge verification samples in figure 7-5). if at least two of these three verification samples detect a logic zero, a valid start bit has been detected, otherwise the line is assumed to be idle. a noise flag is set if all three verification samples do not detect a logic zero. a valid start bit could be assumed with a set noise flag present. if there has been a framing error without detection of a break (10 zeros for 8-bit format or 11 zeros for 9-bit format), the circuit continues to operate as if there actually was a stop bit and the start edge will be placed artificially. the last bit received in the data shift register is inverted to a logic one, and the three logic one start qualifiers (shown in figure 7-5) are forced into the sample shift register during the interval when detection of a start bit is anticipated (see figure 7-6); therefore, the start bit will be accepted no sooner than it is anticipated. if the receiver detects that a break produced the framing error, the start bit will not be artificially induced and the receiver must actually detect a logic one before the start bit can be recognised (see figure 7-7). 16x internal sampling clock rt clock edges (for all three examples) idle rxd start 1111111111 0000 1 r t 2 r t 3 r t 4 r t 5 r t 6 r t 7 r t 8 r t start qualifiers start idle rxd rxd idle start noise noise start edge verification samples 1111111111 0010 0000 1111011111 figure 7-5. examples of start bit sampling techniques
MC68HC11G5 serial communications interface motorola 7-7 data expected stop start edge data samples start bit data receive data in data expected stop artifical edge start bit data receive data in data samples (a) case 1, receive line low during artificial edge (b) case 2, receive line high during expected start edge figure 7-6. sci artificial start following a framing error break expected stop start edge start bit receive data in data samples detected as valid start qualifiers start edge verification samples figure 7-7. sci start bit following a break
motorola serial communications interface MC68HC11G5 7-8 7.7 transmit data (txd) transmit data is the serial data from the internal data bus that is applied through the serial communications interface to the output line. the transmitter generates a bit time by using a derivative of the rt clock, thus producing a transmission rate equal to 1/16th that of the receiver sample clock. 7.8 sci registers primarily the sci system is configured and controlled by five registers baud, sccr1, sccr2, scsr, and scdat). in addition, the port d data and data direction registers and the port d wired- or mode bit in the spcr register are secondarily related to the sci system. reference should be made to the block diagram shown in figure 7-1. 7.8.1 serial communications data register (scdat) the sci data register (scdat) shown in the following figure is actually two separate registers. when scdat is read, the read-only receive data register is accessed and when scdat is written, the write-only transmit data register is accessed. scdat $ 1 02f 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 read: accesses the read-only sci receive data register (rdr). write: accesses the write-only sci transmit data register (tdr). reset: does not affect this address. 7.8.2 serial communications control register 1 (sccr1) the sci control register 1 (sccr1) contains control bits related to the nine data bit character format and the receiver wake-up feature. four of the bits in this register are not used and always read as zeros. sccr1 $ 1 02c 7 6 5 4 3 2 1 0 u u 0 0 0 0 0 0 reset: r8 t8 0 m wake 0 0 0
MC68HC11G5 serial communications interface motorola 7-9 r8 receive data bit 8 read: any time. write: has no meaning or effect. this bit is the ninth serial data bit received when the sci system is configured for nine data bit operation (m = 1). the most significant bit (bit 8) of the received character is transferred into this bit at the same time as the remaining eight bits (bits 0 C 7) are transferred from the serial receive shifter to the sci receive data register. t8 transmit data bit 8 read: any time. write: any time. this bit is the ninth data bit to be transmitted when the sci system is configured for nine data bit operation (m = 1). when the eight low order bits (bits 0 C 7) of a transmit character are transferred from the sci data register to the serial transmit shift register, this bit (bit 8) is transferred to the ninth bit position of the shifter. m mode (select character format) read: any time. write: any time. 0 C 1 start bit, 8 data bits, 1 stop bit. 1 C 1 start bit, 8 data, 9th data bit, 1 stop bit. the m bit controls the character length for both the transmitter and receiver at the same time. the 9th data bit is most commonly used as an extra stop bit or in conjunction with the address mark wake-up method. it can also be used as a parity bit. wake wake-up mode select read: any time. write: any time. 0 C wake-up on idle line. 1 C wake-up on address mark. note: bits 2 C 1 are not implemented and always read as zeros. 7.8.3 serial communications control register 2 (sccr2) the sci control register 2 (sccr2) provides the control bits that enable/disable individual sci functions. sccr2 $ 1 02d 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: tie tcie rie ilie te re rwu sbk
motorola serial communications interface MC68HC11G5 7-10 read: any time write: any time reset: $00 tie transmit interrupt enable 0 C tdre interrupts disabled 1 C sci interrupt if tdre = 1 tcie transmit complete interrupt enable 0 C tc interrupts disabled 1 C sci interrupt if tc = 1 rie receiver interrupt enable 0 C rdrf and or interrupts disabled 1 C sci interrupt if rdrf or or = 1 ilie idle line interrupt enable 0 C idle interrupts disabled. 1 C sci interrupt if idle = 1 te transmitter enable when the transmit enable bit is set, the transmit shift register output is applied to the txd line. depending on the state of control bit m (sccr1), a preamble of 10 (m = 0) or 11 (m = 1) consecutive ones is transmitted when software sets the te bit from a cleared state. after loading the last byte in the serial communications data register and receiving the tdre flag, the user can clear te. transmission of the last byte will then be completed before the transmitter gives up control of the txd pin. while the transmitter is active, the data direction register control for port d bit 1 is overridden and the line is forced to be an output. re receiver enable when the receiver enable bit is set, the receiver is enabled. when re is clear, the receiver is disabled and all of the status bits associated with the receiver (rdrf, idle, or, nf and fe) are inhibited. while the receiver is enabled, the data direction register control for port d bit 0 is overridden and the line is forced to be an input. rwu receiver wake-up when the receiver wake-up bit is set by the user software, it puts the receiver to sleep and enables the wake-up function. if the wake bit is cleared, rwu is cleared by the sci logic after receiving 10 (m = 0) or 11 (m = 1) consecutive ones. if the wake bit is set, rwu is cleared by the sci logic after receiving a data word whose msb is set. sbk send break if the send break bit is toggled set and cleared, the transmitter sends 10 (m = 0) or 11 (m = 1) zeros and then reverts to idle sending data. if sbk remains set, the transmitter will continually send whole blocks of zeros (sets of 10 or 11) until cleared. at the completion
MC68HC11G5 serial communications interface motorola 7-11 of the break code, the transmitter sends at least one high bit to guarantee recognition of a valid start bit. if the transmitter is currently empty and idle, setting and clearing sbk is likely to queue two character times of break because the first break transfers almost immediately to the shift register and the second is then queued into the parallel transmit buffer. 7.8.4 serial communications status register (scsr) the serial communications status register (scsr) provides inputs to the interrupt logic circuits for generation of the sci system interrupt. tdre tc rdrf idle or nf fe 0 scsr $ 1 02e 7 6 5 4 3 2 1 0 1 1 0 0 0 0 0 0 reset: read: any time (used in auto clearing mechanism). write: has no meaning or effect. tdre ?transmit data register empty flag this bit is set when the byte in the transmit data register is transferred to the serial shift register. new data will not be transmitted unless the scsr register is read before writing to the transmit data register. reset sets this bit. tc ?transmit complete flag this bit is set to indicate that the sci transmitter has no meaningful information to transmit (no data in shifter, no preamble, no break). when tc is set the serial line will go idle (continuous mark). reset sets this bit. rdrf ?receive data register full flag this bit is set when the contents of the receiver serial shift register is transferred to the receiver data register. idle ?idle line detected flag this bit is set when a receiver idle line is detected (the receipt of a minimum of ten/eleven consecutive ??). this bit will not be set by the idle line condition when the rwu bit is set. once cleared, idle will not be set again until after rdrf has been set, (until after the line has been active and becomes idle again). or ?overrun error flag this bit is set when a new byte is ready to be transferred from the receiver shift register to the receiver data register and the receive data register is already full (rdrf bit is set). data transfer is inhibited until this bit is cleared.
motorola serial communications interface MC68HC11G5 7-12 nf noise error flag this bit is set if there is noise on a valid start bit, any of the data bits, or on the stop bit. the nf bit is set during the same cycle as the rdrf bit but does not get set in the case of an overrun (or). fe framing error flag this bit is set when the word boundaries in the bit stream are not synchronized with the receiver bit counter (generated by the reception of a logic zero bit where a stop bit was expected). the fe bit reflects the status of the byte in the receive data register and the transfer from the receive shifter to the receive data register is inhibited in the case of overrun. the fe bit is set during the same cycle as the rdrf bit but does not get set in the case of an overrun (or). the framing error flag inhibits further transfer of data into the receive data register until it is cleared. 7.8.5 baud rate register (baud) the baud rate register (baud) is used to set the bit rate for the sci system. normally this register is written once, during initialization, to set the baud rate for sci communications. both the receiver and the transmitter use the same baud rate which is derived from the mcu bus rate clock. a two stage divider is used to develop custom baud rates from normal mcu crystal frequencies so it is not necessary to use special baud rate crystal frequencies. tclr 0 scp1 scp0 rckb scr2 scr1 scr0 baud $ 1 02b 7 6 5 4 3 2 1 0 0 0 0 0 0 u u u reset: tclr ?clear baud rate counters (for test purposes only) read: always returns 0. write: only while smod = 1 (test or bootstrap mode) this bit is disabled and remains low in any mode other than test or bootstrap mode. reset clears this bit. while in test or bootstrap mode, setting this bit causes the baud rate counter chains to be reset. the logic one state of this bit is transitory and reads always return a logic zero. this control bit is intended only for factory testing of the mcu. scp1, scp0 ?serial prescaler select bits read: any time write: any time the e-clock is divided by the factors shown in table 7-1. this prescaled output provides an input to a divider which is controlled by the sci rate select bits (scr2 ?scr0).
MC68HC11G5 serial communications interface motorola 7-13 table 7-1. first prescaler stage scp1 scp0 internal processor clock divide by 00 1 01 3 10 4 11 13 scr2, scr1, scr0 sci rate select bits read: any time write: any time these three bits select the baud rates for both the transmitter and the receiver. the prescaler output described above is divided by the factors shown in table 7-2. table 7-2. second prescaler stage scr2 scr1 scr0 prescaler output divide by 000 1 001 2 010 4 011 8 100 16 101 32 110 64 111 128
motorola serial communications interface MC68HC11G5 7-14 rckb sci receive baud rate clock test read: always returns logic 0 write: only while smod = 1 (test or bootstrap mode) this bit is disabled and remains low in any mode other than test or bootstrap modes. reset clears this bit. while in test or bootstrap mode, this bit may be written but not read (reads always return a logic zero). setting this bit enables a baud rate counter test mode where the exclusive-or of the receiver clock (16 times the baud rate) and the transmit clock (1 times the baud rate) is driven out the pd1/txd pin. this control bit is intended only for factory testing of the mcu.
MC68HC11G5 serial peripheral interface motorola 8-1 section 8 serial peripheral interface this section contains a description of the serial peripheral interface (spi). 8.1 overview and features the spi is a synchronous interface which allows several spi microcontrollers or spi-type peripherals to be interconnected. in a serial peripheral interface, separate wires (signals) are required for data and clock. in the spi format, the clock is not included in the data stream and must be furnished as a separate signal. the MC68HC11G5 spi system may be configured either as a master or as a slave. features include: ? full-duplex, 3-wire synchronous transfers ? master or slave operation ? 1.05 mhz (maximum) master bit frequency ? 2.1 mhz (maximum) slave bit frequency ? four programmable master bit rates ? programmable clock polarity and phase ? end-of-transmission interrupt flag ? write collision flag protection ? master-master mode fault protection ? easy interface to simple expansion parts (plls, d/as, latches, display drivers, etc.) 8.2 spi signal descriptions the spi interface consists of four port d lines (miso, mosi, sck, and ss). these signals are discussed in the following paragraphs for both master mode and slave mode of operation. any spi output line has to have its corresponding data direction register bit set. if this bit is clear, the line is disconnected from the spi logic and becomes a general-purpose input line. any spi input line is forced to act as an input regardless of the state of the corresponding data direction register bit.
motorola serial peripheral interface MC68HC11G5 8-2 8.2.1 master in slave out (miso) the miso line is configured as an input in a master device and as an output in a slave device. it is one of the two lines that transfer serial data in one direction, with the most significant bit sent first. the miso line of a slave device is placed in the high-impedance state if the slave is not selected. 8.2.2 master out slave in (mosi) the mosi line is configured as an output in a master device and as an input in a slave device. it is one of the two lines that transfer serial data in one direction with the most significant bit sent first. 8.2.3 serial clock (sck) the serial clock is used to synchronize data movement both in and out of the device through its mosi and miso lines. the master and slave devices are capable of exchanging a byte of information during a sequence of eight clock cycles. since sck is generated by the master device, this line becomes an input on a slave device. ss sck (cpol = 0, cpha = 0) sck (cpol = 0, cpha = 1) sck (cpol = 1, cpha = 0) sck (cpol = 1, cpha = 1) miso/mosi msb 6 5 4 3 2 1 lsb internal strobe for data capture (all modes) ss figure 8-1. data clock timing diagram
MC68HC11G5 serial peripheral interface motorola 8-3 as shown in figure 8-1, four different timing relationships may be selected by control bits cpol and cpha in the serial peripheral control register (spcr). both master and slave devices must operate with the same timing. the master device always places data on the mosi line a half cycle before the clock edge (sck), in order for the slave device to latch the data. two bits (spr0 and spr1) in the spcr of the master device select the clock rate. in a slave device, spr0 and spr1 have no effect on the operation of the spi. 8.2.4 slave select (ss) the slave select (ss) input line is used to select a slave device. it must be in the active low state prior to data transactions and must stay low for the duration of the transaction. the ss line on the master must be tied high. if it goes low, a mode fault error flag (modf) is set in the serial peripheral status register (spsr). the ss pin can be selected to be a general-purpose output by writing a one in bit 5 of the port d data direction register, thus disabling the mode fault circuit. the other three spi lines are dedicated to the spi whenever the spi is on. when cpha = 0, the shift clock is the logical or of ss and sck. in this clock phase mode, ss must go high between successive characters in an spi message. when cpha = 1, ss may be left low for several spi characters. if there is only one spi slave mcu, its ss line may be tied to v ss provided cpha = 1 clock modes are used. figure 8-2 shows a block diagram of the serial peripheral interface circuitry. when a master device transmits data to a slave device via the mosi line, the slave device responds by sending data to the master device via the masters miso line. this implies full duplex transmission with both data out and data in synchronized to the same clock signal. thus, the byte transmitted is replaced by the byte received and eliminates the need for separate transmitter-empty and receiver-full status bits. a single status bit (spif) is used to signify that the i/o operation has been completed. the spi is double buffered on read, but not on write. if a write is performed during data transfer, the transfer is not interrupted, and the write will be unsuccessful. this condition will cause the write collision status bit (wcol) in the spsr to be set. after a data byte is shifted, the spif flag in the spsr is set. in master mode, the sck pin is an output. it idles high or low, depending on the spol bit in the spcr, until data is written to the shift register, at which point eight clocks are generated to shift the eight bits of data, after which sck goes idle again. in slave mode, the slave start logic receives a logic low on the ss pin and a clock input at the sck pin. thus, the slave is synchronized to the master. data from the master is received serially via the slave mosi line and is loaded into the 8-bit shift register. the data is then transferred, in parallel, from the 8-bit shift register to the read buffer. during a write cycle, data is written into the shift register, then the slave waits for a clock train from the master to shift the data out on the slaves miso line. figure 8-3 illustrates the mosi, miso and ss master-slave interconnections.
motorola serial peripheral interface MC68HC11G5 8-4 8.3 functional description spr0 spr1 cpol cpha mstr dwom spe spie modf wcol spif spi status register 8-bit shift register read data buffer msb lsb internal data bus spi interrupt request mstr spe mstr dwom spe spr0 spr1 spi clock (master) spi control select internal mcu clock divider 32 16 4 2 clock logic clock pin control logic s m s m s m spi control register miso pd2 mosi pd3 sck pd4 ss pd5 figure 8-2. serial peripheral interface block diagram
MC68HC11G5 serial peripheral interface motorola 8-5 8-bit shift register 8-bit shift register slave master miso mosi sck miso mosi sck spi clock generator +5v ss ss figure 8-3. serial peripheral interface master-slave interconnection due to data direction register control of spi outputs and the port d wire-or mode (dwom) option, the spi system can be configured in a variety of ways. systems with a single bidirectional data path rather than separate miso and mosi paths can be accommodated. since MC68HC11G5 slaves can selectively disable their miso output, a broadcast message protocol is also possible. 8.4 spi registers there are three registers in the serial peripheral interface which provide control, status and data storage functions. these registers are called the serial peripheral control register (spcr), the serial peripheral status register (spsr) and the serial peripheral data i/o register (spdat). 8.4.1 control register (spcr) spcr $ 1 028 7 6 5 4 3 2 1 0 0 0 0 0 0 1 u u reset: spie spe dwom mstr cpol cpha spr1 spr0 read: any time write: any time. spie spi interrupt enable 0 C spi interrupts disabled. 1 C spi interrupts enabled. when this bit is set to one, a hardware interrupt sequence is requested each time the spif or modf status flag is set. spi interrupts are inhibited if this bit is clear or if the i bit in the cc register is set. spe spi system enable 0 C spi system off. 1 C spi system on.
motorola serial peripheral interface MC68HC11G5 8-6 when the spe bit is set the port d bit 2, 3, 4, and 5 pins are dedicated to the spi function. if the spi is in master mode and ddrd bit 5 is set, then the port d bit 5 pin becomes a general purpose output instead of the ss input. dwom port d wired-or mode 0 C port d output buffers operate normally (cmos outputs). 1 C port d output buffers operate as open-drain outputs. dwom affects all six port d pins together. mstr master/slave mode select 0 C slave mode. 1 C master mode. cpol clock polarity when the clock polarity bit is cleared and data is not being transferred, a steady state low value is produced at the sck pin of the master device. conversely, if this bit is set, the sck pin will idle high. this bit is also used in conjunction with the clock phase control bit to produce the desired clock-data relationship between master and slave. see figure 8-1. cpha clock phase the clock phase bit, in conjunction with the cpol bit, controls the clock-data relationship between master and slave. the cpol bit can be thought of simply as inserting an inverter in series with the sck line. the cpha bit selects one of two fundamentally different clocking protocols. when cpha = 0, the shift clock is the logical or of sck and ss. as soon as ss goes low, the transaction begins and the first edge on sck invokes the first data sample. when cpha = 1, the ss pin may be thought of as a simple output enable control. refer to figure 8-1. spr1, spr0 spi clock (sck) rate select bits if the device is a master, the two serial peripheral rate bits select one of four division ratios of the e-clock to be used as sck (see table 8-1). these bits have no effect in slave mode. table 8-1. spi rate selection internal processor clock divide by spr1 spr0 00 2 01 4 10 16 11 32
MC68HC11G5 serial peripheral interface motorola 8-7 8.4.2 status register (spsr) spsr $ 1 029 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: spif wcol 0 modf 0 0 0 0 read: any time. write: has no meaning or effect. spif spi interrupt request flag the serial peripheral data transfer flag bit is set after the eighth sck cycle in a data transfer and it is cleared by reading the spsr register (with spif set) followed by reading from or writing to the spi data register (spdat). wcol write collision the write collision bit is used to indicate that a serial transfer was in progress when the mcu tried to write new data into the spdat data register. the mcu write is disabled to avoid writing over the data being transmitted. no interrupt is generated because the error status flag can be read upon completion of the transfer that was in progress at the time of the error. this flag is automatically cleared by a read of the spsr (with wcol set) followed by an access (read or write) to the spdat register. modf spi mode error interrupt status flag this bit is set automatically by spi hardware if the mstr control bit is set to one and the ss input pin goes low. this condition is not permitted in normal operation. in the special case where ddrd bit 5 is set to one, the port d bit 5 pin is a general purpose output pin rather than being dedicated as the slave select input for the spi system. in this special case the mode error function is inhibited and modf remains at zero. this flag is automatically cleared by a read of the spsr (with modf set) followed by a write to the spcr register. 8.4.3 data i/o register (spdat) spdat $ 1 02a 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 read: any time (normally only after spif flag set) write: any time (see wcol write collision flag). reset: does not affect this register. the serial peripheral data i/o register is used to transmit and receive data on the serial bus. only a write to this register will initiate transmission/reception of another byte, and this will only occur in
motorola serial peripheral interface MC68HC11G5 8-8 the master device. at the completion or transmitting a byte of data, the spif status bit is set in both the master and slave devices. when the user reads the serial peripheral data i/o register, a buffer is actually being read. the first spif must be cleared by the time a second transfer of data from the shift register to the read buffer is initiated or an overrun condition will exist. in cases of overrun, the byte which causes the overrun is lost. a write to the serial peripheral data i/o register is not buffered and places data directly into the shift register for transmission.
MC68HC11G5 analog-to-digital converter motorola 9-1 section 9 analog-to-digital converter the analog to digital converter system consists of a single 10-bit successive approximation type converter and a 16-channel multiplexer. eight of the channels are connected to pins on the MC68HC11G5, four are unused and the remaining four channels are dedicated to internal reference points or test functions. there are eight 10-bit result registers and control logic allows for four or eight consecutive conversions before stopping or for conversions to continue with the newest conversion overwriting the oldest result register. also, the control logic allows conversions to be performed on a single selected channel, multiple times or consecutively on a selected group of four channels. in addition, the control logic allows for converting all eight channels and either stopping or converting continuously. two dedicated lines (v rl and v rh ) are provided for the reference voltage inputs. these pins may be connected to a separate or isolated power supply to ensure full accuracy of the ad conversion. the 10-bit a/d converter accepts analog inputs ranging from v rl to v rh . smaller input ranges can also be obtained by adjusting v rl and v rh to the desired upper and lower limits. conversion is specified and tested for v rl = 0 volts and v rh = 5 volts. the a/d system can be operated with v rh below v dd and/or v rl above v ss as long as v rh is above v rl by enough to support the conversions (2.5 to 5.0 volts). each set of four conversions takes 144 cycles of the e-clock, provided that e is greater than or equal to 750 khz. if e is less than 750 khz, an internal r-c oscillator, which is nominally 1.5 mhz, must be used for the a/d conversion clock. when the internal r-c oscillator is being used as the conversion clock, the conversion complete flag (ccf) must be used to determine when a conversion sequence has been completed. when using the internal r-c oscillator for a/d conversions the sample and conversion process runs at the nominal 1.5 mhz rate; however, the conversion results must be transferred to the mcu result registers synchronously with the mcu e-clock, so conversion time is limited to a maximum of one channel per e-clock cycle. two control bits in the option register control the basic configuration of the a/d system. the a to d power-up bit (adpu) allows the system to be disabled, resulting in reduced power consumption when the a/d system is not being used. any conversion which is in process when adpu is written to zero will be aborted. a delay of typically 100 microseconds is required after turning on the a/d (by writing adpu from 0 to 1) for the analog and comparator sections to stabilize. the csel bit is used to select either the internal r-c oscillator or the mcu e-clock as the a/d system clock source.
motorola analog-to-digital converter MC68HC11G5 9-2 9.1 conversion process the a/d converter is ratiometric. an input voltage equal to v rh converts to $ffc0 (full scale) and an input voltage equal to v rl converts to $0000. an input voltage greater than v rh will convert to $ffc0 with no overflow indication. note that the six least significant bits always read zero. for ratiometric conversions, the source of each analog input should use v rh as the supply voltage and be referenced to v rl . the a/d reference inputs are applied to a precision internal digital-to-analog converter. control logic drives this d/a and the analog output is successively compared to the selected analog input which was sampled at the beginning of the conversion time. the conversion process is monotonic with no missing codes. 9.2 channel assignments a multiplexer allows the single a/d converter to select one of sixteen analog signals. eight of these channels are supported on the port e input pins. of the eight other channels, four are reserved for future use and four are for internal reference points and testing purposes. table 9-1 shows the signals selected by the channel select bits (cd, cc, cb, ca) in the adctl register. all reserved channels are connected to v rl . table 9-1. channel assignments conv8 = 0 result in register if cd cc cb ca channel signal mult = 1 mult = 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 1 an1 (pe0) an2 (pe1) an3 (pe2) an4 (pe3) adr5 adr6 adr7 adr8 adr5 C 8 adr5 C 8 adr5 C 8 adr5 C 8 0 0 0 0 1 1 1 1 0 0 1 1 0 1 0 1 an5 (pe4) an6 (pe5) an7 (pe6) an8 (pe7) adr5 adr6 adr7 adr8 adr5 C 8 adr5 C 8 adr5 C 8 adr5 C 8 1 0 x x reserved 1 1 1 1 1 1 1 1 0 0 1 1 0 1 0 1 test (reserved) adr5 adr6 adr7 adr8 adr5 C 8 adr5 C 8 adr5 C 8 adr5 C 8 rh rh rl v v v/2
MC68HC11G5 analog-to-digital converter motorola 9-3 table 9-1. channel assignments (continued) conv8 = 1 result in register if cd cc cb ca channel signal mult = 1 mult = 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 1 an1 (pe0) an2 (pe1) an3 (pe2) an4 (pe3) adr1 adr2 adr3 adr4 adr1 C 8 adr1 C 8 adr1 C 8 adr1 C 8 0 0 0 0 1 1 1 1 0 0 1 1 0 1 0 1 an5 (pe4) an6 (pe5) an7 (pe6) an8 (pe7) adr5 adr6 adr7 adr8 adr1 C 8 adr1 C 8 adr1 C 8 adr1 C 8 1 0 x x reserved 1 1 1 1 1 1 1 1 0 0 1 1 0 1 0 1 test (reserved) adr5 adr6 adr7 adr8 adr1 C 8 adr1 C 8 adr1 C 8 adr1 C 8 rh rh rl v v v/2 9.3 single channel operation single channel operation is selected by writing a zero to the mult bit in the a/d control and status register (adctl). this mode has four variations, which can be selected using the conv8 and scan bits in the adctl register. in the first two variations, the conv8 bit is clear and the single selected channel is converted four consecutive times. in the second two variations, the conv8 bit is set and the single selected channel is converted eight consecutive times. the state of the scan bit determines whether continuous or single scanning is selected. the channel is selected by the cd C ca bits in the adctl register. 9.3.1 4-conversion, single scan whichever port e bit is selected, the first result will be stored in the adr5 result register and the fourth result will be stored in the adr8 register. after the fourth conversion is complete all conversion activity is halted until a new conversion command is written to the adctl control register. 9.3.2 4-conversion, continuous scan conversions continue to be performed on the selected channel with the fifth conversion being stored in the adr5 register (overwriting the first conversion result), the sixth conversion overwrites adr6, the seventh overwrites adr7, and so on continuously. using this variation, the data in any result register is at most four conversion times old.
motorola analog-to-digital converter MC68HC11G5 9-4 9.3.3 8-conversion, single scan the result of the first conversion will be placed in result register adr1, while the result of the eighth conversion will be placed in result register adr8. after the eighth conversion is complete all conversion activity is halted until a new conversion command is written to the adctl control register. 9.3.4 8-conversion, continuous scan conversions continue to be performed on the selected channel with the ninth conversion being stored in the adr1 register (overwriting the first conversion result), the tenth conversion overwrites adr2, the eleventh overwrites adr3, and so on continuously. using this variation, the data in any result register is at most eight conversion times old. 9.4 multiple channel operation multiple channel operation is selected by writing a one to the mult bit in the a/d control and status register (adctl). this mode has four variations, which can be selected using the conv8 and scan bits in the adctl register in the first two variations, the conv8 bit is clear; and either port e bits 0 C 3 or port e bits 4 C 7 are selected. (in this multiple channel mode, only the two most significant bits of the channel address (cd and cc) are decoded.) in the second two variations, the conv8 bit is set and all eight channels are converted. the state of the scan bit determines whether continuous or single scanning is selected. 9.4.1 4-channel single scan either port e bits 0 C 3 are selected or port e bits 4 C 7 are selected. the first result is stored in the adr5 result register and the fourth result is stored in the adr8 register. after the fourth conversion is complete, all conversion activity is halted until a new conversion command is written to the adctl control register. 9.4.2 4-channel continuous scan conversions continue to be performed on the selected group of channels with the fifth conversion being stored in the adr5 register (replacing the earlier conversion result for the first channel in the group), the sixth conversion overwrites adr6, the seventh overwrites adr7, and so on, continuously. using this second variation the data in any result register is, at most, four conversion times old. 9.4.3 8-channel single scan when conv8 is set and mult is set, all eight channels are converted. each of the channels is converted and the result is placed in a separate result register. port e bit 0 uses result register adr1, port e bit 1 uses result register adr2 and so on. each channel is converted once, then all conversion activity is halted until a new conversion command is written to the adctl control register.
MC68HC11G5 analog-to-digital converter motorola 9-5 9.4.4 8-channel continuous scan conversions continue to be performed on all eight channels with the ninth conversion being stored in the adr1 register (replacing the earlier conversion result for the first channel in the group), the tenth conversion overwrites adr2, the eleventh overwrites adr3, and so on, continuously. using this second variation the data in any result register is, at most, eight conversion times old. 9.5 power-up and clock select a/d power up is controlled by the adpu bit in the option register. when adpu is cleared, power to the a/d system is removed. when adpu is set, the a/d system is enabled. a delay of 100 microseconds is required after turning on the a/d converter, to allow the analog bias voltages to stabilize. clock select is controlled by the csel bit in the option register. when csel is cleared, the a/d system uses the system e-clock. when csel is set, the a/d system uses an internal r-c clock source, nominally 1.5 mhz, in which case the r-c internal clock should be selected. a delay of 10 milliseconds is required, after changing csel from zero to one, to allow the r-c oscillator to start and internal bias voltages to settle. when the a/d system is operating with the mcu e-clock, all switching and comparator operations are synchronized with the mcu clock. this allows the comparator results to be sampled at quiet clock times to minimise the effect of internal switching noise. as the internal r-c oscillator is asynchronous with respect to the mcu clock, internal switching noise is more likely to affect the overall accuracy of the a/d results, when using this oscillator, than when using the e-clock. 9.6 operation in stop and wait modes if a conversion sequence is still in process when the MC68HC11G5 enters the stop or wait mode, the conversion of the current channel is suspended. when the mcu resumes normal operation, that channel is re-sampled and the conversion sequence resumes. as the mcu exits the wait mode, the a/d circuits are stable and valid results can be obtained on the first conversion. however, in stop mode the comparator, charge pump and r-c oscillator are turned off. if the MC68HC11G5 exits the stop mode with a delay (as is normal), there will automatically be enough time for these circuits to stabilize before the first conversion. if the MC68HC11G5 exits the stop mode with no delay (dly bit in option register equal to zero) and a stable external clock supplied, the user must allow about 100 microseconds for the a/d circuitry to stabilize and to avoid invalid results.
motorola analog-to-digital converter MC68HC11G5 9-6 9.7 registers 9.7.1 a/d control and status register (adctl) adctl $ 1 030 7 6 5 4 3 2 1 0 undefined reset: ccf conv8 scan mult cd cc cb ca read: any time. write: any time except writes always clear bit 7. reset: indeterminate. ccf conversions complete flag this flag bit is set automatically after an a/d conversion cycle (four or eight conversions, depending on which conversion mode is selected). if a continuous scan mode is selected, the ccf flag will become set after the first time all four (or eight) registers have been updated, and it will remain set until the adctl register is again written. each time the adctl register is written, this bit is automatically cleared to zero, any current conversion is aborted and a new conversion sequence is started. conv8 convert 8/convert 4 select bit 0 C convert 4 channels or one channel 4 times (uses 4 result registers). 1 C convert 8 channels or one channel 8 times, (uses all 8 result registers). scan continuous scan control 0 C perform selected number of conversions (4 or 8) and stop. 1 C convert continuously. mult multiple channel/single channel control 0 C convert single channel selected. 1 C convert the selected number of channels (4 or 8). cd, cc, cb, ca channel select bits when 4-conversion (conv8 = 0) and multiple channel (mult=1) modes are selected, the cb and ca bits have no meaning or effect, and the cd and cc bits specify which of four groups of four channels are to be converted. when 8-conversion (conv8 = 1) and multiple channel (mult=1) modes are selected, the cc, cb and ca bits have no meaning or effect. (refer to table 9-1 for a list of the a/d channel assignments.)
MC68HC11G5 analog-to-digital converter motorola 9-7 9.7.2 result registers (adr1 C adr8) bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 adr1 $ 1 040 7 6 5 4 3 2 1 0 bit7 bit6 0 0 0 0 0 0 $ 1 041 bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 adr2 $ 1 042 bit7 bit6 0 0 0 0 0 0 $ 1 043 bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 adr3 $ 1 044 bit7 bit6 0 0 0 0 0 0 $ 1 045 bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 adr4 $ 1 046 bit7 bit6 0 0 0 0 0 0 $ 1 047 bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 adr5 $ 1 048 bit7 bit6 0 0 0 0 0 0 $ 1 049 bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 adr6 $ 1 04a bit7 bit6 0 0 0 0 0 0 $ 1 04b bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 adr7 $ 1 04c bit7 bit6 0 0 0 0 0 0 $ 1 04d bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 adr8 $ 1 04e bit7 bit6 0 0 0 0 0 0 $ 1 04f undefined reset: read: any time. write: has no meaning or effect. reset: indeterminate. the eight 10-bit result registers are read-only. in each result register, the 8 high order bits are in one address location and the remaining 2 low order bits are in bit locations 6 and 7 of the following address. the 6 unused bits will always read as zeros. this allows a double byte read to be performed without having to adjust the result.
motorola analog-to-digital converter MC68HC11G5 9-8 this page intentionally left blank
MC68HC11G5 pulse width modulation timer motorola 10-1 section 10 pulse width modulation timer 10.1 general overview the pwm module provides up to four 8-bit pulse width modulated waveforms on the port h pins. channel pairs may be concatenated to create 16-bit pwm outputs. three clock sources (a, b and s) give the pwm a wide range of frequencies. figure 10-1 shows the block diagram of the pwm module. each channel also has a separate 8-bit counter register (pwcntx), period register (pwperx), and duty cycle register (pwdtyx). resetting the counter and starting the waveform output is controlled by the occurrence of a match between the period register and the value in the counter. counters may also be reset by writing to them. the duty register changes the state of the output during the period to control the duty cycle of the waveform. the period and duty cycle registers are double buffered so that, if they are changed while the channel is enabled, the change will not take effect until the counter rolls over or the channel is disabled. a new period or duty cycle can be forced by writing to the period or duty cycle register and then writing to the counter. four control registers are used to configure the pwm outputs C pwclk, pwpol, pwscal, and pwen. the pckax and pckbx bits in the pwclk register select the prescale values for the pwm clock sources. pwclk also contains the con34 and con12 bits which enable the 16-bit pwm functions. the pwpol register determines each channels polarity (ppolx bits) and selects the clock source for each channel (pclkx bits). the pwscal register can be programmed with a prescale value which is used to derive a scaled clock based on the a clock source. the pwenx bits in the pwen register enable or disable the pwm channels. with pwms configured for 8-bit mode and e = 2 mhz, pwm signals can be produced from 20 khz (1% duty cycle resolution) to less than 5 hz (approximately 0.4% duty cycle resolution). by configuring the pwms for 16-bit mode with e = 2 mhz, pwm periods greater than one minute can be achieved. in 16-bit mode, duty cycle resolution of almost 15 parts per million can be achieved (at a pwm frequency of about 30 hz). in the same system, a pwm frequency of 1 khz would correspond to a duty cycle resolution of 0.05%.
motorola pulse width modulation timer MC68HC11G5 10-2 12 8 1 2 4 8 mcu e clock select pckb1 pckb2 pckb3 select pcka1 pcka2 8-bit counter 8-bit compare pwscal = reset 2 clock b clock a clock s pclk3 pclk4 pwen3 pwen4 con34 clock select pclk1 pclk2 pwen1 pwen2 con12 clock select port h pin control pw2 bit 1 pwdty1 pwcnt1 pwcnt2 8-bit compare 8-bit compare 8-bit compare 8-bit compare = = = pwdty2 pwper2 pwper1 16-bit pwm control con12 s r q carry reset reset m u x bit 0 pw1 s r q m u x ppol1 ppol2 16 32 64 cnt4 cnt3 cnt2 cnt1 ppol3 pwdty3 8-bit compare 8-bit compare 8-bit compare 8-bit compare = = = = pwdty4 pwper4 pwper3 16-bit pwm control con34 s r q carry reset reset m u x ppol4 pw4 s r q m u x pw3 bit 2 bit 3 q q q q pwdty pwper pwmx pwcnt3 pwcnt4 = figure 10-1. pwm timer module block diagram
MC68HC11G5 pulse width modulation timer motorola 10-3 10.2 clock selection there are three available clocks (a, b and s). clock a can be software-selected to be e, e/ 2, e/4 or e/8. clock b can be software selected to be e, e/2, e/4,..., e/128. the block diagram of figure 10-1 depicts the three different clocks and how the scaled clock is created. the scaled clock (s) uses clock a as an input and divides it with a reloadable counter. this counter is compared with a user programmable scale value (in the pwscal register). when they match, a pulse is output and the 8-bit counter is reset. the output signal from this circuit is then divided by two to give clock s. the rates available for clock s, therefore, are software selectable to be clock a divided by 2 down to clock a divided by 512 in increments of 2. each pwm timer channel can be driven by one of two clocks, selected in software: channels 1 and 2 can use clock a or clock s; channels 3 and 4 can use clock b or clock s. writing to pwscal causes the 8-bit counter to be reset to $00. otherwise, when changing from a low rate to a higher rate, it would be possible for the counter to miss the new value and have to go all the way to $ff and wrap back around before counting at the proper rate. forcing the counter to $00 every time it is written prevents this. 10.3 16-bit pwm function the pwclk register contains two control bits, each of which is used to concatenate a pair of pwm channels into one 16-bit channel. concatenation of channels 3 and 4 is controlled by the con34 bit; similarly, channels 1 and 2 are concatenated using the con12 bit. when channels 3 and 4 are concatenated, channel 3 registers become the high order bytes of the double byte channel. reading the counter high order byte causes the low order byte to be latched for one cycle, to guarantee that double byte reads will be accurate. writing to the low byte of the counter (channel 4) causes the entire counter to be reset. writing to the upper byte of the counter has no effect. similarly, when channels 1 and 2 are concatenated, channel 1 registers become the high order bytes of the double byte channel. the 16-bit duty register and period register are obtained by concatenating the two 8-bit duty registers and period registers, respectively. writing to these registers takes twice as many write cycles as for the 8-bit pwm. the 16-bit pwm circuit has secondary buffers internally, and the user should write to these 16-bit registers using 16-bit write instructions or high byte to low byte sequential write instructions. during the two-byte write sequence, the secondary buffer will not be loaded from the 16-bit register. the 16-bit duty and period registers can be written to at any time; the written value will take effect from the next cycle of the pwm period.
motorola pulse width modulation timer MC68HC11G5 10-4 10.4 boundary cases the following boundary conditions cause these results: if pwdtyx = $00, pwperx > $00, ppolx = 0; the output is always high. if pwdtyx = $00, pwperx > $00, ppolx = 1; the output is always low. if pwdtyx = or > pwperx, ppolx = 0; the output is always low. if pwdtyx = or > pwperx, ppolx = 1; the output is always high. if pwperx = $00 & ppolx = 0; output x is always low. if pwperx = $00 & ppolx = 1; output x is always high. 10.5 pwm registers 10.5.1 counter registers (pwcntx) each channel has its own counter. each counter may be read at any time without affecting the count or the operation of the pwm channel. writing to a counter causes the counter to be reset to $00. generally, writing to a counter is done before the counter is enabled. writing to a counter can also be done while it is enabled (counting), but this may cause a truncated pwm period. bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 pwcnt1 $ 1 064 7 6 5 4 3 2 1 0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 pwcnt2 $ 1 065 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 pwcnt3 $ 1 066 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 pwcnt4 $ 1 067 read: any time. write: forces value to $00. reset: $00. when a channel becomes enabled (i.e. when pwenx is written from 0 to 1), the associated pwm counter starts to count from the value in this pwcntx register, using whichever clock has been selected for that channel.
MC68HC11G5 pulse width modulation timer motorola 10-5 10.5.2 period registers (pwperx) there is one period register for each channel. the value in this register determines the period of the associated pwm timer channel. in terms of the internal pwm circuitry, this register is connected to a buffer which compares with the counter register directly. the period value in this register is loaded into the buffer when the counter is cleared by the termination of the previous period or by a write to the counter. this register can be written at any time, and the written value will take effect from the next pwm timer cycle. reading this register returns the most recent value written. bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 pwper1 $ 1 068 7 6 5 4 3 2 1 0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 pwper2 $ 1 069 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 pwper3 $ 1 06a bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 pwper4 $ 1 06b read: any time. write: any time. reset: $ff. 10.5.3 duty registers (pwdtyx) there is one duty register for each channel. the value in this register determines the duty cycle of the associated pwm timer channel. in terms of the internal pwm circuitry, this register is connected to a buffer which compares with the counter directly. the duty value in this register is loaded into the second buffer when the counter is cleared by previous period termination or the counter write operation. this register can be written at any time, and the written value will take effect from the next pwm timer cycle. reading this register returns the most recent value written.
motorola pulse width modulation timer MC68HC11G5 10-6 note: if the duty register is greater than or equal to the value in the period register there will be no duty change in state. in addition, if the duty register is set to $00 the output will always be in the state which would normally be the state changed to at the duty change of state. refer to the boundary cases section for more information on this. bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 pwdty1 $ 1 06c 7 6 5 4 3 2 1 0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 pwdty2 $ 1 06d bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 pwdty3 $ 1 06e bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 pwdty4 $ 1 06f read: any time. write: any time. reset: $ff. 10.5.4 clock select register (pwclk) pcka2 pcka1 0 pckb3 pckb2 pckb1 pwclk $ 1 060 7 6 5 4 3 2 1 0 0 0 0 0 0 0 reset: con34 con12 0 0 read: any time. write: any time. reset: $00. con34 concatenate channels 3 and 4 1 C channels 3 and 4 are concatenated to create one 16-bit pwm channel. (channel 3 becomes the high order byte and channel 4 becomes the low order byte. the channel 4 output is used as the output for this 16-bit pwm (bit 3 of port h)). 0 C channels 3 and 4 are separate 8-bit pwm channels.
MC68HC11G5 pulse width modulation timer motorola 10-7 con12 concatenate channels 1 and 2 1 C channels 1 and 2 are concatenated to create one 16-bit pwm channel. (channel 1 becomes the high order byte and channel 2 becomes the low order byte. the channel 2 output is used as the output for this 16-bit pwm (bit 1 of port h)). 0 C channels 1 and 2 are separate 8-bit pwm channels. pcka2, pcka1 prescaler for clock a clock a is one of two clock sources which may be used for channels 1 & 2. these two bits determine the rate of clock a. pcka2 pcka1 value of clock a 00e 01e/2 10e/4 11e/8 pckb3, pckb2, pckb1 prescaler for clock b clock b is one of two clock sources which may be used for channels 3 & 4. these three bits determine the rate of clock b. pckb3 pckb2 pckb1 value of clock b 000e 001e/2 010e/4 011e/8 1 0 0 e/16 1 0 1 e/32 1 1 0 e/64 1 1 1 e/128
motorola pulse width modulation timer MC68HC11G5 10-8 10.5.5 polarity select register (pwpol) each channel has a polarity bit (ppolx) to start the cycle with a high signal or with a low signal. this is shown on the block diagram as a multiplex select of either the q output or the q output of the pwm output flip-flop. when one of the bits in the pwpol register is set, the associated pwm channel output is high at the beginning of the clock cycle, then goes low when the duty count is reached. pclk4 pclk3 pclk2 pclk1 pwpol $ 1 061 7 6 5 4 3 2 1 0 0 0 0 0 reset: ppol4 ppol3 ppol2 ppol1 0 0 0 0 read: any time. write: any time. reset: $00 pclk4 ?pulse width channel 4 clock select 1 the clock source for pwm channel 4 is clock s. (clock s equals clock a divided by two times the value (plus one) in the pwscal register.) 0 clock b is the clock source for pwm channel 4. pclk3 ?pulse width channel 3 clock select 1 the clock source for pwm channel 3 is clock s. 0 clock b is the clock source for pwm channel 3. pclk2 ?pulse width channel 2 clock select 1 the clock source for pwm channel 2 is clock s. 0 clock a is the clock source for pwm channel 2. pclk1 ?pulse width channel 1 clock select 1 the clock source for pwm channel 1 is clock s. 0 clock a is the clock source for pwm channel 1. note: while register bits pclk1 ?4 may be written at any time, if a clock select is changed while a pwm signal is being generated, a truncated pulse may occur during the transition. ppol4 ?pulse width channel 4 polarity 1 pwm channel 4 output is high at the beginning of the clock cycle, then goes low when the duty count is reached. 0 pwm channel 4 output is low at the beginning of the clock cycle, then goes high when the duty count is reached.
MC68HC11G5 pulse width modulation timer motorola 10-9 ppol3 pulse width channel 3 polarity 1 C pwm channel 3 output is high at the beginning of the clock cycle, then goes low when the duty count is reached. 0 C pwm channel 3 output is low at the beginning of the clock cycle, then goes high when the duty count is reached. ppol2 pulse width channel 2 polarity 1 C pwm channel 2 output is high at the beginning of the clock cycle, then goes low when the duty count is reached. 0 C pwm channel 2 output is low at the beginning of the clock cycle, then goes high when the duty count is reached. ppol1 pulse width channel 1 polarity 1 C pwm channel 1 output is high at the beginning of the clock cycle, then goes low when the duty count is reached. 0 C pwm channel 1 output is low at the beginning of the clock cycle, then goes high when the duty count is reached. 10.5.6 scale register (pwscal) bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 pwscal $ 1 062 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: read: any time. write: any time (causes clock counter to be reset to $00). reset: $00 each of the pwm channels can select clock s (scaled) as its input clock. clock s may be selected for channel x by writing a one to the control bit pclkx. clock s is generated by taking clock a, dividing it by the value in this pwscal register and dividing that by two. when pwscal = $00, clock a is divided by 256 then divided by two to generate clock s. in test mode, the pwscal register can be used to read the value of clock s (scaled) if the tpwsl bit in the test1 register is set.
motorola pulse width modulation timer MC68HC11G5 10-10 10.5.7 enable register (pwen) each timer has an enable bit (pwenx) to start its waveform output. writing any of these pwenx bits to one causes the associated port h line to become an output regardless of the state of the associated ddr bit. this does not change the state of the ddr bit and, when pwenx returns to zero, the ddr bit again controls the i/o state. on the front end of the pwm timer the clock is enabled to the pwm circuit by the pwenx enable bit being high. a synchronizing circuit guarantees that the clock will only be enabled or disabled at an edge. 0 0 0 0 pwen4 pwen3 pwen2 pwen1 pwen $ 1 063 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: read: any time. write: any time. reset: $00. pwen4 ?pulse width channel 4 enable 1 pwm channel 4 is enabled. the pulse modulated signal becomes available at port h bit 3 when its clock source begins its next cycle. 0 pwm channel 4 is disabled. pwen3 ?pulse width channel 3 enable 1 pwm channel 3 is enabled. the pulse modulated signal becomes available at port h bit 2 when its clock source begins its next cycle. 0 pwm channel 3 is disabled. pwen2 ?pulse width channel 2 enable 1 pwm channel 2 is enabled. the pulse modulated signal becomes available at port h bit 1 when its clock source begins its next cycle. 0 pwm channel 2 is disabled. pwen1 ?pulse width channel 1 enable 1 pwm channel 1 is enabled. the pulse modulated signal becomes available at port h bit 0 when its clock source begins its next cycle. 0 pwm channel 1 is disabled.
MC68HC11G5 event counter motorola 11-1 section 11 event counter 11.1 introduction the event counter consists of two distinct functional blocks. one block functions as an 8-bit pulse accumulator unit (pa), the other as an 8-bit pulse width modulation unit (pwm). each unit has its own 8-bit counter and two 8-bit compare registers. four software selectable operating modes provide different configurations of the pa and pwm, their interconnection and their combined operation. (the operating mode is selected using the event counter mode select bits, evmda and evmdb in the event counter lock register (evclk)). all four modes provide programmable pwm period, duty cycle and polarity. note that these pwm circuits differ from the main pwm section in that these can be driven by an external signal. a simplified block diagram of each mode is shown in figure 11-1. in mode 0, the pa unit can modify the pwm output by adding a programmable offset to the input signal and by controlling the clearing of the pwm unit, thereby controlling the period of the output signal. in mode 1, the event counter operates as separate pwm and pa units. the two units are not interconnected and operate completely independently of each other, providing standard programmable pwm and pa functions. in mode 2, the pa unit counts the pwm output signal periods, which may be of varying duration and modulation. in mode 3, the pa unit acts as a programmable 8-bit (1 C 256 clock) prescaler for the pwm unit. the 8-bit counters in the pwm and pa units can be driven by an external clock or by a derivative of the e-clock (e or scaled e), generated by the on-chip time-base counter. the clock source is controlled by two input selectors (input1 and input2). depending on the mode of operation selected, the input selectors are used to determine the following: 1) clock source, 2) active edge of the external signal (which may be used as a clock), 3) the gated input of the internal clock, 4) counter clear one output selector is used to control the polarity of the pwm output signal.
motorola event counter MC68HC11G5 11-2 pulse accumulator modifies pwm output by adding offset and controlling the clearing of the pwm mode 0: input2 input1 pa pwm output * * l input2 input1 pa pwm output * * pa and pwm are completely independent mode 1: input2 input1 pa pwm output * * pa counts the pwm periods (which may be of variable duration and modulation) mode 2: input2 input1 pa pwm output * * pa acts as programmable 8-bit prescaler for pwm unit mode 4: * input1 and input2 can be driven from the e-clock, a second value of the e-clock or from external signals on the evi2 and evi1 input pins. when evi2 or evi1 is not being used for this purpose they may be used as general i/o pins (ph4 and ph5). figure 11-1. event counter operating modes each unit can generate an interrupt signal (referred to as event1 or event2 in the following discussion) on a counter match with one of its two compare registers. the pwm unit is comprised of counter 1 (evcnt1), two compare registers (ecmp1a and ecmp1b), an input selector (input1) and an output selector. the pa unit is comprised of counter 2 (evcnt2), two compare registers (ecmp2a and ecmp2b) and an input selector (input2).
MC68HC11G5 event counter motorola 11-3 11.2 mode 0: 8-bit pwm with selectable phase shift in mode 0, the event counter operates as an 8-bit pwm unit with an 8-bit phase shifter. if mode 0 is selected (evmdb = 0, evmda = 0), then the elements of the event counter are configured as shown in figure 11-2. evi2 (ph4) input2 clear ecmp2b x z event2 clear evcnt1 ecmp1b input1 e e/2 e/4 e/8 e/16 e/32 e/64 e/128 y x ' r s event1 (ph6) evo evi2 evcnt2 evo x ' y-x ' 8 8 8 8 x y y-x ' evcnt2 ecmp2a evi1(ph5) ecmp1a figure 11-2. 8-bit pwm with selectable phase shift (mode 0) 11.2.1 operation of pwm and pa unit in mode 0 the period of the modulated output is controlled by an external signal applied to the evi2 pin. the active edge of this input signal is selected via the input2 selector. this input signal clears evcnt2 in the pa unit and starts the 8-bit phase shift sequence.
motorola event counter MC68HC11G5 11-4 the two counter registers (evcnt1 and evcnt2) are clocked by the same signal via the input1 selector. this clock signal can be the e-clock, a scaled e-clock or an external signal applied to the evi1 pin. if the clock signal is the e-clock or a derivative, an external gating signal can be applied to evi1. if evi1 is not used for clock or gate, it can be used as a normal i/o pin (ph5). the 8-bit phase shift value (x) is stored in ecmp2a (in the pa unit). when the count in evcnt2 reaches this value, the successful compare causes a clearing signal to be applied to evcnt1 in the pwm unit and starts the pwm sequence. the value of the output pulse width (y) is stored in ecmp1a, however the start time and the duration of this pulse can be modified by a skew value (x) which is stored in ecmp1b. if no skew is included, i.e. ecmp1b is set to zero, then a compare occurs when evcnt1 is cleared, and the output signal changes state immediately after the initial phase shift period x introduced by the pa unit. the effect of storing a skew value (x) in ecmp1b is to delay the leading edge of the pwm output pulse by the phase shift plus the skew value (x+x). the trailing edge of the output pulse is generated when there is a match between evcnt1 and ecmp1a (x + y). note that the skew value does not affect the timing of the trailing edge of the output pulse, but only the leading edge. consequently the output pulse width is reduced by the skew value from y to y-x. a maskable interrupt signal event1 is generated when there is a match between evcnt1 and ecmp1a. a clearing signal on the evi2 pin clears evcnt2 in the pa unit and restarts the sequence. ecmp2b can be used to generate an interrupt signal, event2, when evcnt2 accumulates a desired number of clock pulses. 11.2.2 register functions in mode 0 11.2.2.1 counter 1 (evcnt1) this counter drives the pwm section of the event counter. it is cleared by a successful comparison between ecmp2a and evcnt2. the source chosen by input selector input1 is used as the clock input to both counters (evcnt1 and evcnt2). the width and time of the output pulse is determined by the value in this counter matching the values in ecmp1a and ecmp1b. 11.2.2.2 compare register 1a (ecmp1a); (y) this compare register holds the nominal value of the output pulse width. note that the actual output pulse width value will be equal to the value contained in ecmp1a minus the skew value which is held in event compare register 1b (ecmp1b). an interrupt signal, event1 is generated when there is a match between ecmp1a and evcnt1. 11.2.2.3 compare register 1b (ecmp1b); (x) this compare register holds a value which adjusts the phase skew between the external signal (on evi2) and the leading edge of the desired output signal. if the value in this register is zero, then the actual pulse width depends only on the value y in ecmp1a. if the value in this register is equal to
MC68HC11G5 event counter motorola 11-5 the value y in ecmp1a, the event output (evo) will always be low (when evpol = 0). note that this skew value should be a smaller value than the minimum value of the pulse width y. (if the value in this register is larger than the value y in ecmp1a, it is possible to miss a pulse in one cycle and the following cycle will be reversed in polarity cycle, which is equivalent to exchanging x and y in figure 11-2.). 11.2.2.4 counter 2 (evcnt2) this counter is cleared by the external signal on the evi2 pin. the source chosen by input selector input1 is used as the clock input to both counters (evcnt1 and evcnt2). this counter is used to control the amount of phase shift between the external signals active edge and the start of the pwm output signal, using ecmp2a. a successful compare with compare register 2b will cause an interrupt request 2 (event2) to be generated. 11.2.2.5 compare register 2a (ecmp2a); (x) this compare register holds the value of the phase shift between the external signal active edge (or level) and the pwm output signal. note that this phase shift value is added to the skew value held in ecmp1b to determine the timing of the leading edge of the pwm output pulse. if the value in this register is zero, then the active edge of the external signal on evi2 will reset evcnt1 immediately and there will be no phase shift, only skew. 11.2.2.6 compare register 2b (ecmp2b) this compare register can be used to generate an interrupt when the pa unit has accumulated a desired number of clock pulses. when a match occurs between evcnt2 and ecmp2b, an interrupt signal event2 is generated which, if enabled, will interrupt the cpu. 11.2.2.7 input unit 1 (evi1) this unit selects the clock source for evcnt1 and evcnt2. if the input signal on the evi1 pin (ph5) is used as a clock source, this unit will select the rising edge, falling edge or both edges of the input signal. if the e-clock or a scaled e-clock is selected as the clock source, this unit controls the active gated input level which inhibits counting. even if ph5 is used for general purpose i/o, this unit is able to select the pass mode (evi1c = 0, evi1b = 0, evi1a = 1). 11.2.2.8 input unit 2 (evi2) this unit selects the active edge or level of the input signal on the evi2 pin (ph4) which will reset evcnt2 (to zero). 11.2.2.9 output unit (evo) this unit controls the polarity of the pwm output signal. with the evoen (event output enable) bit in the evctl register set to one, the evpol (event output polarity) bit determines the polarity of the pwm output.
motorola event counter MC68HC11G5 11-6 11.3 mode 1: 8-bit pwm and pulse accumulator in mode 1, the event counter operates as two independent 8-bit pulse accumulators or as one 8- bit pulse accumulator and one 8-bit pwm. the two counters work independently of each other. if mode 1 is selected (evmdb = 0, evmda = 1), then the elements of the event counter are configured as shown in figure 11-3. evi2 (ph4) input2 clear evcnt2 ecmp2a ecmp2b 8 8 event2 clear evi1(ph5) evcnt1 ecmp1a ecmp1b input1 e e/2 e/4 e/8 e/16 e/32 e/64 e/128 r s event1 (ph6) evo e 8 8 figure 11-3. 8-bit pwm and pulse accumulator (mode 1)
MC68HC11G5 event counter motorola 11-7 both units can be driven by the e-clock, a scaled e-clock or by external signals applied to the evi1 and evi2 pins. however, note that only one scaled value of the e-clock can be selected. for example, if e/4 is selected as the clock source for evcnt1, the only e-clock derivatives that can be chosen as the clock source for evcnt2 are e and e/4. alternatively, if e/4 is selected to drive evcnt2, then e/4 is the only e-clock derivative that can be selected to drive evcnt1. 11.3.1 operation of pulse width modulation unit in mode 1 the pwm unit can be clocked by the e-clock, a scaled e-clock, or an external signal applied to the evi1 (ph5) pin. alternatively an external signal on evi1 can be used to gate the e-clock or scaled e-clock signal to the counter evcnt1. the clock source is selected via the input1 selector. the period of the pwm output signal is determined by the value stored in ecmp1a. when a match occurs between this compare register and the counter register, evcnt1, the output unit evo is reset and evcnt1 is cleared (to zero). at the same time, an interrupt signal event1 is generated which, if enabled, interrupts the cpu. the duty cycle of the pwm output signal is determined by the relationship between the values stored in ecmp1b and ecmp1a. the value stored in ecmp1b is the number of clock pulses to be accumulated by evcnt1 before the output signal changes state. the output signal then remains in the new state for the remainder of the period, i.e. until evcnt1 reaches the value stored in ecmp1a. the duty cycle can be expressed as a percentage of the period by the following equation: duty cycle = 100 x [1 - (ecmp1b)/(ecmp1a)] % the pwm unit will also work as a pulse accumulator by switching off the output signal to the evo pin (ph6) and ignoring ecmp1b. 11.3.2 operation of pulse accumulator unit in mode 1 the pa unit can be clocked by the e-clock, a scaled e-clock, or an external signal applied to the evi2 (ph4) pin. alternatively an external signal on evi2 can be used to gate the e-clock or scaled e-clock signal to the counter evcnt1. the clock source is selected via the input2 selector. evcnt2 counts the pulses coming from the input2 selector. it is cleared by a successful comparison between itself and the compare register ecmp2a. ecmp2a can be programmed with any 8-bit value to control the time when the counter is cleared. ecmp2b can be used to generate an interrupt signal event2 after a required number of input pulses have been accumulated by evcnt2. if enabled, event2 will interrupt the cpu. 11.3.3 register functions in mode 1 11.3.3.1 counter 1 (evcnt1) evcnt1 counts the number of pulses coming from the input1 selector. it is cleared by a successful comparison between itself and ecmp1a.
motorola event counter MC68HC11G5 11-8 11.3.3.2 compare register 1a (ecmp1a) this compare register holds the value of the pwm period which determines when interrupt 1 (event1) occurs. on a successful comparison with evcnt1, it generates event1, clears evcnt1 and resets output evo to zero (when evpol = 0). 11.3.3.3 compare register 1b (ecmp1b) this compare register holds the duty value which determines when the output (evo) is set to one (when evpol = 0). the duty cycle can be expressed as a percentage of the period by the following equation: duty cycle = 100 x [1 - (ecmp1b)/(ecmp1a)] % 11.3.3.4 counter 2 (evcnt2) evcnt2 counts the number of pulses coming from the input2 selector. it is cleared by a successful comparison between itself and ecmp2a. 11.3.3.5 compare register 2a (ecmp2a) this compare register holds the number of the pulses to be accumulated by evcnt2 before evcnt2 is cleared to zero. 11.3.3.6 compare register 2b (ecmp2b) this compare register holds the number of the pulses to be accumulated by evcnt2 before an interrupt signal event2 is generated. if enabled, event2 will interrupt the cpu. 11.3.3.7 input unit 1 (evi1) this input unit selects the clock source for evcnt1. if the input signal evi1 (ph5) is used as a clock source, this unit will select the rising edge, falling edge or both edges of the input signal. if the time- base counter is used as a clock source, this unit will select the active gated input level which inhibits counting while this input signal is at the active level. 11.3.3.8 input unit 2 (evi2) this input unit selects the clock source for evcnt2. if the input signal evi2 (ph4) is used as a clock source, this unit will select the rising edge or falling edge of the input signal. if the time base counter is used as a clock source, this unit will select the active gate input level which inhibits counting while this input signal is at the active level. even if the time-base counter has selected one of the eight clock rates (e, e/2, e/4, e/8, e/16, e/32, e/64, or e/128), this input selector can select the e-clock independently as its clock source.
MC68HC11G5 event counter motorola 11-9 11.3.3.9 output unit (evo) this unit controls the output signal from the pwm unit. if the evoen bit in the evctl register is set to one, the evo unit is enabled. the state of the evpol bit in the evctl register then determines the polarity of the event output. if evo is not required for pulse width modulation, the evoen bit should be reset to zero to disable the evo unit and to allow pin ph6 to be used for general purpose i/o. 11.4 mode 2: 8-bit pwm with period counter in mode 2, the event counter operates as an 8-bit pwm unit and an 8-bit counter (the pa unit) which increments at the end of each period of the pwm unit. if mode 2 is selected (evmdb = 1, evmda = 0), then the elements of the event counter are configured as shown in figure 11-4. clear evcnt2 ecmp2a ecmp2b event2 clear evi1(ph5) evcnt1 8 ecmp1a ecmp1b input1 e e/2 e/4 e/8 e/16 e/32 e/64 e/128 r s event1 (ph6) evo 8 8 8 figure 11-4. 8-bit pwm with period counter (mode 2)
motorola event counter MC68HC11G5 11-10 the only difference between this mode and mode 1 lies in the clock source used to drive the counter in the pa unit (evcnt2). in mode 1, the clock signal comes via the input1 selector and is either derived from the e-clock (gated or ungated) or an external signal. in mode 2, the signal which results from a successful comparison between evcnt1 and ecmp1a in the pwm unit is used to drive evcnt2 in the pa unit. this is the same signal which clears evcnt1, thereby ending the pwm period. evcnt2, therefore, counts the number of periods completed by the pwm unit. 11.4.1 operation of pulse width modulation unit in mode 2 the pwm unit can be clocked by the e-clock, a scaled e-clock, or an external signal applied to the evi1 (ph5) pin. alternatively an external signal on evi1 can be used to gate the e-clock or scaled e-clock signal to the counter evcnt1. the clock source is selected via the input1 selector. the period of the pwm output signal is stored in ecmp1a. when a match occurs between this compare register and the counter register, evcnt1, the output unit evo is reset, evcnt1 is cleared (to zero) and evcnt2 in the pa is incremented by one. at the same time, an interrupt signal event1 is generated which, if enabled, interrupts the cpu. the duty cycle of the pwm output signal is stored in ecmp1b. when a match occurs between this compare register and evcnt1, the pwm output signal changes state (from zero to one or from one to zero depending on the polarity selected by the output unit. duty cycle = 100 x [1 - (ecmp1b)/(ecmp1a)] % the pwm unit will also work as a pulse accumulator by switching off the output signal to the evo pin (ph6) and ignoring ecmp1b. 11.4.2 operation of pulse accumulator unit in mode 2 the pa unit is clocked each time there is a successful comparison between evcnt1 and ecmp1a in the pwm unit, i.e. at the end of each pwm period. evcnt2 counts the pulses coming from the pwm unit. it is cleared by a successful comparison between itself and the compare register ecmp2a. ecmp2a can be programmed with any 8-bit value to control the time when the counter is cleared. ecmp2b can be used to generate an interrupt signal event2 after a required number of input pulses have been accumulated by evcnt2. if enabled, event2 will interrupt the cpu. 11.4.3 register functions in mode 2 11.4.3.1 counter 1 (evcnt1) evcnt1 counts the number of pulses coming from the input1 selector. it is cleared by a successful comparison between itself and ecmp1a.
MC68HC11G5 event counter motorola 11-11 11.4.3.2 compare register 1a (ecmp1a) this compare register holds the value of the pwm period which determines when interrupt 1 (event1) occurs. on a successful comparison with evcnt1, it generates event1, clears evcnt1, resets output evo to zero (when evpol = 0) and clocks evcnt2 in the pa unit. 11.4.3.3 compare register 1b (ecmp1b) this compare register holds the pwm duty value which determines when the output (evo) is set to one (when evpol = 0). duty cycle = 100 x [1 - (ecmp1b)/(ecmp1a)] % 11.4.3.4 counter 2 (evcnt2) evcnt2 counts the number of pulses coming from the pwm unit. it is cleared when a successful comparison occurs between itself and ecmp2a. 11.4.3.5 compare register 2a (ecmp2a) this compare register holds the number of the pulses to be accumulated by evcnt2 before evcnt2 is cleared to zero. 11.4.3.6 compare register 2b (ecmp2b) this compare register holds the number of the pulses to be accumulated by evcnt2 before an interrupt signal event2 is generated. if enabled, event2 will interrupt the cpu. 11.4.3.7 input unit 1 (evi1) this input unit selects the clock source for evcnt1. if the input signal evi1 (ph5) is used as a clock source, this unit will select the rising edge, falling edge or both edges of the input signal. if the time base counter is used as a clock source, this unit will select the active gated input level which inhibits counting while this input signal is at the active level. 11.4.3.8 input unit 2 (evi2) this unit is not used and the evi2 pin (ph4) can be used as a general purpose i/o pin. 11.4.3.9 output unit (evo) this unit controls the output signal from the pwm unit. if the evoen bit in the evctl register is set to one, the evo unit is enabled. the state of the evpol bit in the evctl register then determines the polarity of the event output. if evo is not required for pwm, the evoen bit should be reset to zero to disable the evo unit and to allow pin ph6 to be used for general purpose i/o.
motorola event counter MC68HC11G5 11-12 11.5 mode 3: 8-bit pwm with 256 clock prescaler in mode 3, the event counter operates as an 8-bit pwm unit with a software programmable 8-bit clock prescaler (the pa unit). if mode 3 (evmdb = 1, evmda = 1) is selected then the elements of the event counter are configured as shown in figure 11-5. the only difference between this mode and mode 1 lies in the clock source used to drive the counter in the pwm unit (evcnt1). in mode 1, the clock signal comes via the input2 selector and is either derived from the e-clock (gated or ungated) or an external signal. in mode 3, the signal which results from a successful comparison between evcnt2 and ecmp2a in the pa unit is used to drive evcnt1 in the pwm unit. evcnt1, therefore, increments by one every time the value in evcnt2 reaches the value programmed into ecmp2a. in other words, the pa unit acts as a prescaler to the pwm unit, its division ratio being the 8-bit value in ecmp2a. 11.5.1 operation of pulse width modulation unit in mode 3 the pwm unit is clocked each time there is a successful comparison between evcnt2 and ecmp2a in the pa unit, i.e. at the end of each pa counting period. the period of the pwm output signal is stored in ecmp1a. when a match occurs between this compare register and the counter register, evcnt1, the output unit evo is reset and evcnt1 is cleared (to zero). at the same time, an interrupt signal event1 is generated which, if enabled, interrupts the cpu. the duty cycle of the pwm output signal is stored in ecmp1b. when a match occurs between this compare register and evcnt1, the pwm output signal changes state (from zero to one or from one to zero depending on the polarity selected by the output unit.
MC68HC11G5 event counter motorola 11-13 evi2 (ph4) input2 clear evcnt2 ecmp2a ecmp2b 8 8 event2 clear evcnt1 8 8 ecmp1a ecmp1b e e/2 e/4 e/8 e/16 e/32 e/64 e/128 r s event1 (ph6) evo figure 11-5. 8-bit pwm with 256 clock prescaler (mode 3) the pwm unit will also work as a pulse accumulator by switching off the output signal to the evo pin (ph6) and ignoring ecmp1b. 11.5.2 operation of pulse accumulator unit in mode 3 the pa unit can be clocked by the e-clock, a scaled e-clock, or an external signal applied to the evi2 (ph4) pin. alternatively an external signal on evi2 can be used to gate the e-clock or scaled e-clock signal to the counter evcnt2. the clock source is selected via the input2 selector. evcnt2 counts the clock pulses coming from the input2 selector. it is cleared by a successful comparison between itself and the compare register ecmp2a. ecmp2a can be programmed with
motorola event counter MC68HC11G5 11-14 any 8-bit value to define when the counter is cleared and the pwm clocked. it causes the pa unit to act as a prescaler for the pwm by dividing the clock signal, coming via input2, by any value between 1 and 256. ecmp2b can be used to generate an interrupt signal event2 after a required number of input pulses have been accumulated by evcnt2. if enabled, event2 will interrupt the cpu. 11.5.3 register functions in mode 3 11.5.3.1 counter 1 (evcnt1) evcnt1 counts the number of pulses coming from the pa unit. it is cleared by a successful comparison between itself and ecmp1a. 11.5.3.2 compare register 1a (ecmp1a) this compare register holds the value of the pwm period which determines when interrupt 1 (event1) occurs. on a successful comparison with evcnt1, it generates event1, clears evcnt1 and resets output evo to zero (when evpol = 0). 11.5.3.3 compare register 1b (ecmp1b) this compare register holds the pwm duty value which determines when the output (evo) is set to one (when evpol = 0). duty cycle = 100 x [1 - (ecmp1b)/(ecmp1a)] % 11.5.3.4 counter 2 (evcnt2) evcnt2 counts the number of clock pulses coming from the input2 selector. it is cleared when a successful comparison occurs between itself and ecmp2a. 11.5.3.5 compare register 2a (ecmp2a) this compare register holds the number of the pulses to be accumulated by evcnt2 before evcnt2 is cleared to zero. 11.5.3.6 compare register 2b (ecmp2b) this compare register holds the number of the pulses to be accumulated by evcnt2 before an interrupt signal event2 is generated. if enabled, event2 will interrupt the cpu. 11.5.3.7 input unit 1 (evi1) this unit is not used and the evi1 pin (ph5) can be used as a general purpose i/o pin.
MC68HC11G5 event counter motorola 11-15 11.5.3.8 input unit 2 (evi2) this input unit selects the clock source for evcnt2. if the input signal evi2 (ph4) is used as a clock source, this unit will select the rising edge or falling edge of the input signal. if the time base counter is used as a clock source, this unit will select the active gate input level which inhibits counting while this input signal is at the active level. even if the time base counter has selected one of the eight clock rates (e, e/2, e/4, e/8, e/16, e/32, e/64, or e/128), this input selector can select the e-clock independently as its clock source. 11.5.3.9 output unit (evo) this unit controls the output signal from the pwm unit. if the evoen bit in the evctl register is set to one, the evo unit is enabled. the state of the evpol bit in the evctl register then determines the polarity of the event output. if evo is not required for pwm, the evoen bit should be reset to zero to disable the evo unit and to allow pin ph6 to be used for general purpose i/o. 11.6 event counter registers 11.6.1 counter clock register (evclk) evmdb evmda evckc evckb evcka evclk $ 1 070 7 6 5 4 3 2 1 0 0 0 0 0 0 0 reset: 0 0 read: any time. write: any time. reset: $00. evmdb, evmda event counter mode bits these two bits determine which event counter mode will be used. evmdb evmda mode 0 0 0 (8-bit pwm with selectable phase shift) 0 1 1 (8-bit pwm and 8-bit pulse accumulator) 1 0 2 (8-bit pwm with period counter) 1 1 3 (8-bit pwm with 256 clock prescaler) evckc, evckb, evcka event counter prescaler bits these three bits control the time-base counter. they select the prescaler value used to scale the e-clock before driving the event counters.
motorola event counter MC68HC11G5 11-16 evckc evckb evcka prescaled clock 000 e 001 e/2 010 e/4 011 e/8 1 0 0 e/16 1 0 1 e/32 1 1 0 e/64 1 1 1 e/128 11.6.2 counter control register (evctl) evoen evpol evi2c evi2b evctl $ 1 071 7 6 5 4 3 2 1 0 0 0 0 0 reset: evi2a evi1c evi1b evi1a 0 0 0 0 read: any time. write: any time. reset: $00. evoen event output enable (port h, bit 6) 1 C ph6 is used as event output. 0 C ph6 is used as a general purpose i/o. evpol event output polarity 1 C event output (evo) will be set (to one) when ecmp1a matches, and cleared (to zero) when ecmp1b matches. 0 C event output (evo) will be set (to one) when ecmp1b matches, and cleared (to zero) when ecmp1a matches. evi2c, evi2b, evi2a event input select 2 (evi2) these three bits determine the function of event input unit 2 as shown in the following tables. the following table applies to modes 1 and 3 only: evi2c evi2b evi2a ph4 clock source count mode 0 0 0 i/o count stop 0 0 1 i/o scaled e count always 0 1 0 evi2 scaled e inhibit counting on evi2 = 0 0 1 1 evi2 scaled e inhibit counting on evi2 = 1 1 0 0 evi2 external count on falling edge of evi2 1 0 1 evi2 external count on rising edge of evi2 1 1 0 evi2 e-clock inhibit counting on evi2 = 0 1 1 1 evi2 e-clock inhibit counting on evi2 = 1
MC68HC11G5 event counter motorola 11-17 the following table applies to mode 0 only: evi2c evi2b evi2a clear input mode for evcnt2 0 x x not used 1 0 0 falling edge of evi2 (ph4) 1 0 1 rising edge of evi2 (ph4) 1 1 0 logic high (1) level on evi2 1 1 1 logic low (0) level on evi2 in mode 0, evi2 is used as a clear input to (evcnt2). note: in mode 2, these three bits should be reset to zero to allow ph4 to be used as an i/o port. evi1c, evi1b, evi1a event input select 1 (evi1) these three bits determine the operation of event input unit 1 as shown in the following table. the following table applies to modes 0, 1 and 2 only: evi1c evi1b evi1a ph5 clock source count mode 0 0 0 i/o count stop 0 0 1 i/o scaled e count always 0 1 0 evi1 scaled e inhibit counting on evi1 = 0 0 1 1 evi1 scaled e inhibit counting on evi1 = 1 1 0 0 evi1 external count on falling edge of evi1 1 0 1 evi1 external count on rising edge of evi1 1 1 x evi1 external count on both falling and rising edges of evi1 note: in mode 3, these three bits should be reset to zero to allow ph5 to be used as an i/o port. 11.6.3 counters enable/interrupt mask register (evmsk) evcen ev2i ev1i evmsk $ 1 072 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: read: any time. write: any time. reset: $00. evcen event counters enable 0 C event counters evcnt1 and evcnt2 are cleared. also the event output (evo) is cleared to a logic low level (when evpol = 0 and evoen = 1). the evclk and evctl registers should be written while this bit is 0. 1 C event counters are enabled.
motorola event counter MC68HC11G5 11-18 ev2i event 2 interrupt enable 0 C interrupt inhibited. 1 C hardware interrupt requested when ev2f flag set. ev1i event 1 interrupt enable 0 C interrupt inhibited. 1 C hardware interrupt requested when ev1f flag set. 11.6.4 interrupt flag register (evflg) ev2f ev1f evflg $ 1 073 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 reset: read: any time. write: used as clearing mechanism (bits set cause corresponding bits to be cleared). reset: $00. ev2f event interrupt 2 flag set by a successful match of evcnt2 and ecmp2b. this bit is cleared automatically by a write to the evflg register with bit 1 set. ev1f event interrupt 1 flag set by a successful match of evcnt1 and ecmp1a. this bit is cleared automatically by a write to the evflg register with bit 0 set. 11.6.5 counter registers (evcntx) bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 evcnt1 $ 1 074 7 6 5 4 3 2 1 0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 evcnt2 $ 1 075 u u u u u u u u reset: read: any time. write: forces value to $00. reset: indeterminate.
MC68HC11G5 event counter motorola 11-19 11.6.6 counter compare registers (ecmpx) bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 ecmp1a $ 1 076 7 6 5 4 3 2 1 0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 ecmp2a $ 1 077 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 ecmp1b $ 1 078 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 ecmp2b $ 1 079 1 1 1 1 1 1 1 1 reset: read: any time. write: any time. reset: $ff. compare registers ecmp1a and ecmp1b are associated with counter evcnt1. compare registers ecmp2a and ecmp2b are associated with counter evcnt2. 11.7 pwm using the event counter the pwm function of the event counter differs from the main pwm (discussed in section 10) in that it has no double buffered duty and period registers. this means that it is possible to generate a cycle in which there is no duty change of state. this occurs when the duty value written is lower than the previous value, but the counter is already past the new value. in this case the counter register will increment all the way to the period count, roll over to $00 and count up to the new duty value before matching. this situation can be avoided by using the event interrupts to help calculate, in software, the correct values of duty and period to be written to the compare registers. 11.8 effective range of the set up values in mode 0: ecmp1a and ecmp1b: 0 to 255 ($00 to $ff) ecmp2a and ecmp2b: 0 to 255 ($00 to $ff) in modes 1, 2 and 3: ecmp1a and ecmp1b: 1 to 255 ($01 to $ff) (these values follow the boundary conditions of the pwm function.) ecmp2a and ecmp2b: 1 to 255 to 256 ($01 to $ff to $00).
motorola event counter MC68HC11G5 11-20 11.9 boundary conditions of the pwm function the pwm function (in modes 1, 2, and 3) follows the boundary conditions described below. the period is determined by the value in the ecmp1a register (8-bit). the duty value is determined by the values in the ecmp1a and ecmp1b registers (8-bit). if duty = 0, period > 0, evpol = 0 and evoen = 1; ph6 is always high. if duty = 0, period > 0, evpol = 1 and evoen = 1; ph6 is always low. if duty period, evpol = 0 and evoen =1; ph6 is always low. if duty period, evpol = 1 and evoen =1; ph6 is always high. if period = 0, evpol = 0 and evoen =1; ph6 is always low. if period = 0, evpol = 1 and evoen =1; ph6 is always high. if evoen = 0; ph6 is i/o port under the control of ddrh bit 6.
MC68HC11G5 cpu, addressing modes and instruction set motorola 12-1 section 12 cpu, addressing modes and instruction set this section discusses the m68hc11 central processing unit (cpu) architecture, its addressing modes and the instruction set (by instruction type). everything discussed in this section applies to the MC68HC11G5. for more detailed information on the instruction set, refer to the m68hc11 reference manual (m68hc11rm/d). 12.1 programming model and cpu registers in addition to being able to execute all m6800 and m6801 instructions, the MC68HC11G5 uses a 4-page opcode map to allow execution of 91 new opcodes (see 12.3: instruction set ). seven registers, shown in figure 12-1 and discussed in the following paragraphs, are available to programmers. accumulator a accumulator b 7 15 15 15 15 15 07 0 0 0 0 0 0 0 sxh i nzvc double accumulator d index register x index register y stack pointer program counter 7 condition code register carry overflow zero negative i interrupt mask half-carry (from bit 3) x interrupt mask stop disable a:b d ix iy sp pc ccr figure 12-1. programming model
motorola cpu, addressing modes and instruction set MC68HC11G5 12-2 12.1.1 accumulators a and b accumulator a and accumulator b are general purpose 8-bit registers used to hold operands and results of arithmetic calculations or data manipulations. these two accumulators can be concatenated into a single 16-bit accumulator called accumulator d. 12.1.2 index register x (ix) the 16-bit ix register is used for indexed mode addressing. it provides a 16-bit indexing value which is added to an 8-bit offset provided in an instruction to create an effective address. the ix register can also be used as a counter or as a temporary storage register. 12.1.3 index register y (iy) the 16-bit iy register is also used for indexed mode addressing, similar to the ix register; however, all instructions using the iy register have a 2-byte opcode and require an extra cycle of execution time. 12.1.4 stack pointer (sp) the stack pointer (sp) is a 16-bit register which contains the address of the next free location on the stack. the stack is configured as a sequence of last-in/first-out read/write registers which allow important data to be stored during interrupts and subroutine calls. each time a new byte is added to the stack (a push), the sp is decremented; each time a byte is removed from the stack (a pull) the sp is incremented. 12.1.5 program counter (pc) the program counter is a 16-bit register which contains the address of the next instruction to be executed. 12.1.6 condition code register (ccr) the condition code register is an 8-bit register in which the bits signify the results of the instruction just executed. these bits can be individually tested by software and a specific action can be taken as a result of the test. each individual condition code register bit is explained below. carry/borrow (c) the c bit is set if there was a carry or borrow out of the arithmetic logic unit (alu) during the last arithmetic operation. the c bit is also affected during shift and rotate instructions. overflow (v) the overflow bit is set if there was an arithmetic overflow as a result of the operation; otherwise, the v bit is cleared. zero (z) the zero bit is set if the result of the last arithmetic, logic or data manipulation operation was zero; otherwise, the z bit is cleared.
MC68HC11G5 cpu, addressing modes and instruction set motorola 12-3 negative (n) the negative bit is set if the result of the last arithmetic, logic or data manipulation operation was negative; otherwise, the n bit is cleared. a result is said to be negative if its most significant bit is set to one. i interrupt mask (i) the i interrupt mask bit is set, either by hardware or software, to disable (mask) all maskable interrupt sources (both external and internal). half carry (h) the half carry bit is set when a carry occurs between bits 3 and 4 of the alu during an add, aba or adc instruction; otherwise, the h bit is cleared. x interrupt mask (x) the x interrupt mask bit is set only by hardware (reset or xirq acknowledge) and is cleared only by a software instruction (tap or rti). stop disable (s) the stop disable bit is set to disable the stop instruction, and cleared to enable the stop instruction. the s bit is program controlled. the stop instruction is treated as no operation (nop) if the s bit is set. 12.2 addressing modes in the m68hc11 cpu, six addressing modes can be used to reference memory; immediate, direct, extended, indexed (with either of two 16-bit index registers and an 8-bit offset), inherent, and relative. some instructions require an additional byte before the opcode to accommodate a multi- page opcode map; this byte is called a pre-byte. the following paragraphs provide a description of each addressing mode. in these descriptions the term effective address is used to indicate the memory address from which the argument is fetched or stored, or from which execution is to proceed. 12.2.1 immediate addressing (imm) in the immediate addressing mode, the actual argument is contained in the byte(s) immediately following the instruction, where the number of bytes matches the size of the register. these are two, three, or four (if pre-byte is required) byte instructions. 12.2.2 direct addressing (dir) in the direct addressing mode (sometimes called page zero addressing), the least significant byte of the operand address is contained in a single byte following the opcode. the high order byte of the effective address is assumed to be $00 and is not included as an instruction byte. direct addressing allows the user to access $0000 through $00ff using 2-byte instructions and execution time is reduced by eliminating the additional memory access. in most applications, this 256-byte area is reserved for frequently referenced data. in the MC68HC11G5, software can configure the memory map so that internal ram, and/or internal registers or external memory can occupy these addresses.
motorola cpu, addressing modes and instruction set MC68HC11G5 12-4 12.2.3 extended addressing (ext) in the extended addressing mode, the effective address of the instruction appears explicitly in the two bytes following the opcode. therefore, the length of most instructions using the extended addressing mode is three bytes: one for the opcode and two for the effective address. 12.2.4 indexed addressing (ind, x; ind, y) in the indexed addressing mode, either the x or y index register is used in calculating the effective address. in this case, the effective address is variable and depends on the current contents of the x or y index register and a fixed 8-bit unsigned offset contained in the instruction. this addressing mode can be used to reference any memory location in the 64 kbyte address space. these are usually two (or three if a pre-byte is required) byte instructions, the opcode plus the 8-bit offset. 12.2.5 inherent addressing (inh) in the inherent addressing mode, all of the information is contained in the opcode. the operands (if any) are registers and no memory reference is required. these are usually one or two byte instructions. 12.2.6 relative addressing (rel) the relative addressing mode is used for branch instructions. if the branch condition is true, the contents of the 8-bit signed byte following the opcode (the offset) is added to the contents of the program counter to form the effective branch address; otherwise, control proceeds to the instruction immediately following the branch instruction. these are usually two byte instructions. 12.3 instruction set this section explains the basic capabilities and organization of the instruction set. for this discussion the instruction set is divided into functional groups of instructions. some instructions will appear in more than one functional group. for example, transfer accumulator a to condition code register (tap) appears in the condition-code-register group and in the load/store/transfer subgroup of accumulator/memory instructions. for a detailed explanation of each instruction refer to the m68hc11 reference manual (m68hc11rm/d). in order to expand the number of instructions used in the MC68HC11G5, a pre-byte mechanism has been added which affects certain instructions. most of the instructions affected are associated with the y index register. instructions which do not require a pre-byte are said to reside in page 1 of the opcode map. instructions requiring a pre-byte are said to reside in pages 2, 3, and 4 of the opcode map. the opcode map pre-byte codes are $18 for page 2, $1a for page 3, and $cd for page 4. a pre-byte code applies only to the opcode which immediately follows it. that is, all instructions are assumed to be single byte opcodes unless the first byte of the instruction happens to correspond to one of the three pre-byte codes rather than a page 1 opcode.
MC68HC11G5 cpu, addressing modes and instruction set motorola 12-5 12.3.1 accumulator and memory instructions most of these instructions use two operands. one operand is either an accumulator or an index register while the second operand is usually obtained from memory using one of the addressing modes discussed earlier. these accumulator memory instructions can be divided into six subgroups: 1. loads, stores and transfers, 2. arithmetic operations, 3. multiply and divide, 4. logical operations, 5. data testing and bit manipulation, 6. shifts and rotates. these instructions are discussed in the following tables and paragraphs. 12.3.1.1 loads, stores and transfers almost all mcu activities involve moving data from memories or peripherals into the cpu or moving results from the cpu to memory or to i/o devices. the load, store, and transfer instructions associated with the accumulators are summarized in the following table. there are additional load, store, push, and pull instructions associated with the index registers and stack pointer register (see 12.3.2 stack and index register instructions ). table 12-1. loads, stores and transfers function mnemonic imm dir ext indx indy inh clear memory byt e clr x x x clear accumulator a clra x clear accumulator b clrb x load accumulator a lda a xxxxx load accumulator b ldab xxxxx load double accumulator d ldd xxxxx pull a from stac k pula x pull b from stac k pulb x push a onto stac k psha x push b onto stac k pshb x store accumulator a sta a xxxxx store accumulator b sta b xxxxx store double accumulator d std xxxxx transfer a to b ta b x transfer a to cc r ta p x transfer b to a tb a x transfer ccr to a tp a x exchange d with x xgdx x exchange d with y xgdy x
motorola cpu, addressing modes and instruction set MC68HC11G5 12-6 12.3.1.2 arithmetic operations this group of instructions supports arithmetic operations on a variety of operands. 8 and 16-bit operations are supported directly and can easily be extended to support multiple word operands. twos complement (signed) and binary (unsigned) operations are supported directly. bcd arithmetic is supported by following normal arithmetic instruction sequences with the decimal adjust accumulator a (daa) instruction to restore results to bcd format. compare instructions perform a subtraction within the cpu to update the condition code bits without altering either operand. test instructions are provided but are seldom needed since almost all other operations automatically update the condition code bits anyway. table 12-2. arithmetic operations function mnemonic imm dir ext indx indy inh add accumulator s ab a x add accumulator b to x abx x add accumulator b to y aby x add with carry to a adc a xxxxx add with carry to b adcb xxxxx add memory to a add a xxxxx add memory to b addb xxxxx add memory to d (16-bit addd xxxxx compare a to b cba x compare a to memor y cmpaxxxxx compare b to memor y cmpb xxxxx compare d to memory (16-bi t cpd xxxxx decimal adjust a (for bc d da a x decrement memory byt e dec x x x decrement accumulator a deca x decrement accumulator b decb x increment memory byte inc x x x increment accumulator a inca x increment accumulator b incb x twos complement memory byt e neg x x x twos complement accumulator a nega x twos complement accumulator b negb x subtract with carry from a sbca xxxxx subtract with carry from b sbcb xxxxx subtract memory from a suba xxxxx subtract memory from b subb xxxxx subtract memory from d (16-bi t subd xxxxx test memory for zero or minu s ts t xxx test a for zero or minu s tst a x test b for zero or minu s tst b x
MC68HC11G5 cpu, addressing modes and instruction set motorola 12-7 12.3.1.3 multiply and divide one multiply and two divide instructions are provided. the 8-bit by 8-bit multiply instruction (mul) produces a 16-bit result. the integer divide (idiv) performs a 16-bit by 16-bit divide and produces a 16-bit result and a 16-bit remainder. the fractional divide (fdiv) divides a 16-bit numerator by a larger 16-bit denominator to produce a 16-bit result (a binary weighted fraction between 0 and 0.99998) and a 16-bit remainder. fdiv can be used to further resolve the remainder from an idiv or fdiv operation. table 12-3. multiply and divide function mnemonic inh multiply (a x b d) mul x fractional divide (d x x; r d) fdiv x d) idiv x integer divide (d x x; r 12.3.1.4 logical operations this group of instructions is used to perform the boolean logical operations and, inclusive-or, exclusive-or, and complement. table 12-4. logical operations function mnemonic imm dir ext indx indy inh and a with memor y and a xxxxx and b with memor y andb xxxxx bit(s) test a with memor y bit a xxxxx bit(s) test b with memor y bitb xxxxx ones complement memory byt e com ones complement a coma x ones complement b comb x or a with memory (exclusiv e eora xxxxx or b with memory (exclusiv e eorb xxxxx or a with memory (inclusive ) oraa xxxxx or b with memory (inclusive ) orab xxxxx xxx
motorola cpu, addressing modes and instruction set MC68HC11G5 12-8 12.3.1.5 data testing and bit manipulation this group of instructions is used to operate on operands as small as a single bit, but these instructions can also operate on any combination of bits within any 8-bit location in the 64 kbyte memory space. the bit test (bita or bitb) instructions perform an and operation within the cpu to update condition code bits without altering either operand. the bset and bclr instructions read the operand, manipulate selected bits within the operand, and write the result back to the operand address. some care is required when read-modify-write instructions such as bset and bclr are used on i/o and control register locations because the physical location read is not always the same as the location written. table 12-5. data testing and bit manipulation function mnemonic imm dir ext indx indy bit(s) test a with memor y bit a x x x x x bit(s) test b with memor y bitb x x x x x clear bit(s) in memor y bclr x x x set bit(s) in memor y bset x x x branch if bit(s) cle a brclr x x x branch if bit(s) se brset x x x
MC68HC11G5 cpu, addressing modes and instruction set motorola 12-9 12.3.1.6 shifts and rotates the shift and rotate functions in the m68hc11 cpu all involve the carry bit in the condition code register in addition to the 8 or 16-bit operand in the instruction. this permits easy extension to multiple word operands. also, by setting or clearing the carry bit before a shift or rotate instruction, the programmer can easily control what will be shifted into the opened end of an operand. the asr instruction maintains the original value of the most significant bit of the operand which facilitates manipulation of twos complement (signed) numbers. table 12-6. shifts and rotates function mnemonic imm dir ext indx indy inh arithmetic shift left memory as l xxx arithmetic shift left a asl a x arithmetic shift left b aslb x arithmetic shift left doubl e asl d x arithmetic shift right memor y asr x x x arithmetic shift right a asra x arithmetic shift right b asrb x (logical shift left memory ) (lsl ) xxx (logical shift left a (lsla ) x (logical shift left b (lslb ) x (logical shift left doubl e (lsld ) x logical shift right memor y lsr x x x logical shift right a lsra x logical shift right b lsrb x logical shift right d lsrd x rotate left memor y rol x x x rotate left a rola x rotate left b rolb x rotate right memor y ror x x x rotate right a rora x rotate right b rorb x the logical left shift instructions are shown in parenthesis because there is no difference between an arithmetic and a logical left shift. both mnemonics are recognized by the assembler as equivalent, but having both instruction mnemonics makes some programs easier to read.
motorola cpu, addressing modes and instruction set MC68HC11G5 12-10 12.3.2 stack and index register instructions the following table summarizes the instructions available for the 16-bit index registers (x and y) and the 16-bit stack pointer. table 12-7. stack and index register instructions function mnemonic imm dir ext indy inh add accumulator b to x abx x add accumulator b to y aby x compare x to memory (16 bit) cpx x x x x compare y to memory (16 bit) cpy x x x x decrement stack pointer des x decrement index register x dex x decrement index register y dey x increment stack pointer ins x increment index register x inx x increment index register y iny x load index register x ldx x x x x load index register y ldy x x x x load stack pointe r lds x x x x pull x from stac k pulx x pull y from stac k puly x push x onto stack pshx x push y onto stack pshy x store index register x st x xxx x store index register y st y xxx x store stack pointe r st s xxx x transfer sp to x ts x x transfer sp to y ts y x transfer x to s p tx s x transfer y to s p ty s x exchange d with x xgdx x exchange d with y xgdy x indx x x x x x x x x the exchange d with x (xgdx) and exchange d with y (xgdy) instructions provide a simple way of getting a pointer value from a 16-bit index register to the d accumulator which has more powerful 16-bit arithmetic capabilities than the 16-bit index registers. since these are bidirectional exchanges,
MC68HC11G5 cpu, addressing modes and instruction set motorola 12-11 the original value of the d accumulator is automatically preserved in the index register while the pointer is being manipulated in the d accumulator. when pointer calculations are finished, another exchange simultaneously updates the index register and restores the d accumulator to its former value. the transfers between an index register and the stack pointer deserve additional comment. the stack pointer always points at the next free location on the stack as opposed to the last thing that was pushed onto the stack. the usual reason for transferring the stack pointer value into an index register is to allow indexed addressing access to information that was formerly pushed onto the stack. in such cases, the address pointed-to by the stack pointer is of no value since nothing has been stored at that location yet. this explains why the value in the stack pointer is incremented during transfers to an index register. there is a corresponding decrement of a 16-bit value as it is transferred from an index register to the stack pointer. 12.3.3 condition code register instructions this group of instructions allows the programmer to manipulate bits in the condition code register. table 12-8. condition code register instructions function mnemonic inh clear carry b i clc x clear interrupt mask bi t cli x clear overflow bi t cl v x set carry bi t sec x set interrupt mask bi t sei x set overflow bit sev x transfer a to cc r ta p x transfer ccr to a tp a x at first look, it may appear that there should be a set and a clear instruction for each of the 8 bits in the condition code register while these instructions are present for only 3 of the 8 bits (c, i and v). upon closer consideration there are good reasons for not including the set and clear instructions for the other five bits. the stop disable (s) bit is an unusual case because this bit is intended to lock out the stop instruction for those who view it as an undesirable function in their application. providing set and clear instructions for this bit would make it easier to enable stop when it was not wanted or disable stop when it was wanted. the tap instruction provides a way to change s but cuts the chances of an undesirable change to s in half because the value of the a accumulator at the time the tap instruction is executed determines whether or not s will actually change.
motorola cpu, addressing modes and instruction set MC68HC11G5 12-12 the xirq interrupt mask (x) bit is another unusual case. the definition of this bit specifically states that software shall not be allowed to change x from 0 to 1, in fact, this is even prohibited by hardware logic. this immediately eliminates a need for a set x instruction. for arguments similar to those used for the s bit, the tap instruction is preferred over a clear x instruction as a means of clearing x because tap makes it a little less likely that x will become cleared before the programmer really intended to clear it. the half-carry (h) bit needs no set or clear instructions because this condition code bit is only used by the daa instruction to adjust the result of a bcd add or subtract. the h bit is not used as a test condition for any branches so it would not be useful to be able to set or clear this bit. this leaves only the negative (n) and zero (z) condition code bits. in contrast to s, x, and h, it is often useful to be able to easily set or clear these flag bits. a clear accumulator instruction such as clrb will clear both the n and z condition code bits. the instruction ldaa #$80 causes both n and z to be set. since there are so many simple instructions that can accomplish setting or clearing of n and z, it is not necessary to provide specific set and clear instructions for n and z in this group. 12.3.4 program control instructions this group of instructions is used to control the flow of a program rather than to manipulate data. since this group is so large it has been further divided into five subgroups: 1. branches, 2. jumps, 3. subroutine calls and returns, 4. interrupt handling, 5. miscellaneous. 12.3.4.1 branches these instructions allow the cpu to make decisions based on the contents of the condition code bits. all decision blocks in a flow chart would correspond to one of the conditional branch instructions which are summarized in the following table.
MC68HC11G5 cpu, addressing modes and instruction set motorola 12-13 table 12-9. branches functio n comment s mnemoni c re l dir indx indy branch if carry clea bcc x c = 0 ? branch if carry se t bcs x c = 1 ? branch if equal zer o beq x z = 1 ? branch if greater than or equ a bge x signed branch if greater tha n bgt x signed > branch if higher bhi x unsigned > branch if higher or same (same as bcc ) bhs x unsigned branch if less than or equ a ble x signed branch if lower (same as bcs ) blo x unsigned < branch if lower or same bls x unsigned branch if less tha n blt x signed < branch if minus bmi x n = 1 ? branch if not equal bne x z = 0 ? branch if plu s bpl x n = 0 ? branch if bit(s) clear in memory byte brclr x x x bit manipulation branch neve r brn x 3-cycle no p branch if bit(s) set in memory byte brset x x x bit manipulation branch if overflow clear bvc x v = 0 ? branch if overflow set bvs x v = 1 ? the limited range of branches (-128/+127 locations) is more than adequate for most (but not all) situations. in cases where this range is too short, a jump instruction must be used. for every branch there is a branch for the opposite condition so it is a simple matter to replace a branch which has an out-of-range destination with a sequence consisting of the opposite branch around a jump to the out-of-range destination. for example, if a program contained the instruction... bhi tinbuk2 unsigned > where tinbuk2 was out of the -128/+127 location range, the following instruction sequence could be substituted... bls around unsigned jmp tinbuk2 still go to tinbuk2 if > around equ *
motorola cpu, addressing modes and instruction set MC68HC11G5 12-14 12.3.4.2 jumps the jump instruction allows control to be passed to any address in the 64 kbyte memory map. table 12-10. jumps function mnemonic dir ext indx indy inh jump jmp x x x x 12.3.4.3 subroutine calls and returns (bsr, jsr, rts) these instructions provide an easy way to break a programming task into manageable blocks called subroutines. the cpu automates the process of remembering the address in the main program where processing should resume after the subroutine is finished. this address is automatically pushed onto the stack when the subroutine is called and is pulled off the stack during the return from subroutine (rts) instruction which ends the subroutine. table 12-11. subroutine calls and returns (bsr, jsr, rts) function mnemonic rel dir ext indx indy inh branch to subroutin e bsr x jump to subroutin e jsr xxxx return from subroutin e rts x 12.3.4.4 interrupt handling (rti, swi, wai) this group of instructions is related to interrupt operations. table 12-12. interrupt handling (rti, swi, wai) function mnemonic inh return from interrup t rti x software interrup t swi x wait for interrup t wai x the software interrupt (swi) instruction is similar to a jump to subroutine (jsr) instruction except that the contents of all working cpu registers are saved on the stack, rather than just saving the return address. swi is unusual in that it is requested by the software program as opposed to other interrupts which are requested asynchronously with respect to the executing program.
MC68HC11G5 cpu, addressing modes and instruction set motorola 12-15 wait for interrupt (wai) has two main purposes. wai is executed to place the mcu in a reduced power consumption standby state (wait mode) until some interrupt occurs. the other use is to reduce the latency time to some important interrupt. the reduction of latency comes about because the time consuming task of storing the cpu registers on the stack is done as soon as the wai instruction starts to execute. when the interrupt finally comes, the cpu is ready to fetch the appropriate vector so the delay associated with register stacking is eliminated from latency calculations. 12.3.4.5 miscellaneous (nop, stop, test) nop can be used to introduce a small time delay into the flow of a program. this is often useful in meeting the timing requirements of slow peripherals. by incorporating nop instructions into loops, longer delays can be produced. table 12-13. miscellaneous (nop, stop, test) function mnemonic inh no operation (2-cycle dela y nop x stop clock s stop x test tes t x during debugging it is common to replace various instructions with nop opcodes to effectively remove an unwanted instruction without having to rearrange the rest of the program. occasionally a programmer is faced with the problem of fine tuning the delays through various paths in his program. in such cases it is sometimes useful to use a brn instruction as a 3 cycle nop. it is also possible to fine tune execution time by choosing alternate addressing mode variations of instructions to change the execution time of an instruction sequence without changing the programs function. stop causes the oscillator and all mcu clocks to freeze. this frozen state is called stop mode and power consumption is dramatically reduced in this mode. the operation of this instruction is also dependent upon the s condition code bit because the stop mode is not appropriate for all applications. if s is 1 the stop instruction is treated as a no operation (nop) instruction and processing just continues to the next instruction. the test instruction is used only during factory testing and is treated as an illegal opcode in normal operating modes of the mcu. this instruction causes unusual behaviour on the address bus (counts backwards) which prevents its use in any normal system.
motorola cpu, addressing modes and instruction set MC68HC11G5 12-16 this page intentionally left blank
MC68HC11G5 electrical specifications motorola 13-1 section 13 electrical specifications this section contains the electrical specifications and associated timing information for the MC68HC11G5. 13.1 maximum ratings ? one pin at a time, observing maximum power dissipation limits. * this device contains protective circuitry against damage due to high static voltages or electrical fields; however, it is advised that normal precautions be taken to avoid application of any voltages higher than maximum-rated voltages to this high-impedance circuit. reliability of operation is enhanced if unused inputs are tied to an appropriate logic voltage level (eg. either gnd or v ). ? rating symbol value unit supply voltage v dd C 0.5 to 7.0 v input voltage v in ss v C 0.5 to v dd + 0.5 v operating temperature range t al t to t h C 40 to 85 c storage temperature range t stg C 65 to 150 c current drain per pin excluding v dd and v ss i d 25 ma * dd
motorola electrical specifications MC68HC11G5 13-2 13.2 thermal characteristics symbol q ja characteristic value unit thermal resistance plastic 50 c/w 13.3 power considerations the average chip junction temperature, t j , in degrees celsius can be obtained from the following equation: t j = t a + (p d ? q ja ) (1) where: t a = ambient temperature ( o c) q ja = package thermal resistance, junction-to-ambient ( o c/w) p d =p int + p i/o p int = internal chip power = i dd x v dd (w) p i/o = power dissipation on input and output pins (w) user determined) note: for most applications p i/o < p int and can be neglected. an approximate relationship between p d and t j (if p i/o is neglected) is: p d = k (t j + 273 o c) (2) solving equations (1) and (2) for k gives: k = p d ? (t a + 273 o c) + q ja ? p d 2 (3) where k is a constant pertaining to the particular part. k can be determined from equation (3) by measuring p d (at equilibrium) for known t a . using this value of k, the values of p d and t j can be obtained by solving equations (1) and (2) for any value of t a .
MC68HC11G5 electrical specifications motorola 13-3 13.4 dc electrical characteristics (v dd = 5.0 vdc 10%, v ss = 0 vdc, t a = t l to t h unless otherwise noted) characteristic output voltage i load = 10.0 m a (see note 1) all outputs all outputs except reset and moda output high voltage i load = - 0.8ma, v dd = 4.5v (see note 1) all outputs except reset, xtal and moda output low voltage i load = 1.6ma all outputs except xtal input high voltage reset all inputs except reset input low voltage i load = 1.6ma all inputs i/o ports, three-state leakage v in = v ih or v il pa0-7, pc0-7, pd0-5, pg0-7, ph0-7, pj0-3, moda/ lir , reset input current v in = v dd or v ss all inputs ram standby voltage powerdown ram standby current powerdown total supply current (see note 2) run: single-chip mode wait: (all peripheral functions shut down) single-chip mode stop: (no clocks) single-chip mode i dd (run) i dd (wait) i dd (stop) input capacitance irq, xirq, extal moda/ lir , reset, all ports except port e notes: 1. v oh specification for reset and moda is not applicable because they are open- drain pins. v oh specification is not applicable to ports c and d in wired-or mode. 2. all ports configured as inputs, v il 0.2v, v il v dd - 0.2v, no dc loads, extal is driven with a square wave, and t cyc = 476.5ns. symbol v ol v oh v oh v ol v ih v ih v il i oz i in v sb i sb i dd c in c in min v dd - 0.1 v dd - 0.8 0.8 x v dd 0.7 x v dd 2.0 max 0.1 0.4 v dd v dd 0.8 10 1.0 v dd 20 30 15 100 12 12 unit v v v v v m a m a v m a ma ma m a pf pf
motorola electrical specifications MC68HC11G5 13-4 test point c1 r2 r1 v dd equivalent test load 1 pins r1 r2 c1 pa0-7, pb0-7, pc0-7, pd0, pd5, pf0-7, pg0-7, ph0-7, pj0-3, e, r/w 3.26k w 2.38k w 90pf pd1-pd4 3.26k w 2.38k w 200pf clocks inputs outputs 0.4v 0.4v nom. nom. nominal timing 0.4v d.c. testing v dd v dd v ss v ss ?0.8v v dd ?0.8v v dd ?70% of v dd ?20% of v dd clocks inputs outputs spec spec spec timing a.c. testing v dd v dd v ss v ss 20% of v dd 20% of v dd 20% of v dd 70% of v dd 70% of v dd ?0.8v ?v dd ?0.4v 20% of v dd 70% of v dd (see note 2) notes: 1. full test loads are applied during all dc electrical tests and ac timing measurements. 2. during ac timing measurements, inputs are driven to 0.4 volts and vdd ?0.8 volts while timing measurements are taken at the 20% and 70% of vdd points. figure 13-1. test methods
MC68HC11G5 electrical specifications motorola 13-5 5.5v 4.5v bus frequency (mhz) 0 0.5 1 1.5 2 2.5 3 3.5 idd (ma) 0 2 4 6 8 10 12 14 16 18 20 22 24 26 figure 13-2. run i dd vs bus frequency (single chip mode C 4.5v, 5.5v) 5.5v 4.5v bus frequency (mhz) 0 0.5 1 1.5 2 2.5 3 3.5 idd (ma) 0 2 4 6 8 10 12 14 16 18 20 22 24 26 figure 13-3. run i dd vs bus frequency (expanded mode C 4.5v, 5.5v) bus frequency (mhz) bus frequency (mhz) i dd (ma) i dd (ma) 5.5v 4.5v 5.5v 4.5v 0 0.5 1 1.5 2 2.5 3 3.5 26 24 22 20 18 16 14 12 10 8 6 4 2 0 0 0.5 1 1.5 2 2.5 3 3.5 26 24 22 20 18 16 14 12 10 8 6 4 2 0
motorola electrical specifications MC68HC11G5 13-6 5.5v 4.5v bus frequency (mhz) 0 0.5 1 1.5 2 2.5 3 3.5 idd (ma) 0 1 2 3 4 5 6 figure 13-4. wait i dd vs bus frequency (single chip mode C 4.5v, 5.5v) 5.5v 4.5v bus frequency (mhz) 0 0.5 1 1.5 2 2.5 3 3.5 idd (ma) 0 1 2 3 4 5 6 figure 13-5. wait i dd vs bus frequency (expanded mode C 4.5v, 5.5v) bus frequency (mhz) i dd (ma) bus frequency (mhz) 5.5v 4.5v 5.5v 4.5v i dd (ma) 6 5 4 3 2 1 0 6 5 4 3 2 1 0 0 0.5 1 1.5 2 2.5 3 3.5 0 0.5 1 1.5 2 2.5 3 3.5
MC68HC11G5 electrical specifications motorola 13-7 13.5 control timing (v dd = 5.0 vdc 10%, v ss = 0 vdc, t a = t l to t h unless otherwise noted) characteristic symbol external oscillator frequency f xtal 4f o internal operating frequency f o f o cycle time t cyc crystal oscillator startup time t oxov stop recovery startup time t srs t srs wait recovery startup time t wrs reset input pulse width (see note 1) t rlrh mode programming t mps t mph interrupt pulse width, irq edge sensitive mode interrupt pulse period t ilil processor control reset , wait, irq mrdy halt bus tri state enable bus tri state disable crystal option external clock option crystal (f xtal /4) external clock all outputs except xtal dly = 0 dly = 1 (to guarantee external reset vector) (minimum input time; may be pre-empted by internal reset) setup time hold time t ilih = t cyc + 20ns ( t pcs = 1/4 t cyc - 50ns) ( t pcs = 1/4 t cyc + 20ns) ( t tse = 1/4 t cyc + 40ns) t pcs t pcs t pcs t tse t tsd min max unit dc 8.4 8.4 mhz mhz dc 2.1 2.1 mhz mhz 476 ns 100 ms 4 4064 t cyc t cyc 4t cyc 8 1 t cyc 2 0 t cyc ns 496 ns note 2 t cyc 69 50 170 159 65 ns ns ns ns ns notes: 1. reset will be recognised during the first clock cycle it is held low. internal circuitry then drives the pin low for four clock cycles, releases the pin, and samples the pin level two cycles later to determine the source of the interrupt. 2. the minimum period t ilil should not be less than the number of cycles it takes to execute the interrupt service routine plus 21 t cyc . 3. all timing is shown with respect to 20% v dd and 70% v dd unless otherwise noted. t ilih
motorola electrical specifications MC68HC11G5 13-8 v dd extal e reset address fffe new pc 4064 t cyc fffe fffe t oxov t rlrw t mps t mph t pcs moda, modb fffe new pc fffe ffff fffe fffe fffe figure 13-6. por external reset timing diagram e t srs internal clock irq (edge) xirq, irq (level) address (xirq (x = 1)) address (irq, xirq (x=0)) stop address + 1 stop address + 1 op- code +2 sp sp-8 sp-8 new pc fff2 (fff4) fff3 (fff5) resume program with instruction which follows the stop instruction stop address + 1 stop address + 1 stop address stop address t ilih figure 13-7. stop recovery timing diagram
MC68HC11G5 electrical specifications motorola 13-9 e address irq, xirq or internal interrupt t wrs sp-8 new pc sp-8 sp-8 sp-8 t pcs sp-8 sp-8 vector addr. vector addr+1 sp-1 sp-2 .... sp-8 sp wait addr. wait addr+1 stack registers r/w figure 13-8. wait recovery from interrupt timing diagram e t ilih next opcode sp sp-1 sp-8 new pc irq (edge) address t pcs irq (level), xirq or internal interrupt sp-8 vector addr vector addr+1 data op- code pcl pch ccr vect msb vect lsb op- code r/w last cycle of an instruction next op+1 sp-2 sp-3 sp-4 sp-5 sp-6 sp-7 iyl iyh ixl ixh b a figure 13-9. interrupt timing diagram
motorola electrical specifications MC68HC11G5 13-10 e internal address t pcs data e external t pcs mrdy figure 13-10. memory ready timing diagram e address data t pcs halt lir t tse t tse opcode opcode opcode addr opcode addr opcode fetch last instruction halt state figure 13-11. entering halt
MC68HC11G5 electrical specifications motorola 13-11 e address data t pcs halt lir t tsd opcode addr + 1 halt state exiting halt execute figure 13-12. exiting halt
motorola electrical specifications MC68HC11G5 13-12 13.6 peripheral port characteristics (v dd = 5.0 vdc 10%, v ss = 0 vdc, t a = t l to t h unless otherwise noted) characteristic symbol min max unit frequency of operation (e clock) f o 2.1 mhz e clock period t cyc 476 ns peripheral data setup time port a, c, d, j port e port g, h (t pdsu = -1/4 t cyc + 93ns) t pdsu t pdsu t pdsu 100 100 C 26 ns ns ns peripheral data hold time port a, c, d, j port e port g, h (t pdh = 1/4 t cyc + 130ns) t pdh t pdh t pdh 80 80 249 ns ns ns delay time, peripheral data write port j1, j2, a3, a4, a5, a6, a7 port b, c, d, f, g, h, a0, a1, a2, j0, j3 (t pwd = 1/4 t cyc + 90ns) t pwd t pwd 150 209 ns ns notes: 1. all timing is shown with respect to 20% v dd and 70% v dd unless otherwise noted. e clock pwd t pwd t ports a3-7, j1- 2 ports b, c, d, f, g, h, a0-2, j0- 3 figure 13-13. port write timing diagram
MC68HC11G5 electrical specifications motorola 13-13 e clock pdsu t ports a, c, d, j port e port g, h pdh t pdsu t pdh t pdsu t pdh t 1/4 t cyc figure 13-14. port read timing diagram
motorola electrical specifications MC68HC11G5 13-14 13.7 timer characteristics (v dd = 5.0 vdc 10%, v ss = 0 vdc, t a = t l to t h unless otherwise noted) characteristic symbol min max unit timer pulse width input capture pulse accumulator input (pw tim = t cyc + 20ns) pw tim 496 ns timer output compare high valid t och 310 ns timer output compare low valid t ocl 295 ns timer input capture response delay min = t cyc + 20ns max = 2 t cyc + 220ns t cap 496 1172 ns notes: 1. all timing is shown with respect to 20% v dd and 70% v dd unless otherwise noted. pa7 1,3 pw tim pa0-pa3/pj1-pj2 2 pa7 2,3 notes: 1. rising edge sensitive input. 2. failing edge sensitive input. 3. maximum pulse accumulator clocking rate is e frequency divided by 2. 1 pa0-pa3/pj1-pj2 figure 13-15. timer inputs timing diagram
MC68HC11G5 electrical specifications motorola 13-15 e clock oc1-oc7 output oc1-oc7 output counter t och t ocl compare register value = xxxx xxxx - 1 xxxx xxxx + 1 figure 13-16. output compare timing diagram e clock counter capture register ic1-ic6 tcap ic1-ic6 xxxx - 3 xxxx - 2 xxxx - 1 xxxx xxxx (captured) min max figure 13-17. input capture timing diagram
motorola electrical specifications MC68HC11G5 13-16 13.8 a/d converter characteristics (v dd = 5.0 vdc 10%, v ss = 0 vdc, t a = t l to t h , e = 750khz to 2.1mhz unless otherwise noted) characteristic parameter min absolute max unit resolution number of bits resolved by the a/d 10 bits nonlinearity maximum deviation from the ideal a/d transfer characteristics tbd lsb zero error difference between the output of an ideal and an actual a/d for zero input voltage tbd lsb full scale error difference between the output of an ideal and an actual a/d for full scale input voltage tbd lsb total unadjusted error maximum sum of nonlinearity, zero error and full scale error tbd lsb quantization error uncertainty due to converter resolution 0.5 lsb absolute accuracy (see note 1) difference between the actual input voltage and the full scale weighted equivalent of the binary output code, all error sources included tbd lsb conversion range (see notes 3 and 4) analog input voltage range v rl v rh v v rh (see note 2) maximum analog reference voltage v rl v dd + 0.1 v v rl (see note 2) minimum analog reference voltage v ss - 0.1 v rh v delta v r (see note 2) minimum difference between v rh and v rl 0v conversion time total time to perform a single analog to digital conversion: 1. e clock 2. internal rc oscillator 36 t cyc + 24 t cyc m s monotonicity conversion result never decreases with an increase in input voltage and has no missing codes guaranteed zero input reading (see note 3) conversion result when v in = v rl $000 hex full scale reading (see note 4) conversion result when v in = v rh $3ff hex sample acquisition time analog input acquisition sampling time: 1. e clock 2. internal rc oscillator 13 8.7 t cyc m s sample hold capacitance input capacitance during sample pe0-pe7 35 (typ) pf input leakage input leakage on a/d pins: pe0-pe7 v rl , v rh 100 250 na m a notes: 1. source impedances greater then 10k w will adversely affect accuracy, due mainly to input leakage. 2. performance verified down to 2.5v delta v r , but accuracy is tested and guaranteed at delta v r = 5v 10%. 3. minimum analog input voltage should not go below v ss - 0.3v. 4. maximum analog input voltage should not exceed 1.125v rh .
MC68HC11G5 electrical specifications motorola 13-17 13.9 expansion bus timing (v dd = 5.0 vdc 10%, v ss = 0 vdc, t a = t l to t h unless otherwise noted) num characteristic symbol min max unit frequency of operation (e-clock) f o 2.1 mhz 1 cycle time t cyc 476 ns 2t eleh 215 ns 3t ehel 210 ns 4 e rise and fall time t r , t f 20 ns 9 address hold time (t ah = 1/8 t cyc (see note 1(a)) t ah 30 ns 12 address valid time to e rise (see note 1(b)) t av 120 ns 17 read data setup time t dsr 30 ns 18 read data hold time t dhr 10 ns 19 write data delay time t ddw 80 ns 21 write data hold time t dhw 50 ns 29 mpu address access time (t acca = t av + t r + t ehel - t dsr (see note 1(a)) t acca 320 ns notes: 1. input clock with duty cycle other than 50% will affect the bus performance. timing parameters affected by the input clock duty cycle are identified by (a) and (b). to re-calculate approximate bus timing values, substitute the following expressions in place of 1/8 t cyc in the above formulae where applicable: (a) (1-dc) x 1/4 t cyc where dc is the decimal value of duty cycle percentage (high time). 2. all timing is shown with respect to 20% v dd and 70% v dd . pulse width e low (1/2 t cyc - 23ns) pulse width e high (1/2 t cyc - 28ns) - 29.5ns) (b) dc x 1/4 t cyc
motorola electrical specifications MC68HC11G5 13-18 e-clock r/w addres s data (read) data (write) 4 4 9 18 1 2 3 4 17 21 19 29 12 figure 13-18. non-multiplexed expanded bus
MC68HC11G5 electrical specifications motorola 13-19 13.10 serial peripheral interface (spi) timing (v dd = 5.0 vdc 10%, v ss = 0 vdc, t a = t l to t h unless otherwise noted) num characteristic symbol min max unit operating frequency master slave f op(s) dc dc 0.5 2.1 f o mhz 1 cycle time master slave t cyc(m) t cyc(s) 2.0 480 t cyc ns 2 enable lead time master slave t lead(m) t lead(s) * 240 ns ns 3 enable lag time master slave t lag(m) t lag(s) * 240 ns ns 4 clock (sck) high time master slave t w(sckh)m t w(sckh)s 340 190 ns ns 5 clock (sck) low time master slave t w(sckl)m 340 190 ns ns 6 data setup time master slave 100 100 ns ns 7 data hold time master slave t su(m) t su(s) t h(m) t h(s) 100 100 ns ns 8 access time (time to data active from high-impedance state) slave t a 0 120 ns 9 disable time (hold time to high-impedance state) slave t dis 240 ns 10 data valid (after enable edge)** t v(s) 240 ns 11 data hold time (outputs) (after enable edge) t ho - 40 ns f op(m) t w(sckl)s 12 rise time (20% v dd to 70% v dd , c l = 200pf) spi outputs (sck, mosi, miso) spi inputs (sck, mosi, miso, ss ) t r(m) t r(s) 100 2.0 ns m s 13 fall time (70% v dd to 20% v dd , c l = 200pf) spi outputs (sck, mosi, miso) spi inputs (sck, mosi, miso, ss ) t f(m) t f(s) 100 2.0 ns m s notes: * signal production depends on software. ** assumes 200 pf load on all spi pins. 1. all timing is shown with respect to 20% v dd and 70% v dd unless otherwise noted.
motorola electrical specifications MC68HC11G5 13-20 miso (input) mosi (output) sck (cpol=0) ss see note see note sck (cpol=1) ss is held high on master 1 13 12 5 4 4 5 12 13 6 7 10 11 12 13 msb msb lsb lsb note: this first edge is generated internally but is not seen at the sck pin. figure 13-19. spi master timing (cpha = 0) miso (input) mosi (output) sck (cpol=0) ss see note see note sck (cpol=1) ss is held high on master 1 13 12 5 4 4 5 12 13 6 7 10 11 12 13 msb msb lsb lsb note: this last edge is generated internally but is not seen at the sck pin. figure 13-20. spi master timing (cpha = 1)
MC68HC11G5 electrical specifications motorola 13-21 miso (output) sck (cpol=0) ss sck (cpol=1) 1 13 12 5 4 4 5 12 13 10 11 msb mosi (input) 6 7 msb lsb lsb note: not defined but normally msb of character just received. 2 3 see note 9 8 figure 13-21. spi slave timing (cpha = 0) miso (output) sck (cpol=0) ss sck (cpol=1) 1 13 12 5 4 4 5 12 13 11 10 msb mosi (input) 6 7 msb lsb lsb note: not defined but normally lsb of character previously transmitted. 2 3 8 see note 9 figure 13-22. spi slave timing (cpha = 1)
motorola electrical specifications MC68HC11G5 13-22 13.11 event counter characteristics table 13.1. clock input (required limit) clock input (required limit) num characteristic symbol min max unit 1 cycle time of external clock input t cycex ns 2 clock high time t wckh ns 3 clock low time t wckl ns 4 rise time t rck ns 5 fall time t fck ns 3xt cyc 1.5xt cyc 1xt cyc 0.25xt cyc 0.25xt cyc table 13.2. clock input (guaranteed limit) clock input (guaranteed limit) num characteristic symbol min max unit 6 propagation delay external clock rise to evo valid t ovr ns 7 propagation delay external clock fall to evo valid t ovf ns 1.5xt cyc 2.5xt cyc + 240 1.5xt cyc 2.5xt cyc + 240 evi1, evi2 1 5 4 6 7 2 3 evo figure 13-23. event counter mode 1, 2, 3 C clock input timing diagram
MC68HC11G5 electrical specifications motorola 13-23 table 13.3. clock gate input (guaranteed limit) clock gate input (required limit) num characteristic symbol min max unit 1 gate input setup time to e fall t gsu ns 2 gate input hold time to e fall t gh ns 0.25xt cyc 0.5xt cyc e clock 1 2 gate input (evi1 or evi2) figure 13-24. event counter mode 1, 2, 3 C clock gate input timing diagram
motorola electrical specifications MC68HC11G5 13-24 this page intentionally left blank
MC68HC11G5 mechanical data motorola 14-1 section 14 mechanical data this section contains the pin assignments, packaging dimensions and ordering information for the MC68HC11G5 mcu. 14.1 ordering information package type temperature part number plcc (cfn suffix) - 40 to 85 c MC68HC11G5cfn
motorola mechanical data MC68HC11G5 14-2 14.2 pin assignments the MC68HC11G5 is offered in an 84-pin plcc (quad surface mount plastic) package. 11 10 9 8 7 6 5 4 3 2 1 84 83 82 81 80 79 78 77 76 75 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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 pf4/a4 pf5/a5 pf6/a6 pf7/a7 irq xirq reset halt ph7/mrdy ph6/evo ph5/evi1 ph4/evi2 ph3/pw4 ph2/pw3 ph1/pw2 ph0/pw1 pc7/d7 pc6/d6 pc5/d5 pj1/oc6/ic5 pj0/tck pb7/a15 pb6/a14 pb5/a13 pb4/a12 pb3/a11 pb2/a10 pb1/a9 pb0/a8 pg7 pg6 pg5 pg4 pg3 pg2 pg1 pg0 pe0/an1 pe4/an5 pe1/an2 pe5/an6 pe2/an3 pe6/an7 pe3/an4 pe7/an8 modb/v moda/lir extal xtal r/w e pc0/d0 pc1/d1 pc2/d2 pc3/d3 pc4/d4 pj2/oc7/ic6 pj3 pa0/ic3 pa1/ic2 pa2/ic1 pa3/oc5/ic4 pa4/oc4 pa5/oc3 pa6/oc2 pa7/oc1/pa i pd5/ss pd4/sck pd3/mosi pd2/miso pd1/txd pd0/rxd pf0/a0 pf1/a1 pf2/a2 pf3/a3 ddl v ssl v dd v v rl v rh kam v ss ddr v ssr v
MC68HC11G5 mechanical data motorola 14-3 14.3 package dimensions millimeters inches dim min max min max 30.10 30.35 1.185 1.195 a 30.10 30.35 1.185 1.195 b 4.20 4.57 0.165 0.180 c 2.29 2.79 0.090 0.110 e f g g 1.27 bsc 0.050 bsc h j k 0.64 0.025 r 29.21 29.36 1.150 1.156 u v 1.07 1.21 0.042 0.048 w 1.07 1.21 0.042 0.056 x y 0.50 0.020 z 2 10 2 10 g1 k1 1.02 0.040 z1 2 10 2 10 0.33 0.48 0.019 0.013 0.66 0.81 0.032 0.026 0.51 0.020 29.21 29.36 1.150 1.156 1.07 1.42 0.042 0.056 28.20 28.70 1.110 1.130 notes: 1. 2. 3. datums -l-, -m-, -n-, and -p- determined where top of lead shoulder exit plastic body at mold parting line. dim g1, true position to be measured at datum -t-, seating plane dim r and u do not include mold protrusion. allowable mold protrusion is 0.25 (0.010) per side 4. due to space limitation, case 780-01 shall be represented by a general case outline drawing. 5. dimensions and tolerancing per ansi y14.5m, 1982 6. controlling dimension: inch -l- -n- -m- -p- y brk w v 1 (note 1) 84 d d detail s g1 g c a r z e j 0.18 (0.007) m t ls ms ns ps 0.18 (0.007) m t ls ms ns ps 0.10 (0.004) -t- seating plane 0.25 (0.010) t ls ms ns ps s detail s 0.18 (0.007) m t ls ms ns ps 0.18 (0.007) m t ls ms ns ps 0.18 (0.007) m t ls ms ns ps 0.18 (0.007) m t ls ms ns ps f h k1 k 0.18 (0.007) m t ls ms ns ps b 0.18 (0.007) m t l s m s n s p s u z1 g1 0.25 (0.010) m t ls ms ns ps x view d-d
motorola mechanical data MC68HC11G5 14-4 this page intentionally left blank


▲Up To Search▲   

 
Price & Availability of MC68HC11G5

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]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X