![]() |
|
If you can't view the Datasheet, Please click here to try to view without PDF Reader . |
|
Datasheet File OCR Text: |
?otorola inc., 1992 mc68340 integrated processor with dma user? manual motorola f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
motorola reserves the right to make changes without further notice to any products herein to improve reliability, function or design. motorola does not assume any liability arising out of the application or use of any product or circuit described herein; neither does it convey any license under its patent rights nor the rights of others. motorola products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the failure of the 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 death associated with such unintended or unauthorized use, even if such claim alleges that motorola was negligent regarding the design or manufacture of the part. motorola and the are registered trademarks of motorola, inc. motorola, inc. is an equal opportunity/affirmative action employer. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . preface the complete documentation package for the mc68340 consists of the mc68340um/ad, mc68340 integrated processor with dma user? manual , m68000pm/ad, mc68000 family programmer? reference manual, and the mc68340p/d, mc68340 integrated processor with dma product brief . the mc68340 integrated with dma processor user? manual describes the programming, capabilities, registers, and operation of the mc68340; the mc68000 family programmer? reference manual provides instruction details for the mc68340; and the mc68340 integrated processor with dma product brief provides a brief description of the mc68340 capabilities. this user? manual is organized as follows: section 1 device overview section 8 timer modules section 2 signal descriptions section 9 ieee 1149.1 test access section 3 bus operation port section 4 system integration module section 10 applications section 5 cpu32 section 11 electrical characteristics section 6 dma controller module section 12 ordering information and section 7 serial module mechanical data 68k fax-it fax 512-891-8593 the motorola high-end technical publication department provides a fax number for you to submit any questions and comments about this document. we welcome your suggestions for improving our documentation or any questions concerning our products. please provide the part number and revision number (located in upper right-hand corner on the cover), and the title of the document when submitting. when referring to items in the manual please reference by the page number, paragraph number, figure number, table number, and line number if needed. reference the line number from the top of the page. when we receive a fax between the hours of 7:30 am and 5:00 pm est, monday through friday, we will respond within two hours. if the fax is received after 5:00 pm or on the weekend, we will respond within two hours on the first working day following receipt of the fax. when sending a fax, please provide your name, company, fax number, and voice number including area code (so we can talk to a real person if needed). f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11/2/95 section 1: overview um rev 1 motorola mc68340 user's manual iii table of contents paragraph page number title number section 1 device overview 1.1 m68300 family.................................................................................................. 1-2 1.1.1 organization .................................................................................................. 1-3 1.1.2 advantages .................................................................................................... 1-3 1.2 central processor unit..................................................................................... 1-3 1.2.1 cpu32 ............................................................................................................ 1-4 1.2.2 background debug mode ........................................................................... 1-4 1.3 on-chip peripherals ........................................................................................ 1-5 1.3.1 system integration module ......................................................................... 1-5 1.3.1.1 external bus interface .............................................................................. 1-5 1.3.1.2 system configuration and protection ................................................... 1-6 1.3.1.3 clock synthesizer..................................................................................... 1-6 1.3.1.4 chip select and wait state generation ............................................... 1-6 1.3.1.5 interrupt handling ..................................................................................... 1-6 1.3.1.6 discrete i/o pins........................................................................................ 1-6 1.3.1.7 ieee 1149.1 test access port ................................................................ 1-7 1.3.2 direct memory access module................................................................... 1-7 1.3.3 serial module ................................................................................................ 1-7 1.3.4 timer modules............................................................................................... 1-8 1.4 power consumption management................................................................ 1-8 1.5 physical .............................................................................................................. 1-9 1.6 compact disc-interactive ................................................................................ 1-9 1.7 more information ............................................................................................... 1-10 section 2 signal descriptions 2.1 signal index....................................................................................................... 2-2 2.2 address bus....................................................................................................... 2-4 2.2.1 address bus (a23?0) ................................................................................ 2-4 2.2.2 address bus (a31?24) .............................................................................. 2-4 2.3 data bus (d15?0) .......................................................................................... 2-4 2.4 function codes (fc3?c0)............................................................................ 2-5 2.5 chip selects ( cs3 cs0 ) ................................................................................ 2-5 2.6 interrupt request level ( irq7 , irq6 , irq5 , irq3 ) ................................... 2-6 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11/2/95 section 1: overview um rev.1.0 iv mc68340 user's manual motorola table of contents (continued) paragraph page number title number 2.7 bus control signals ......................................................................................... 2-6 2.7.1 data and size acknowledge ( dsack1 , dsack0 )................................ 2-6 2.7.2 address strobe ( as ) .................................................................................... 2-6 2.7.3 data strobe ( ds )........................................................................................... 2-7 2.7.4 transfer size (siz1, siz0) .......................................................................... 2-7 2.7.5 r ead/write (r/ w )........................................................................................... 2-7 2.8 bus arbitration signals .................................................................................... 2-7 2.8.1 bus request ( br ).......................................................................................... 2-7 2.8.2 bus grant ( bg )............................................................................................... 2-7 2.8.3 bus grant acknowledge ( bgack )............................................................. 2-7 2.8.4 read-modify-write cycle ( rmc )................................................................. 2-8 2.9 exception control signals .............................................................................. 2-8 2.9.1 reset ( reset )............................................................................................... 2-8 2.9.2 halt ( halt ) .................................................................................................... 2-8 2.9.3 bus error ( berr )........................................................................................... 2-8 2.10 clock signals .................................................................................................... 2-8 2.10.1 system clock (clkout)............................................................................ 2-8 2.10.2 crystal oscillator (extal, xtal)............................................................... 2-9 2.10.3 external filter capacitor (xfc) .................................................................. 2-9 2.10.4 clock mode select (modck)..................................................................... 2-9 2.11 instrumentation and emulation signals ....................................................... 2-9 2.11.1 instruction fetch ( ifetch ) .......................................................................... 2-9 2.11.2 instruction pipe ( ipipe ) ............................................................................... 2-9 2.11.3 breakpoint ( bkpt )........................................................................................ 2-10 2.11.4 freeze (freeze) .......................................................................................... 2-10 2.12 dma module signals ....................................................................................... 2-10 2.12.1 dma request ( dreq2 , dreq1 )................................................................. 2-10 2.12.2 dma acknowledge ( dack2 , dack1 ) ...................................................... 2-10 2.12.3 dma done ( done2 , done1 )...................................................................... 2-10 2.13 serial module signals ..................................................................................... 2-11 2.13.1 serial crystal oscillator (x2, x1) ............................................................... 2-11 2.13.2 serial external clock input (sclk)........................................................... 2-11 2.13.3 receive data (rxda, rxdb) ....................................................................... 2-11 2.13.4 transmit data (txda, txdb)....................................................................... 2-11 2.13.5 clear to send ( ctsa , ctsb ) ..................................................................... 2-11 2.13.6 request to send ( rtsa , rtsb ) ................................................................ 2-11 2.13.7 transmitter ready ( t ? rdya ) ..................................................................... 2-11 2.13.8 receiver ready ( r ? rdya ) ......................................................................... 2-12 2.14 timer signals .................................................................................................... 2-12 2.14.1 timer gate ( tgate2 , tgate1 ) ................................................................ 2-12 2.14.2 timer input (tin2, tin1) .............................................................................. 2-12 2.14.3 timer output (tout2, tout1)................................................................... 2-12 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11/2/95 section 1: overview um rev 1 motorola mc68340 user's manual v table of contents (continued) paragraph page number title number 2.15 test signals ....................................................................................................... 2-13 2.15.1 test clock (tck) ........................................................................................... 2-13 2.15.2 test mode select (tms).............................................................................. 2-13 2.15.3 test data in (tdi) .......................................................................................... 2-13 2.15.4 test data out (tdo) ..................................................................................... 2-13 2.16 synthesizer power (v ccsyn ).......................................................................... 2-13 2.17 system power and ground (v cc and gnd)................................................ 2-13 2.18 signal summary ............................................................................................... 2-13 section 3 bus operation 3.1 bus transfer signals........................................................................................ 3-1 3.1.1 bus control signals ..................................................................................... 3-2 3.1.2 function code signals ................................................................................ 3-3 3.1.3 address bus (a31?0) ................................................................................ 3-4 3.1.4 address strobe ( as ) .................................................................................... 3-4 3.1.5 data bus (d15?0) ...................................................................................... 3-4 3.1.6 data strobe ( ds )........................................................................................... 3-4 3.1.7 bus cycle termination signals.................................................................. 3-4 3.1.7.1 data transfer and size acknowledge signals ( dsack1 and dsack0 ) ..................................................................... 3-4 3.1.7.2 bus error ( berr )....................................................................................... 3-5 3.1.7.3 autovector ( avec ).................................................................................... 3-5 3.2 data transfer mechanism ............................................................................... 3-5 3.2.1 dynamic bus sizing ..................................................................................... 3-5 3.2.2 misaligned operands................................................................................... 3-7 3.2.3 operand transfer cases ............................................................................. 3-7 3.2.3.1 byte operand to 8-bit port, odd or even (a0 = x) .............................. 3-7 3.2.3.2 byte operand to 16-bit port, even (a0 = 0).......................................... 3-8 3.2.3.3 byte operand to 16-bit port, odd (a0 = 1) ........................................... 3-9 3.2.3.4 word operand to 8-bit port, aligned ..................................................... 3-9 3.2.3.5 word operand to 16-bit port, aligned................................................... 3-10 3.2.3.6 long-word operand to 8-bit port, aligned ........................................... 3-10 3.2.3.7 long-word operand to 16-bit port, aligned ........................................ 3-12 3.2.4 bus operation................................................................................................ 3-14 3.2.5 synchronous operation with dsack ? ..................................................... 3-14 3.2.6 fast termination cycles .............................................................................. 3-15 3.3 data transfer cycles........................................................................................ 3-16 3.3.1 read cycle..................................................................................................... 3-16 3.3.2 write cycle ..................................................................................................... 3-18 3.3.3 read-modify-write cycle............................................................................. 3-19 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11/2/95 section 1: overview um rev.1.0 vi mc68340 user's manual motorola table of contents (continued) paragraph page number title number 3.4 cpu space cycles........................................................................................... 3-21 3.4.1 breakpoint acknowledge cycle ................................................................. 3-22 3.4.2 lpstop broadcast cycle ........................................................................... 3-23 3.4.3 module base address register access.................................................... 3-27 3.4.4 interrupt acknowledge bus cycles............................................................ 3-27 3.4.4.1 interrupt acknowledge cycle?erminated normally........................ 3-27 3.4.4.2 autovector interrupt acknowledge cycle ............ ................................. 3-29 3.4.4.3 spurious interrupt cycle.......................................................................... 3-30 3.5 bus exception control cycles ........................................................................ 3-32 3.5.1 bus errors....................................................................................................... 3-34 3.5.2 retry operation ............................................................................................. 3-36 3.5.3 halt operation ............................................................................................... 3-38 3.5.4 double bus fault .......................................................................................... 3-39 3.6 bus arbitration ................................................................................................... 3-40 3.6.1 bus request................................................................................................... 3-43 3.6.2 bus grant........................................................................................................ 3-43 3.6.3 bus grant acknowledge .............................................................................. 3-43 3.6.4 bus arbitration control................................................................................. 3-44 3.6.5 show cycles.................................................................................................. 3-44 3.7 reset operation ................................................................................................ 3-46 section 4 system integration module 4.1 module overview .............................................................................................. 4-1 4.2 module operation ............................................................................................. 4-2 4.2.1 module base address register operation............................................... 4-2 4.2.2 system configuration and protection operation .................................... 4-3 4.2.2.1 system configuration .............................................................................. 4-5 4.2.2.2 internal bus monitor ................................................................................. 4-6 4.2.2.3 double bus fault monitor........................................................................ 4-6 4.2.2.4 spurious interrupt monitor ...................................................................... 4-6 4.2.2.5 software watchdog .................................................................................. 4-6 4.2.2.6 periodic interrupt timer ........................................................................... 4-7 4.2.2.6.1 periodic timer period calculation..................................................... 4-8 4.2.2.6.2 using the periodic timer as a real-time clock ............................. 4-9 4.2.2.7 simultaneous interrupts by sources in the sim40............................. 4-9 4.2.3 clock synthesizer operation...................................................................... 4-9 4.2.3.1 phase comparator and filter ................................................................. 4-11 4.2.3.2 frequency divider .................................................................................... 4-12 4.2.3.3 clock control ............................................................................................. 4-13 4.2.4 chip select operation ................................................................................. 4-13 4.2.4.1 programmable features.......................................................................... 4-14 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11/2/95 section 1: overview um rev 1 motorola mc68340 user's manual vii table of contents (continued) paragraph page number title number 4.2.4.2 global chip select operation ................................................................ 4-14 4.2.5 external bus interface operation ............................................................... 4-15 4.2.5.1 port a........................................................................................................... 4-15 4.2.5.2 port b........................................................................................................... 4-16 4.2.6 low-power stop ........................................................................................... 4-17 4.2.7 freeze ............................................................................................................. 4-17 4.3 programming model......................................................................................... 4-18 4.3.1 module base address register (mbar)................................................... 4-20 4.3.2 system configuration and protection registers ..................................... 4-21 4.3.2.1 module configuration register (mcr).................................................. 4-21 4.3.2.2 autovector register (avr)....................................................................... 4-23 4.3.2.3 reset status register (rsr)................................................................... 4-23 4.3.2.4 software interrupt vector register (swiv)........................................... 4-24 4.3.2.5 system protection control register (sypcr)..................................... 4-24 4.3.2.6 periodic interrupt control register (picr) ........................................... 4-26 4.3.2.7 periodic interrupt timer register (pitr) ............................................... 4-27 4.3.2.8 software service register (swsr) ...................................................... 4-28 4.3.3 clock synthesizer control register (syncr) ........................................ 4-28 4.3.4 chip select registers .................................................................................. 4-29 4.3.4.1 base address registers .......................................................................... 4-30 4.3.4.2 address mask registers .......................................................................... 4-31 4.3.4.3 chip select registers programming example.................................... 4-33 4.3.5 external bus interface control.................................................................... 4-33 4.3.5.1 port a pin assignment register 1 (ppara1)....................................... 4-33 4.3.5.2 port a pin assignment register 2 (ppara2)....................................... 4-34 4.3.5.3 port a data direction register (ddra)................................................. 4-34 4.3.5.4 port a data register (porta) ................................................................ 4-34 4.3.5.5 port b pin assignment register (pparb) ............................................ 4-35 4.3.5.6 port b data direction register (ddrb)................................................. 4-35 4.3.5.7 port b data register (portb, portb1) .............................................. 4-35 4.4 mc68340 initialization sequence ................................................................. 4-36 4.4.1 startup ............................................................................................................ 4-36 4.4.2 sim40 module configuration ..................................................................... 4-36 4.4.3 sim40 example configuration code ........................................................ 4-38 section 5 cpu32 5.1 overview............................................................................................................. 5-1 5.1.1 features.......................................................................................................... 5-2 5.1.2 virtual memory .............................................................................................. 5-2 5.1.3 loop mode instruction execution .............................................................. 5-3 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11/2/95 section 1: overview um rev.1.0 viii mc68340 user's manual motorola table of contents (continued) paragraph page number title number 5.1.4 vector base register.................................................................................... 5-4 5.1.5 exception handling ...................................................................................... 5-4 5.1.6 addressing modes........................................................................................ 5-5 5.1.7 instruction set................................................................................................ 5-5 5.1.7.1 table lookup and interpolate instructions........................................... 5-7 5.1.7.2 low-power stop instruction ................................................................. 5-7 5.1.8 processing states......................................................................................... 5-7 5.1.9 privilege states ............................................................................................. 5-7 5.2 architecture summary ..................................................................................... 5-8 5.2.1 programming model..................................................................................... 5-8 5.2.2 registers......................................................................................................... 5-10 5.3 instruction set.................................................................................................... 5-11 5.3.1 m68000 family compatibility ..................................................................... 5-11 5.3.1.1 new instructions........................................................................................ 5-11 5.3.1.1.1 lo w-power stop (lpstop)................................................................ 5-11 5.3.1.1.2 table lookup and interpolation (tbl) .............................................. 5-12 5.3.1.2 unimplemented instructions ................................................................... 5-12 5.3.2 instruction format and notation ................................................................. 5-12 5.3.3 instruction summary .................................................................................... 5-15 5.3.3.1 condition code register ......................................................................... 5-20 5.3.3.2 data movement instructions ................................................................... 5-21 5.3.3.3 integer arithmetic operations ................................................................. 5-22 5.3.3.4 logic instructions ...................................................................................... 5-24 5.3.3.5 shift and rotate instructions ................................................................... 5-24 5.3.3.6 bit manipulation instructions................................................................... 5-25 5.3.3.7 binary-coded decimal (bcd) instructions .......................................... 5-26 5.3.3.8 program control instructions .................................................................. 5-26 5.3.3.9 system control instructions .................................................................... 5-27 5.3.3.10 condition tests ......................................................................................... 5-29 5.3.4 using the tbl instructions .......................................................................... 5-29 5.3.4.1 table example 1: standard usage ....................................................... 5-30 5.3.4.2 table example 2: compressed table .................................................. 5-31 5.3.4.3 table example 3: 8-bit independent variable .................................... 5-32 5.3.4.4 table example 4: maintaining precision.............................................. 5-34 5.3.4.5 table example 5: surface interpolations............ ................................. 5-36 5.3.5 nested subroutine calls ............................................................................. 5-36 5.3.6 pipeline synchronization with the nop instruction................................ 5-36 5.4 processing states............................................................................................. 5-36 5.4.1 state transitions ........................................................................................... 5-37 5.4.2 privilege levels............................................................................................. 5-37 5.4.2.1 supervisor privilege level...................................................................... 5-37 5.4.2.2 user privilege level ................................................................................. 5-39 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11/2/95 section 1: overview um rev 1 motorola mc68340 user's manual ix table of contents (continued) paragraph page number title number 5.4.2.3 changing privilege level........................................................................ 5-39 5.5 exception processing ...................................................................................... 5-39 5.5.1 exception vectors ......................................................................................... 5-40 5.5.1.1 types of exceptions ................................................................................. 5-41 5.5.1.2 exception processing sequence .......................................................... 5-41 5.5.1.3 exception stack frame............................................................................ 5-42 5.5.1.4 multiple exceptions .................................................................................. 5-42 5.5.2 processing of specific exceptions ............................................................ 5-44 5.5.2.1 reset ........................................................................................................... 5-44 5.5.2.2 bus error...................................................................... ............................... 5-46 5.5.2.3 address error............................................................................................. 5-46 5.5.2.4 instruction traps........................................................................................ 5-47 5.5.2.5 software breakpoints............................................................................... 5-47 5.5.2.6 hardware breakpoints ............................................................................. 5-48 5.5.2.7 format error ............................................................................................... 5-48 5.5.2.8 illegal or unimplemented instructions .................................................. 5-48 5.5.2.9 privilege violations................................................................................... 5-49 5.5.2.10 tracing ........................................................................................................ 5-50 5.5.2.11 interrupts..................................................................................................... 5-51 5.5.2.12 return from exception.............................................................................. 5-52 5.5.3 fault recovery............................................................................................... 5-53 5.5.3.1 types of faults .......................................................................................... 5-55 5.5.3.1.1 type i?eleased write faults ........................................................... 5-55 5.5.3.1.2 type ii?refetch, operand, rmw, and movep faults................. 5-56 5.5.3.1.3 type iii?aults during movem operand transfer ....................... 5-57 5.5.3.1.4 type iv?aults during exception processing ............................... 5-57 5.5.3.2 correcting a fault ..................................................................................... 5-57 5.5.3.2.1 type i?ompleting released writes via software ....................... 5-57 5.5.3.2.2 type i?ompleting released writes via rte ................................ 5-57 5.5.3.2.3 type ii?orrecting faults via rte.................................................... 5-58 5.5.3.2.4 type iii?orrecting faults via software .......................................... 5-58 5.5.3.2.5 type iii?orrecting faults by conversion and restart................. 5-58 5.5.3.2.6 type iii?orrecting faults via rte................................................... 5-59 5.5.3.2.7 type iv?orrecting faults via software ......................................... 5-59 5.5.4 cpu32 stack frames .................................................................................. 5-60 5.5.4.1 four-word stack frame .......................................................................... 5-60 5.5.4.2 six-word stack frame............................................................................. 5-60 5.5.4.3 bus error stack frame............................................................................. 5-60 5.6 development support...................................................................................... 5-63 5.6.1 cpu32 integrated development support ................................................ 5-63 5.6.1.1 background debug mode (bdm) overview ........................................ 5-64 5.6.1.2 deterministic opcode tracking overview ............................................ 5-64 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11/2/95 section 1: overview um rev.1.0 x mc68340 user's manual motorola table of contents (continued) paragraph page number title number 5.6.1.3 on-chip hardware breakpoint overview............................................. 5-64 5.6.2 background debug mode ........................................................................... 5-65 5.6.2.1 enabling bdm ........................................................................................... 5-65 5.6.2.2 bdm sources ............................................................................................ 5-66 5.6.2.2.1 external bkpt signal. ......................................................................... 5-66 5.6.2.2.2 bgnd instruction .................................................................................. 5-66 5.6.2.2.3 double bus fault. ................................................................................. 5-66 5.6.2.3 entering bdm ............................................................................................ 5-66 5.6.2.4 command execution................................................................................ 5-67 5.6.2.5 bdm registers........................................................................................... 5-67 5.6.2.5.1 fault address register (far) ............................................................. 5-67 5.6.2.5.2 return program counter (rpc) ......................................................... 5-67 5.6.2.5.3 current instruct ion program counter (pcc).................................... 5-67 5.6.2.6 returning from bdm ................................................................................. 5-68 5.6.2.7 serial interface .......................................................................................... 5-68 5.6.2.7.1 cpu serial logic .................................................................................. 5-69 5.6.2.7.2 development system serial logic.................................................... 5-71 5.6.2.8 command set ........................................................................................... 5-73 5.6.2.8.1 command format ................................................................................. 5-73 5.6.2.8.2 command sequence diagram .......................................................... 5-74 5.6.2.8.3 command set summary..................................................................... 5-75 5.6.2.8.4 read a/d register (rareg/rdreg) ................................................ 5-76 5.6.2.8.5 write a/d register (wareg/wdreg) .............................................. 5-77 5.6.2.8.6 read system register (rsreg)........................................................ 5-77 5.6.2.8.7 write system register (wsreg) ....................................................... 5-78 5.6.2.8.8 read memory location (read) ......................................................... 5-79 5.6.2.8.9 write memory location (write) ........................................................ 5-79 5.6.2.8.10 dump memory block (dump). ........................................................... 5-80 5.6.2.8.11 fill memory block (fill) ...................................................................... 5-82 5.6.2.8.12 resume execution (go) ...................................................................... 5-83 5.6.2.8.13 call user code (call)........................................................................ 5-83 5.6.2.8.14 reset peripherals (rst)...................................................................... 5-85 5.6.2.8.15 no operation (nop) ............................................................................. 5-85 5.6.2.8.16 future commands ................................................................................ 5-86 5.6.3 deterministic opcode tracking .................................................................. 5-86 5.6.3.1 instruction fetch ( ifetch ) ...................................................................... 5-86 5.6.3.2 instruction pipe ( ipipe ) ........................................................................... 5-87 5.6.3.3 opcode tracking during loop mode .................................................... 5-88 5.7 instruction execution timing........................................................................... 5-88 5.7.1 resource scheduling .................................................................................. 5-88 5.7.1.1 microsequencer ........................................................................................ 5-89 5.7.1.2 instruction pipeline ................................................................................... 5-89 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11/2/95 section 1: overview um rev 1 motorola mc68340 user's manual xi table of contents (continued) paragraph page number title number 5.7.1.3 bus controller resources ....................................................................... 5-89 5.7.1.3.1 prefetch controller................................................................................ 5-90 5.7.1.3.2 write pending buffer. ........................................................................... 5-90 5.7.1.3.3 microbus controller .............................................................................. 5-91 5.7.1.4 instruction execution overlap................................................................. 5-91 5.7.1.5 effects of wait states................................................................................ 5-92 5.7.1.6 instruction execution time calculation ................................................ 5-92 5.7.1.7 effects of negative tails .......................................................................... 5-93 5.7.2 instruction stream timing examples ........................................................ 5-94 5.7.2.1 timing example 1?xecution overlap................................................ 5-94 5.7.2.2 timing example 2?ranch instructions .............................................. 5-95 5.7.2.3 timing example 3?egative tails ....................................................... 5-96 5.7.3 instruction timing tables ............................................................................ 5-97 5.7.3.1 fetch effective address ........................................................................... 5-99 5.7.3.2 calculate effective address .................................................................... 5-100 5.7.3.3 move instruction ...................................................................................... 5-101 5.7.3.4 special-purpose move instruction....................................................... 5-101 5.7.3.5 arithmetic/logic instructions ................................................................... 5-102 5.7.3.6 immediate arithmetic/logic instructions ............................................... 5-105 5.7.3.7 binary-coded decimal and extended instructions ............................ 5-106 5.7.3.8 single operand instructions ................................................................... 5-107 5.7.3.9 shift/rotate instructions ........................................................................... 5-108 5.7.3.10 bit manipulation instructions................................................................... 5-109 5.7.3.11 conditional branch instructions ............................................................. 5-110 5.7.3.12 control instructions................................................................................... 5-111 5.7.3.13 exception-related instructions and operations.................................. 5-111 5.7.3.14 save and restore operations ................................................................ 5-111 section 6 dma controller module 6.1 dma module overview .................................................................................... 6-2 6.2 dma module signal definitions..................................................................... 6-4 6.2.1 dma request ( dreq ? )................................................................................ 6-4 6.2.2 dma acknowledge ( dack ? )...................................................................... 6-4 6.2.3 dma done ( done ? ) ..................................................................................... 6-4 6.3 transfer request generation ......................................................................... 6-4 6.3.1 internal request generation....................................................................... 6-4 6.3.1.1 internal request, maximum rate ........................................................... 6-5 6.3.1.2 internal request, limited rate ............................................................... 6-5 6.3.2 external request generation ..................................................................... 6-5 6.3.2.1 external burst mode ................................................................................. 6-5 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11/2/95 section 1: overview um rev.1.0 xii mc68340 user's manual motorola table of contents (continued) paragraph page number title number 6.3.2.2 external cycle steal mode ..................................................................... 6-5 6.4 data transfer modes........................................................................................ 6-6 6.4.1 single-address mode .................................................................................. 6-6 6.4.1.1 single-address read............................................................................... 6-7 6.4.1.2 single-address write ............................................................................... 6-9 6.4.2 dual-address mode ..................................................................................... 6-12 6.4.2.1 dual-address read .................................................................................. 6-12 6.4.2.2 dual-address write .................................................................................. 6-14 6.5 bus arbitration ................................................................................................... 6-18 6.6 dma channel operation ................................................................................. 6-18 6.6.1 channel initialization and startup ............................................................. 6-18 6.6.2 data transfers ............................................................................................... 6-19 6.6.2.1 internal request transfers ...................................................................... 6-19 6.6.2.2 external request transfers..................................................................... 6-19 6.6.3 channel termination ................................................................................... 6-20 6.6.3.1 channel termination ............................................................................... 6-20 6.6.3.2 interrupt operation.................................................................................... 6-20 6.6.3.3 fast termination option .......................................................................... 6-20 6.7 register description ......................................................................................... 6-22 6.7.1 module configuration register (mcr)...................................................... 6-23 6.7.2 interrupt register (intr) .............................................................................. 6-26 6.7.3 channel control register (ccr) ............................................................... 6-26 6.7.4 channel status register (csr) ................................................................. 6-30 6.7.5 function code register (fcr) ................................................................... 6-32 6.7.6 source address register (sar) ................................................................ 6-33 6.7.7 destination address register (dar) ......................................................... 6-33 6.7.8 byte transfer counter register (btc) ...................................................... 6-34 6.8 data packing ..................................................................................................... 6-35 6.9 dma channel initialization sequence ......................................................... 6-36 6.9.1 dma channel configuration ...................................................................... 6-36 6.9.1.1 dma channel operation in single-address mode ............................ 6-37 6.9.1.2 dma channel operation in dual-address mode ............................... 6-37 6.9.2 dma channel example configuration code .......................................... 6-38 section 7 serial module 7.1 module overview .............................................................................................. 7-2 7.1.1 serial communication channels a and b ............................................... 7-3 7.1.2 baud rate generator logic ........................................................................ 7-3 7.1.3 internal channel control logic .................................................................. 7-3 7.1.4 interrupt control logic ................................................................................. 7-3 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11/2/95 section 1: overview um rev 1 motorola mc68340 user's manual xiii table of contents (continued) paragraph page number title number 7.1.5 comparison of serial module to mc68681 ............................................. 7-4 7.2 serial module signal definitions................................................................... 7-4 7.2.1 crystal input or external clock (x1) .......................................................... 7-5 7.2.2 crystal output (x2) ....................................................................................... 7-5 7.2.3 external input (sclk) .................................................................................. 7-6 7.2.4 channel a transmitter serial data output (txda)................................. 7-6 7.2.5 channel a receiver serial data input (rx da)........................................ 7-6 7.2.6 channel b transmitter serial data output (txdb)................................. 7-6 7.2.7 channel b receiver serial data input (rx db)........................................ 7-6 7.2.8 channel a request-to-send ( rtsa ) ...................................................... 7-6 7.2.8.1 rtsa ........................................................................................................... 7-6 7.2.8.2 op0.............................................................................................................. 7-6 7.2.9 channel b request-to-send ( rtsb )....................................................... 7-6 7.2.9.1 rtsb ........................................................................................................... 7-7 7.2.9.2 op1.............................................................................................................. 7-7 7.2.10 channel a clear-to-send ( ctsa ) ........................................................... 7-7 7.2.11 channel b clear-to-send ( ctsb )............................................................ 7-7 7.2.12 channel a transmitter ready ( t ? rdya )................................................. 7-7 7.2.12.1 t ? rdya ...................................................................................................... 7-7 7.2.12.2 op6.............................................................................................................. 7-7 7.2.13 channel a receiver ready ( r ? rdya ) ..................................................... 7-7 7.2.13.1 r ? rdya ...................................................................................................... 7-7 7.2.13.2 ffulla ....................................................................................................... 7-7 7.2.13.3 op4.............................................................................................................. 7-7 7.3 operation............................................................................................................ 7-8 7.3.1 baud rate generator ................................................................................... 7-8 7.3.2 transmitter and receiver operating modes ............................................ 7-8 7.3.2.1 transmitter ................................................................................................. 7-10 7.3.2.2 receiver....................................................................... ............................... 7-11 7.3.2.3 fifo stack.................................................................................................. 7-12 7.3.3 looping modes ............................................................................................. 7-14 7.3.3.1 automatic echo mode .............................................................................. 7-14 7.3.3.2 local loopback mode ............................................................................. 7-14 7.3.3.3 remote loopback mode ......................................................................... 7-14 7.3.4 multidrop mode ............................................................................................. 7-15 7.3.5 bus operation................................................................................................ 7-17 7.3.5.1 read cycles............................................................................................... 7-17 7.3.5.2 write cycles ............................................................................................... 7-17 7.3.5.3 interrupt acknowledge cycles................................................................ 7-17 7.4 register description and programming ....................................................... 7-17 7.4.1 register description ..................................................................................... 7-17 7.4.1.1 module configuration register (mcr).................................................. 7-19 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11/2/95 section 1: overview um rev.1.0 xiv mc68340 user's manual motorola table of contents (continued) paragraph page number title number 7.4.1.2 interrupt level register (ilr) .................................................................. 7-21 7.4.1.3 interrupt vector register (ivr) ................................................................ 7-21 7.4.1.4 mode register 1 (mr1) ............................................................................ 7-22 7.4.1.5 status register (sr)................................................................................. 7-24 7.4.1.6 clock-select register (csr) .................................................................. 7-26 7.4.1.7 command register (cr) ......................................................................... 7-27 7.4.1.8 receiver buffer (rb) ................................................................................. 7-30 7.4.1.9 transmitter buffer (tb) ............................................................................. 7-30 7.4.1.10 input port change register (ipcr)........................................................ 7-31 7.4.1.11 auxiliary control register ( acr)............................................................ 7-32 7.4.1.12 interrupt status register (isr)................................................................ 7-32 7.4.1.13 interrupt enable register (ier)............................................................... 7-34 7.4.1.14 input port (ip) ............................................................................................. 7-35 7.4.1.15 output port control register (opcr) .................................................... 7-35 7.4.1.16 output port data register (op) .............................................................. 7-37 7.4.1.17 mode register 2 (mr2) ............................................................................ 7-37 7.4.2 programming ................................................................................................. 7-40 7.4.2.1 serial module initialization ..................................................................... 7-40 7.4.2.2 i/o driver example.................................................................................... 7-40 7.4.2.3 interrupt handling ..................................................................................... 7-40 7.5 serial module initialization sequence ......................................................... 7-46 7.5.1 serial module configuration ...................................................................... 7-46 7.5.2 serial module example configuration code .......................................... 7-47 section 8 timer modules 8.1 module overview .............................................................................................. 8-1 8.1.1 timer and counter functions ..................................................................... 8-2 8.1.1.1 prescaler and counter............................................................................. 8-2 8.1.1.2 timeout detection..................................................................................... 8-2 8.1.1.3 comparator ................................................................................................ 8-2 8.1.1.4 clock selection logic .............................................................................. 8-3 8.1.2 internal control logic................................................................................... 8-3 8.1.3 interrupt control logic ................................................................................. 8-4 8.2 timer modules signal definitions ................................................................. 8-4 8.2.1 timer input (tin1, tin2) .............................................................................. 8-5 8.2.2 timer gate ( tgate1 , tgate2 ) ................................................................ 8-6 8.2.3 timer output (tout1, tout2)................................................................... 8-6 8.3 operating modes .............................................................................................. 8-6 8.3.1 input capture/output compare .................................................................. 8-6 8.3.2 square-wave generator ............................................................................. 8-8 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11/2/95 section 1: overview um rev 1 motorola mc68340 user's manual xv table of contents (continued) paragraph page number title number 8.3.3 variable duty-cycle square-wave generator........................................ 8-9 8.3.4 variable-width single-shot pulse generator ......................................... 8-10 8.3.5 pulse-width measurement.......................................................................... 8-12 8.3.6 period measurement.................................................................................... 8-13 8.3.7 event count ................................................................................................... 8-14 8.3.8 timer bypass ................................................................................................. 8-16 8.3.9 bus operation................................................................................................ 8-17 8.3.9.1 read cycles............................................................................................... 8-17 8.3.9.2 write cycles ............................................................................................... 8-17 8.3.9.3 interrupt acknowledge cycles................................................................ 8-17 8.4 register description ......................................................................................... 8-17 8.4.1 module configuration register (mcr)...................................................... 8-18 8.4.2 interrupt register (ir) ................................................................................... 8-20 8.4.3 control register (cr) ................................................................................... 8-20 8.4.4 status register (sr)..................................................................................... 8-23 8.4.5 counter register (cntr) ............................................................................ 8-25 8.4.6 preload 1 register (prel1)........................................................................ 8-25 8.4.7 preload 2 register (prel2)........................................................................ 8-26 8.4.8 compare register (com)............................................................................ 8-26 8.5 timer module initialization sequence .......................................................... 8-27 8.5.1 timer module configuration ....................................................................... 8-27 8.5.2 timer module example configuration code ........................................... 8-28 section 9 ieee 1149.1 test access port 9.1 overview............................................................................................................. 9-1 9.2 tap controller ................................................................................................... 9-2 9.3 boundary scan register ................................................................................. 9-3 9.4 instruction register ........................................................................................... 9-9 9.4.1 extest (000) ............................................................................................... 9-10 9.4.2 sample/preload (001) .......................................................................... 9-10 9.4.3 bypass (x1x, 101)..................................................................................... 9-11 9.4.4 hi-z (100) ....................................................................................................... 9-11 9.5 mc68340 restrictions...................................................................................... 9-11 9.6 non-ieee 1149.1 operation ........................................................................... 9-12 section 10 applications 10.1 minimum system configuration................................................................... 10-1 10.1.1 processor clock circuitry .......................................................................... 10-1 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11/2/95 section 1: overview um rev.1.0 xvi mc68340 user's manual motorola table of contents (concluded) paragraph page number title number 10.1.2 reset circuitry ............................................................................................. 10-3 10.1.3 sram interface ........................................................................................... 10-3 10.1.4 rom interface .............................................................................................. 10-4 10.1.5 serial interface ............................................................................................ 10-4 10.2 memory interface information ....................................................................... 10-5 10.2.1 using an 8-bit boot rom........................................................................... 10-5 10.2.2 access time calculations ......................................................................... 10-6 10.2.3 calculating frequency-adjusted output ................................................ 10-7 10.2.4 interfacing an 8-bit device to 16-bit memory using single-address dma mode .................................................................. 10-10 10.3 power consumption considerations .......................................................... 10-10 10.3.1 mc68340 power reduction at 5v .......................................................... 10-11 10.3.2 mc68340v (3.3 v) ..................................................................................... 10-13 section 11 electrical characteristics 11.1 maximum rating ............................................................................................. 11-1 11.2 thermal characteristics................................................................................. 11-1 11.3 power considerations ................................................................................... 11-2 11.4 ac electrical specification definitions ....................................................... 11-2 11.5 dc electrical specifications ......................................................................... 11-5 11.6 ac electrical specifications control timing .............................................. 11-6 11.7 ac timing specifications .............................................................................. 11-8 11.8 dma module ac electrical specifications ................................................. 11-19 11.9 timer module electrical specifications ...................................................... 11-20 11.10 serial module electrical specifications...................................................... 11-22 11.11 ieee 1149.1 electrical specifications......................................................... 11-25 section 12 ordering information and mechanical data 12.1 standard mc68340 ordering information ................................................. 12-1 12.2 pin assignment ............................................................................................... 12-2 12.2.1 144-lead ceramic quad flat pack (fe suffix) ..................................... 12-2 12.2.2 145-lead plastic pin grid array (rp suffix) .......................................... 12-4 12.3 package dimensions ..................................................................................... 12-6 12.3.1 fe suffix ....................................................................................................... 12-6 12.3.2 rp suffix ....................................................................................................... 12-7 index f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11/2/95 section 1: overview um rev 1 motorola mc68340 user's manual xvii list of illustrations figure page number title number 1-1 block diagram ......................................................................................................... 1-1 2-1 functional signal groups ..................................................................................... 2-1 3-1 input sample window............................................................................................ 3-2 3-2 mc68340 interface to various port sizes .......................................................... 3-7 3-3 long-word operand read timing from 8-bit port............................................ 3-11 3-4 long-word operand write timing to 8-bit port................................................. 3-12 3-5 long-word and word read and write timing?6-bit port ........................... 3-13 3-6 fast termination timing ........................................................................................ 3-15 3-7 word read cycle flowchart ................................................................................. 3-16 3-8 word write cycle flowchart.................................................................................. 3-18 3-9 read-modify-write cycle timing ......................................................................... 3-19 3-10 cpu space address encoding............................................................................ 3-21 3-11 breakpoint operation flowchart .......................................................................... 3-24 3-12 breakpoint acknowledge cycle timing (opcode returned) .......................... 3-25 3-13 breakpoint acknowledge cycle timing (exception signaled) ...................... 3-26 3-14 interrupt acknowledge cycle flowchart ............................................................. 3-28 3-15 interrupt acknowledge cycle timing .................................................................. 3-29 3-16 autovector operation timing ................................................................................ 3-31 3-17 bus error without dsack ? ................................................................................... 3-35 3-18 late bus error with dsack ? ................................................................................ 3-36 3-19 retry sequence ...................................................................................................... 3-37 3-20 late retry sequence ............................................................................................. 3-38 3-21 halt timing............................................................................................................ 3-39 3-22 bus arbitration flowchart for single request.................................................... 3-41 3-23 bus arbitration timing diagram?dle bus case.............................................. 3-42 3-24 bus arbitration timing diagram?ctive bus case ......................................... 3-42 3-25 bus arbitration state diagram.............................................................................. 3-45 3-26 show cycle timing diagram................................................................................ 3-46 3-27 timing for external devices driving reset ...................................................... 3-47 3-28 power-up reset timing diagram ........................................................................ 3-48 4-1 sim40 module register block .............................................................................. 4-3 4-2 system configuration and protection function ................................................ 4-5 4-3 software watchdog block diagram .................................................................... 4-7 4-4 clock block diagram for crystal operation ....................................................... 4-10 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11/2/95 section 1: overview um rev.1.0 xviii mc68340 user's manual motorola list of illustrations (continued) figure page number title number 4-5 mc68340 crystal oscillator .................................................................................. 4-10 4-6 clock block diagram for external oscillator operation ................................... 4-11 4-7 full interrupt request multiplexer ........................................................................ 4-16 4-8 sim40 programming model.................................................................................. 4-19 5-1 cpu32 block diagram........................................................................................... 5-3 5-2 loop mode instruction sequence ....................................................................... 5-3 5-3 user programming model ..................................................................................... 5-9 5-4 supervisor programming model supplement .................................................. 5-9 5-5 status register ........................................................................................................ 5-10 5-6 instruction word general format ......................................................................... 5-12 5-7 table example 1 ..................................................................................................... 5-30 5-8 table example 2 ..................................................................................................... 5-31 5-9 table example 3 ..................................................................................................... 5-33 5-10 exception stack frame.......................................................................................... 5-42 5-11 reset operation flowchart.................................................................................... 5-45 5-12 format $0?our-word stack frame .................................................................. 5-60 5-13 format $2?ix-word stack frame .................................................................... 5-60 5-14 internal transfer count register .......................................................................... 5-61 5-15 format $c?err stack for prefetches and operands.................................. 5-62 5-16 format $c?err stack on movem operand ................................................ 5-62 5-17 format $c?our- and six-word berr stack .................................................. 5-63 5-18 in-circuit emulator configuration ........................................................................ 5-64 5-19 bus state analyzer configuration ....................................................................... 5-64 5-20 bdm block diagram ............................................................................................... 5-65 5-21 bdm command execution flowchart ................................................................. 5-68 5-22 debug serial i/o block diagram.......................................................................... 5-70 5-23 serial interface timing diagram .......................................................................... 5-71 5-24 bkpt timing for single bus cycle...................................................................... 5-72 5-25 bkpt timing for forcing bdm ............................................................................. 5-72 5-26 bkpt /dsclk logic diagram .............................................................................. 5-72 5-27 command-sequence diagram............................................................................ 5-75 5-28 functional model of instruction pipeline ............................................................ 5-87 5-29 instruction pipeline timing diagram ................................................................... 5-88 5-30 block diagram of independent resources ........................................................ 5-90 5-31 simultaneous instruction execution.................................................................... 5-91 5-32 attributed instruction times................................................................................... 5-92 5-33 example 1?nstruction stream ........................................................................... 5-95 5-34 example 2?ranch taken ................................................................................... 5-95 5-35 example 2?ranch not taken............................................................................ 5-96 5-36 example 3?ranch negative tail ...................................................................... 5-96 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11/2/95 section 1: overview um rev 1 motorola mc68340 user's manual xix list of illustrations (continued) figure page number title number 6-1 dma block diagram ............................................................................................... 6-1 6-2 single-address transfers ..................................................................................... 6-3 6-3 dual-address transfer........................................................................................... 6-3 6-4 dma external connections to serial module.................................................... 6-6 6-5 single-address read timing (external burst) .................................................. 6-8 6-6 single-address read timing (cycle steal)....................................................... 6-9 6-7 single-address write timing (external burst)................................................... 6-10 6-8 single-address write timing (cycle steal) ....................................................... 6-11 6-9 dual-address read timing (external burst?ource requesting)............... 6-13 6-10 dual-address read timing (cycle steal?ource requesting) ................... 6-14 6-11 dual-address write timing (external burst?estination requesting)........ 6-16 6-12 dual-address write timing (cycle steal?estination requesting) ............ 6-17 6-13 fast termination option (cycle steal)................................................................ 6-21 6-14 fast termination option (external burst?ource requesting) .................... 6-22 6-15 dma module programming model ...................................................................... 6-23 6-16 packing and unpacking of operands ................................................................. 6-35 7-1 simplified block diagram...................................................................................... 7-1 7-2 external and internal interface signals .............................................................. 7-5 7-3 baud rate generator block diagram.................................................................. 7-8 7-4 transmitter and receiver functional diagram.................................................. 7-9 7-5 transmitter timing diagram ................................................................................. 7-10 7-6 receiver timing diagram...................................................................................... 7-12 7-7 looping modes functional diagram................................................................... 7-15 7-8 multidrop mode timing diagram ......................................................................... 7-16 7-9 serial module programming model .................................................................... 7-19 7-10 serial module programming flowchart.............................................................. 7-41 8-1 simplified block diagram...................................................................................... 8-1 8-2 timer functional diagram..................................................................................... 8-3 8-3 external and internal interface signals .............................................................. 8-5 8-4 input capture/output compare mode................................................................. 8-7 8-5 square-wave generator mode............................................................................ 8-8 8-6 variable duty-cycle square-wave generator mode ...................................... 8-10 8-7 variable-width single-shot pulse generator mode........................................ 8-11 8-8 pulse-width measurement mode ........................................................................ 8-12 8-9 period measurement mode .................................................................................. 8-14 8-10 event count mode .................................................................................................. 8-15 8-11 timer module programming model..................................................................... 8-18 9-1 test access port block diagram .......................................................................... 9-2 9-2 tap controller state machine.............................................................................. 9-3 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11/2/95 section 1: overview um rev.1.0 xx mc68340 user's manual motorola list of illustrations (continued) figure page number title number 9-3 output latch cell (o.latch)................................................................................... 9-7 9-4 input pin cell (i.pin)................................................................................................ 9-7 9-5 active-high output control cell (io.ctl1) ........................................................... 9-8 9-6 active-low output control cell (io.ctl0) ............................................................ 9-8 9-7 bidirectional data cell (io.cell) ........................................................................... 9-9 9-8 general arrangement for bidirectional pins ...................................................... 9-9 9-9 bypass register ...................................................................................................... 9-11 10-1 minimum system configuration block diagram ............................................. 10-1 10-2 sample crystal circuit ......................................................................................... 10-2 10-3 statek corporation crystal circuit ..................................................................... 10-2 10-4 xfc and v ccsyn capacitor connections ........................................................ 10-3 10-5 sram interface ..................................................................................................... 10-3 10-6 rom interface ........................................................................................................ 10-4 10-7 serial interface ...................................................................................................... 10-5 10-8 external circuitry for 8-bit boot rom ................................................................ 10-5 10-9 8-bit boot rom timing......................................................................................... 10-6 10-10 access time computation diagram.................................................................. 10-6 10-11 signal relationships to clkout ...................................................................... 10-7 10-12 signal width specifications................................................................................ 10-8 10-13 skew between two outputs ............................................................................... 10-9 10-14 circuitry for interfacing 8-bit device to 16-bit memory in single-address dma mode .............................................................................. 10-10 10-15 mc68340 current vs. activity at 5 v .................................................................. 10-11 10-16 mc68340 current vs. voltage/temperature.................................................... 10-12 10-17 mc68340 current vs. clock frequency at 5 v ................................................ 10-12 11-1 drive levels and test points for ac specifications ....................................... 11-4 11-2 read cycle timing diagram............................................................................... 11-11 11-3 write cycle timing diagram ............................................................................... 11-12 11-4 fast termination read cycle timing diagram ............................................... 11-13 11-5 fast termination write cycle timing diagram................................................ 11-14 11-6 bus arbitation timing?ctive bus case ......................................................... 11-15 11-7 bus arbitration timing?dle bus case ............................................................ 11-16 11-8 show cy cle timing diagram.............................................................................. 11-16 11-9 iack cycle timing diagram ............................................................................... 11-17 11-10 background debug mode serial port timing ................................................. 11-18 11-11 background debug mode freeze timing ..................................................... 11-18 11-12 dma signal timing diagram.............................................................................. 11-19 11-13 timer module clock signal timing diagram .................................................. 11-20 11-14 timer module signal timing diagram.............................................................. 11-21 11-15 serial module general timing diagram .......................................................... 11-22 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11/2/95 section 1: overview um rev 1 motorola mc68340 user's manual xxi list of illustrations (concluded) figure page number title number 11-16 serial module asynchronous mode timing (x1)............................................ 11-23 11-17 serial module asynchronous mode timing (sclk?6x) ............................ 11-23 11-18 serial module synchronous mode timing diagram ..................................... 11-23 11-19 test clock input timing diagram....................................................................... 11-25 11-20 boundary scan timing diagram ....................................................................... 11-26 11-21 test access port timing diagram...................................................................... 11-26 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11/2/95 section 1: overview um rev.1.0 xxii mc68340 user's manual motorola list of tables table page number title number 2-1 signal index............................................................................................................. 2-2 2-2 address space encoding ..................................................................................... 2-5 2-3 dsack ? encoding ................................................................................................. 2-6 2-4 sizx signal encoding ............................................................................................ 2-7 2-5 signal summary ..................................................................................................... 2-14 3-1 sizx signal encoding ............................................................................................ 3-3 3-2 address space encoding ..................................................................................... 3-3 3-3 dsack ? encoding ................................................................................................. 3-5 3-4 dsack ? , berr , and halt assertion results .................................................. 3-33 4-1 clock operating modes ......................................................................................... 4-9 4-2 system frequencies from 32.768-khz reference............................................ 4-13 4-3 clock control signals ............................................................................................ 4-13 4-4 port a pin assignment register ........................................................................... 4-15 4-5 port b pin assignment register ........................................................................... 4-16 4-6 shenx control bits ................................................................................................ 4-22 4-7 deriving software watchdog timeout ................................................................ 4-25 4-8 bmtx encoding ....................................................................................................... 4-26 4-9 pirql encoding...................................................................................................... 4-26 4-10 ddx encoding ......................................................................................................... 4-32 4-11 psx encoding.......................................................................................................... 4-32 5-1 instruction set.......................................................................................................... 5-6 5-2 instruction set summary ....................................................................................... 5-16 5-3 condition code computations............................................................................. 5-20 5-4 data movement operations .................................................................................. 5-21 5-5 integer arithmetic operations ............................................................................... 5-23 5-6 logic operations..................................................................................................... 5-24 5-7 shift and rotate operations.................................................................................. 5-25 5-8 bit manipulation operations ................................................................................. 5-25 5-9 binary-coded decimal operations ..................................................................... 5-26 5-10 program control operations................................................................................. 5-26 5-11 system control operations................................................................................... 5-28 5-12 condition tests ....................................................................................................... 5-29 5-13 standard usage entries ........................................................................................ 5-30 5-14 compressed table entries ................................................................................... 5-32 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11/2/95 section 1: overview um rev 1 motorola mc68340 user's manual xxiii list of tables (continued) table page number title number 5-15 8-bit independent variable entries ..................................................................... 5-33 5-16 exception vector assignments............................................................................. 5-40 5-17 exception priority groups...................................................................................... 5-43 5-18 tracing control........................................................................................................ 5-50 5-19 bdm source summary.......................................................................................... 5-67 5-20 polling the bdm entry source.............................................................................. 5-68 5-21 cpu generated message encoding................................................................... 5-70 5-22 size field encoding ............................................................................................... 5-74 5-23 bdm command summary .................................................................................... 5-77 5-24 register field for rsreg and wsreg .............................................................. 5-79 6-1 frzx control bits .................................................................................................... 6-24 6-2 ssizex encoding ................................................................................................... 6-28 6-3 dsizex encoding ................................................................................................... 6-29 6-4 reqx encoding ....................................................................................................... 6-29 6-5 bbx encoding and bus bandwidth...................................................................... 6-29 6-6 address space encoding ..................................................................................... 6-32 7-1 frzx control bits .................................................................................................... 7-20 7-2 pmx and pt control bits........................................................................................ 7-23 7-3 b/cx control bits ..................................................................................................... 7-24 7-4 rcsx control bits ................................................................................................... 7-26 7-5 tcsx control bits ................................................................................................... 7-27 7-6 miscx control bits ................................................................................................. 7-28 7-7 tcx control bits ...................................................................................................... 7-29 7-8 rcx control bits ...................................................................................................... 7-30 7-9 cmx control bits ..................................................................................................... 7-38 7-10 sbx control bits ...................................................................................................... 7-39 8-1 ocx encoding ......................................................................................................... 8-17 8-2 frzx control bits .................................................................................................... 8-19 8-3 iex encoding............................................................................................................ 8-21 8-4 potx encoding ....................................................................................................... 8-22 8-5 modex encoding ................................................................................................... 8-22 8-6 ocx encoding ......................................................................................................... 8-22 9-1 boundary scan control bits ................................................................................. 9-4 9-2 boundary scan bit definitions ............................................................................. 9-5 9-3 instructions ............................................................................................................... 9-10 10-1 memory access times at 16.78 mhz ................................................................ 10-7 10-2 typical electrical characteristics ....................................................................... 10-13 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 1- 1 section 1 device overview the mc68340 is a high-performance 32-bit integrated processor with direct memory access (dma), combining an enhanced m68000-compatible processor, 32-bit dma, and other peripheral subsystems on a single integrated circuit. the mc68340 cpu32 delivers 32-bit cisc processor performance from a lower cost 16-bit memory system. the combination of peripherals offered in the mc68340 can be found in a diverse range of microprocessor-based systems, including embedded control and general computing. systems requiring very high-speed block transfers of data can especially benefit from the mc68340. the mc68340's high level of functional integration results in significant reductions in component count, power consumption, board space, and cost while yielding much higher system reliability and shorter design time. the 3.3-v mc68340v is particularly attractive to applications requiring a very tight power budget. complete code compatibility with the mc68000 and mc68010 affords the designer access to a broad base of established real- time kernels, operating systems, languages, applications, and development tools?any oriented towards embedded control. cpu32 68020?based processor two- channel serial i/o two-channel dma controller external bus interface clock synthesizer system integration module (sim40) bus arbitration intermodule bus timer timer system protection ieee test chip selects and wait states figure 1-1. block diagram f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 1- 2 mc68340 user? manual motorola the primary features of the mc68340, illustrated in figure 1-1, are as follows: high functional integration on a single piece of silicon cpu32?c68020-derived 32-bit central processor unit ?upward object-code compatible with mc68000 and mc68010 ?additional mc68020 instructions and addressing modes ?unique embedded control instructions ?fast two-clock register instructions?0,045 dhrystones two-channel low-latency dma controller for high-speed memory transfers ?single- or dual-address transfers ?32-bit addresses and counters ?8-, 16-, and 32-bit data transfers ?50 mbyte/sec sustained transfers (12.5 mbyte/sec memory-to-memory) two-channel universal synchronous/asynchronous receiver/transmitter (usart) ?baud rate generators ?modem control ?mc68681/mc2681 compatible ?9.8 mbits/sec maximum transfer rate two independent counter/timers ?16-bit counter ?up to 8-bit prescaler ?multimode operation ?80-ns resolution system integration module incorporates many functions typically relegated to external pals, ttl, and asic, such as: ?system configuration ?external bus interface ?system protection ?periodic interrupt timer ?chip select and wait state generation ?interrupt response ?clock generation ?bus arbitration ?dynamic bus sizing ?ieee 1149.1 boundary scan (jtag) ?up to 16 discrete i/o lines ?power-on reset 32 address lines, 16 data lines power consumption control ?static hcmos technology reduces power in normal operation ?low voltage operation at 3.3 v 0.3 v (mc68340v only) ?programmable clock generator throttles frequency ?unused peripherals can be turned off ?lpstop provides an idle state for lowest standby current 0?6.78 mhz or 0?5.16 mhz operation 144-pin ceramic quad flat pack (cqfp) or 145-pin plastic pin grid array (pga) as a low voltage part, the mc68340v can operate with a 3.3-v power supply. mc68340 is used throughout this manual to refer to both the low voltage and standard 5-v parts since both are functionally equivalent. 1.1 m68300 family the mc68340 is one of a series of components in the m68300 family. other members of the family include the mc68302, mc68330, mc68331, mc68332, and mc68333. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 1- 3 1.1.1 organization the m68300 family of integrated processors and controllers is built on an m68000 core processor, an on-chip bus, and a selection of intelligent peripherals appropriate for a set of applications. the cpu32 is a powerful central processor with nearly the performance of the mc68020. a system integration module incorporates the external bus interface and many of the smaller circuits that typically surround a microprocessor for address decoding, wait-state insertion, interrupt prioritization, clock generation, arbitration, watchdog timing, and power-on reset timing. each member of the m68300 family is distinguished by its selection of peripherals. peripherals are chosen to address specific applications but are often useful in a wide variety of applications. the peripherals may be highly sophisticated timing or protocol engines that have their own processors, or they may be more traditional peripheral functions, such as uarts and timers. since each major function is designed in a standalone module, each module might be found in many different m68300 family parts. driver software written for a module on one m68300 part can be used to run the same module that appears on another part. 1.1.2 advantages by incorporating so many major features into a single m68300 family chip, a system designer can realize significant savings in design time, power consumption, cost, board space, pin count, and programming. the equivalent functionality can easily require 20 separate components. each component might have 16?4 pins, totaling over 350 connections. most of these connections require interconnects or are duplications. each connection is a candidate for a bad solder joint or misrouted trace. each component is another part to qualify, purchase, inventory, and maintain. each component requires a share of the printed circuit board. each component draws power?ften to drive large buffers to get the signal to another chip. the cumulative power consumption of all the components must be available from the power supply. the signals between the cpu and a peripheral might not be compatible nor run from the same clock, requiring time delays or other special design considerations. in a m68300 family component, the major functions and glue logic are all properly connected internally, timed with the same clock, fully tested, and uniformly documented. power consumption stays well under a watt, and a special standby mode drops current well under a milliamp during idle periods. only essential signals are brought out to pins. the primary package is the surface-mount quad flat pack for the smallest possible footprint; pin grid arrays are also available. 1.2 central processor unit the cpu32 is a powerful central processor that supervises system functions, makes decisions, manipulates data, and directs i/o. a special debugging mode simplifies processor emulation during system debug. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 1- 4 mc68340 user? manual motorola 1.2.1 cpu32 the cpu32 is an m68000 family processor specially designed for use as a 32-bit core processor and for operation over the intermodule bus (imb). designers used the mc68020 as a model and included advances of the later m68000 family processors, resulting in an instruction execution performance of 4 mips (vax-equivalent) at 25.16 mhz. the powerful and flexible m68000 architecture is the basis of the cpu32. mc68000 (including the mc68hc000 and the mc68ec000) and mc68010 user programs will run unmodified on the cpu32. the programmer can use any of the eight 32-bit data registers for fast manipulation of data and any of the eight 32-bit address registers for indexing data in memory. the cpu32 can operate on data types of single bits, binary-coded decimal (bcd) digits, and 8, 16, and 32 bits. peripherals and data in memory can reside anywhere in the 4-gbyte linear address space. a supervisor operating mode protects system-level resources from the more restricted user mode, allowing a true virtual environment to be developed. flexible instructions for data movement, arithmetic functions, logical operations, shifts and rotates, bit set and clear, conditional and unconditional program branches, and overall system control are supported, including a fast 32 32 multiply and 32-bit conditional branches. new instructions, such as table lookup and interpolate and low power stop, support the specific requirements of embedded control applications. many addressing modes complement these instructions, including predecrement and postincrement, which allow simple stack and queue maintenance and scaled indexed for efficient table accesses. data types and addressing modes are supported orthogonally by all data operations and with all appropriate addressing modes. position-independent code is easily written. the cpu32 is specially optimized to run with the mc68340's 16-bit data bus. most instructions execute in one-half the number of clocks compared to the original mc68000, yielding an overall 1.6 times the performance of the same-speed mc68000 and measuring 10,045?hrystones/sec @ 25.16 mhz (6,742?hrystones/sec @ 16.78 mhz). like all m68000 family processors, the cpu32 recognizes interrupts of seven different priority levels and allows the peripheral to vector the processor to the desired service routine. internal trap exceptions ensure proper instruction execution with good addresses and data, allow operating system intervention in special situations, and permit instruction tracing. hardware signals can either terminate or rerun bad memory accesses before instructions process data incorrectly. the cpu32 offers the programmer full 32-bit data processing performance with complete m68000 compatibility, yet with more compact code than is available with risc processors. the cpu32 is identical in all cpu32-based m68300 family products. 1.2.2 background debug mode a special operating mode is available in the cpu32 in which normal instruction execution is suspended while special on-chip microcode performs the functions of a debugger. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 1- 5 commands are received over a dedicated, high-speed, full-duplex serial interface. commands allow the manual reading or writing of cpu32 registers, reading or writing of external memory locations, and diversion to user-specified patch code. this background debug mode permits a much simpler emulation environment while leaving the processor chip in the target system, running its own debugging operations. 1.3 on-chip peripherals to improve total system throughput and reduce part count, board size, and cost of system implementation, the m68300 family integrates on-chip, intelligent peripheral modules and typical glue logic. these functions on the mc68340 include the sim40, a dma controller, a serial module, and two timers. the processor communicates with these modules over the on-chip intermodule bus (imb). this backbone of the chip is similar to traditional external buses with address, data, clock, interrupt, arbitration, and handshake signals. because bus masters (like the cpu32 and dma), peripherals, and the sim40 are all on the chip, the imb ensures that communication between these modules is fully synchronized and that arbitration and interrupts can be handled in parallel with data transfers, greatly improving system performance. internal accesses across the imb may be monitored from outside of the chip, if desired. each module operates independently. no direct connections between peripheral modules are made inside the chip; however, external connections could, for instance, link a serial output to a dma control line. modules and their registers are accessed in the memory map of the cpu32 (and dma) for easy access by general m68000 instructions and are relocatable. each module may be assigned its own interrupt level, response vector, and arbitration priority. since each module is a self-contained design and adheres to the imb interface specifications, the modules may appear on other m68300 family products, retaining the investment in the software drivers for the module. 1.3.1 system integration module the mc68340 sim40 provides the external bus interface for both the cpu32 and the dma. it also eliminates much of the glue logic that typically supports the microprocessor and its interface with the peripheral and memory system. the sim40 provides programmable circuits to perform address decoding and chip selects, wait-state insertion, interrupt handling, clock generation, bus arbitration, watchdog timing, discrete i/o, and power-on reset timing. a boundary scan test capability is also provided. 1.3.1.1 external bus interface. the external bus interface (ebi) handles the transfer of information between the internal cpu32 or dma controller and memory, peripherals, or other processing elements in the external address space. based on the mc68030 bus, the external bus provides up to 32 address lines and 16 data lines. address extensions identify each bus cycle as cpu32 or dma initiated, supervisor or user privilege level, and instruction or data access. the data bus allows dynamic sizing for 8- or 16-bit bus accesses (plus 32 bits for dma). synchronous transfers from the cpu32 or the dma can be made in as little as two clock cycles. asynchronous transfers allow the f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 1- 6 mc68340 user? manual motorola memory system to signal the cpu32 or dma when the transfer is complete and to note the number of bits in the transfer. an external master can arbitrate for the bus using a three-line handshaking interface. 1.3.1.2 system configuration and protection. the m68000 family of processors is designed with the concept of providing maximum system safeguards. system configuration and various monitors and timers are provided in the mc68340. power-on reset circuitry is a part of the sim40. a bus monitor ensures that the system does not lock up when there is no response to a memory access. the bus fault monitor can reset the processor when a catastrophic bus failure occurs. spurious interrupts are detected and handled appropriately. a software watchdog can pull the processor out of an infinite loop. an interrupt can be sent to the cpu32 with programmable regularity for dram refresh, time-of-day clock, task switching, etc. 1.3.1.3 clock synthesizer. the clock synthesizer generates the clock signals used by all internal operations as well as a clock output used by external devices. the clock synthesizer can operate with an inexpensive 32768-hz watch crystal or an external oscillator for reference, using an internal phase-locked loop and voltage-controlled oscillator. at any time, software can select clock frequencies from 131 khz to 16.78 mhz or 25.16 mhz, favoring either low power consumption or high performance. alternately, an external clock can drive the clock signal directly at the operating frequency. with its fully static hcmos design, it is possible to completely stop the system clock without losing the contents of the internal registers. 1.3.1.4 chip select and wait state generation. four programmable chip selects provide signals to enable external memory and peripheral circuits, providing all handshaking and timing signals with up to 175-ns access times with a 25-mhz system clock (265 ns @ 16.78 mhz). each chip select signal has an associated base address and an address mask that determine the addressing characteristics of that chip select. address space and write protection can be selected for each. the block size can be selected from 256 bytes up to 4 gbytes in increments of 2 n . accesses can be preselected for either 8- or 16-bit transfers. fast synchronous termination or up to three wait states can be programmed, whether or not the chip select signals are used. external handshakes can also signal the end of a bus transfer. a system can boot from reset out of 8-bit-wide memory, if desired. 1.3.1.5 interrupt handling. seven input signals are provided to trigger an external interrupt, one for each of the seven priority levels supported. seven separate outputs can indicate the priority level of the interrupt being serviced. an input can direct the processor to a default service routine, if desired. interrupts at each priority level can be preprogrammed to go to the default service routine. for maximum flexibility, interrupts can be vectored to the correct service routine by the interrupting device. 1.3.1.6 discrete i/o pins. when not used for other functions, 16 pins can be programmed as discrete input or output lines. additionally, in other peripheral modules, pins for otherwise unused functions can often be used for general input/output. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 1- 7 1.3.1.7 ieee 1149.1 test access port. to aid in system diagnostics, the mc68340 includes dedicated user-accessible test logic that is fully compliant with the ieee 1149.1 standard for boundary scan testability, often referred to as jtag (joint test action group). 1.3.2 direct memory access module the most distinguishing mc68340 characteristic is the high-speed 32-bit dma controller, used to quickly move large blocks of data between internal peripherals, external peripherals, or memory without processor intervention. the dma module consists of two, independent, programmable channels. each channel has separate request, acknowledge, and done signals. each channel can operate in a single-address or a dual-address (flyby) mode. in single-address mode, only one (the source or the destination) address is provided, and a peripheral device such as a serial communications controller receives or supplies the data. an external request must start a single-address transfer. in this mode, each channel supports 32 bits of address and 8, 16, or 32 bits of data. in dual-address mode, two bus transfers occur, one from a source device and the other to a destination device. dual-address transfers can be started by either an internal or external request. in this mode, each channel supports 32 bits of address and 8 or 16 bits of data (32 bits require external logic). the source and destination port size can be selected independently; when they are different, the data will be packed or unpacked. an 8-bit disk interface can be read twice before the concatenated 16-bit result is passed into memory. byte, word, and long-word counts up to 32 bits can be transferred. all addresses and transfer counters are 32 bits. addresses increment or remain constant, as programmed. the dma channels support two external request modes, burst transfer and cycle steal. internal requests can be programmed to occupy 25, 50, 75, or 100 percent of the data bus bandwidth. interrupts can be programmed to postpone dma completion. the dma module can sustain a transfer rate of 12.5 mbytes/sec in dual-address mode and nearly 50 mbytes/sec in single-address mode @ 25.16 mhz (8.4 and 33.3 mbytes/sec @ 16.78 mhz, respectively). the dma controller arbitrates with the cpu32 for the bus in parallel with existing bus cycles and is fully synchronized with the cpu32, eliminating all delays normally associated with bus arbitration by allowing dma bus cycles to butt seamlessly with cpu bus cycles. 1.3.3 serial module most digital systems use serial i/o to communicate with host computers, operator terminals, or remote devices. the mc68340 contains a two-channel, full-duplex usart. an on-chip baud rate generator provides standard baud rates up to 76.8k baud independently to each channel's receiver and transmitter. the module is functionally equivalent to the mc68681/mc2681 duart. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 1- 8 mc68340 user? manual motorola each communication channel is completely independent. data formats can be 5, 6, 7, or 8 bits with even, odd, or no parity and stop bits up to 2 in 1/16 increments. four-byte receive buffers and two-byte transmit buffers minimize cpu service calls. a wide variety of error detection and maskable interrupt capability is provided on each channel. full-duplex, autoecho loopback, local loopback, and remote loopback modes can be selected. multidrop applications are supported. a 3.6864-mhz crystal drives the baud rate generators. each transmit and receive channel can be programmed for a different baud rate, or an external 1 and 16 clock input can be selected. full modem support is provided with separate request-to-send (rts) and clear- to-send (cts) signals for each channel. one channel also provides service request signals. the two serial ports can sustain rates of 9.8 mbps with a 25-mhz system clock in 1 mode, 612 kbps in 16 mode (6.5 mbps and 410 kbps @ 16.78 mhz). 1.3.4 timer modules timers and counters are used in a system to monitor elapsed time, generate waveforms, measure signals, keep time-of-day clocks, initiate dram refresh cycles, count events, and provide ?ime slices?to ensure that no task dominates the activity of the processor. a counter that counts clock pulses makes a timer, which is most useful when it causes certain actions to occur in response to reaching desired counts. the mc68340 has two, identical, versatile, on-chip counter/timers as well as a simple timer in the sim40. these general-purpose counter/timers can be used for precisely timed events without the errors to which software-based counters and timers are susceptible e.g., errors caused by dynamic memory refreshing, dma cycle steals, and interrupt servicing. the programmable timer operating modes are input capture, output compare, square-wave generation, variable duty-cycle square-wave generation, variable-width single-shot pulse generation, event counting, period measurement, and pulse-width measurement. each timer consists of a 16-bit countdown counter with an 8-bit countdown prescaler for a composite 24-bit resolution. the two timers can be externally cascaded for a maximum count width of 48 bits. the counter/timer can be clocked by the internal system clock generated by the sim40 ( ? 2) or by an external clock input. either the processor or external stimuli can trigger the starting and stopping of the counter. when a counter reaches a predetermined value, either an external output signal can be driven, or an interrupt can be made to the cpu32. the finest resolution of the timer is 80 ns with a 25-mhz system clock (125 ns @ 16.78 mhz). 1.4 power consumption management the mc68340 is very power efficient due to its advanced 0.8- m hcmos process technology and its static logic design. the resulting power consumption is typically 900?w in full operation @ 25?hz (650?w @ 16.78?hz)?ar less than the comparable discrete component implementation the mc68340 can replace. for applications employing reduced voltage operation, selection of the mc68340v, which f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 1- 9 requires only a 3.3-v power supply, reduces current consumption by 40?0% in all modes of operation (as well as reducing noise emissions). the mc68340 has many additional methods of dynamically controlling power consumption during operation. the frequency of operation can be lowered under software control to reduce current consumption when performance is less critical. idle internal peripheral modules can be turned off to save power (5?0% each). running a special low power stop (lpstop) instruction shuts down the active circuits in the cpu and peripheral modules, halting instruction execution. power consumption in this standby mode is reduced to about 350 m w. processing and power consumption can be resumed by resetting the part or by generating an interrupt with the sim40's periodic interrupt timer. 1.5 physical the mc68340 is available as 0?6.78 mhz and 0?5.16 mhz, 0 c to +70 c and -40 c to +85 c, and 5.0 v 5% and 3.3 v 0.3 supply voltages (reduced frequencies at 3.3 v) . thirty-two power and ground leads minimize ground bounce and ensure proper isolation of different sections of the chip, including the clock oscillator. a 144 pins are used for signals and power. the mc68340 is available in a gull-wing ceramic quad flat pack (cqfp) with 25.6-mil (0.001-in) lead spacing or a 15 15 plastic pin grid array (ppga) with 0.1-in pin spacing. 1.6 compact disc-interactive the mc68340 was designed to meet the needs of many markets, including compact disc- interactive (cd-i). cd-i is an emerging standard for a publishing medium that will bring multimedia to a broad general audience?he consumer. cd-i players combine television and stereo systems as output devices, with interactive control using a tv remote-control- like device to provide a multimedia experience selected from software ?itles?contained in compressed form on standard compact discs. the highly integrated mc68340 is ideal as the central processor for cd-i players. it provides the m68000 microprocessor code compatibility and dma functions required by the cd-i green book specification as well as many other useful on-chip functions for a very cost-effective solution. the extra demands of full-motion video cd-i systems make the best use of the mc68340 high performance. the mc68340 is cd-i compliant and has been cd-i qualified. with its low voltage operation, the mc68340v is the only practical choice for portable cd-i. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 1- 10 mc68340 user? manual motorola 1.7 more information the following table lists available documentation related to the mc68340: document number document name br1114/d m68300 integrated processor family mc68340/d mc68340 technical summary mc68340um/ad mc68340 user's manual m68000pm/ad m68000 family programmer's reference manual an1063/d dram controller for the mc68340 an453 software implementation of spi on the mc68340 br573/d m68340 evaluation system product brief br729/d the 68k source br1407/d 3.3 volt logic and interface circuits f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 2- 1 section 2 signal descriptions this section contains brief descriptions of the mc68340 input and output signals in their functional groups as shown in figure 2-1. cpu32 core two-channel serial i/o two-channel dma controller timer module imb rxdb rxda txdb txda ctsb ctsa sclk x2 x1 bkpt/dsclk freeze ipipe/dso ifetch/dsi dreq2 dreq1 dack2 dack1 done2 done1 tgate1 tgate2 tin1 tin2 tout1 tout2 port a a31/port a7/iack7 a30/port a6/iack6 a29/port a5/iack5 a28/port a4/iack4 a27/port a3/iack3 a26/port a2/iack2 a25/port a1/iack1 a24/port a0 port b irq7/port b7 irq6/port b6 irq5/port b5 irq3/port b3 cs3/irq4/port b4 cs2/irq2/port b2 cs1/irq1/port b1 cs0/avec modck/port b0 extal xtal clkout external bus interface bus arbitration clock system integration module test tck tms tdi tdo a23?0 fc3?c0 d15?0 reset berr halt as ds r/w siz1 siz0 dsack1 dsack0 br bg bgack rmc output port txrdya/op6 rxrdya/ffulla/op4 rtsb/op1 rtsa/op0 timer module xfc figure 2-1. functional signal groups f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 2- 2 mc68340 user? manual motorola 2.1 signal index the input and output signals for the mc68340 are listed in table 2-1. the name, mnemonic, and brief functional description are presented. for more detail on each signal, refer to the signal paragraph. guaranteed timing specifications for the signals listed in table 2-1 can be found in section 11 electrical characteristics . table 2-1. signal index signal name mnemonic function input/ output address bus a23?0 lower 24 bits of the address bus out address bus/port a7?0/ interrupt acknowledge a31?24 upper eight bits of the address bus, parallel i/o port, or interrupt acknowledge lines out/i/o/out data bus d15?0 the 16-bit data bus used to transfer byte or word data i/o function codes fc3?c0 identify the processor state and the address space of the current bus cycle out chip select 3?/ interrupt request level/ port b4, b2, b1 cs3?s1 enables peripherals at programmed addresses, interrupt priority level to the cpu32, or parallel i/o port out/in/ i/o chip select 0/autovector cs0 enables peripherals at programmed addresses or requests an automatic vector out/in bus request br indicates that an external device requires bus mastership in bus grant bg indicates that current bus cycle is complete and the mc68340 has relinquished the bus out bus grant acknowledge bgack indicates that an external device has assumed bus mastership in data and size acknowledge dsack1, dsack0 provides asynchronous data transfers and dynamic bus sizing in read-modify-write cycle rmc identifies the bus cycle as part of an indivisible read - modify-write operation out address strobe as indicates that a valid address is on the address bus out data strobe ds during a read cycle, ds indicates that an external device should place valid data on the data bus. during a write cycle, ds indicates that valid data is on the data bus. out size siz1, siz0 indicates the number of bytes remaining to be transferred for this cycle out read/write r/ w indicates the direction of data transfer on the bus out interrupt request level/ port b7, b6, b5, b3 irq7, irq6, irq5, irq3 provides an interrupt priority level to the cpu32 or becomes a parallel i/o port in/i/o reset reset system reset i/o halt halt suspends external bus activity i/o bus error berr indicates an invalid bus operation is being attempted in system clock clkout system clock out out crystal oscillator extal, xtal connections for an external crystal or oscillator to the internal oscillator circuit in, out external filter capacitor xfc connection pin for an external capacitor to filter the circuit of the phase-locked loop in f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 2- 3 table 2-1. signal index (continued) signal name mnemonic function input/ output clock mode select/ port b0 modck selects the source of the internal system clock upon reset or becomes a parallel i/o port in/i/o instruction fetch/ development serial in ifetch /dsi indicates when the cpu32 is performing an instruction word prefetch and when the instruction pipeline has been flushed or provides background debug mode serial in out/in instruction pipe/ development serial out ipipe/ dso used to track movement of words through the instruction pipeline or provides background debug mode serial out out/out breakpoint/development serial clock bkpt /dsclk signals a hardware breakpoint to the cpu32 or provides background debug mode serial clock in/ freeze freeze indicates that the cpu32 has entered background debug mode out transmit data txda, txdb transmitter serial data output from the serial module out clear-to-send ctsa, ctsb serial module clear-to-send inputs in request-to-send/ op1, op0 rtsb, rtsa channel request-to-send outputs or discrete outputs out/out serial crystal oscillator x1, x2 connections for an external crystal to the serial module internal oscillator circuit serial clock sclk external serial module clock input in transmitter ready/op6 t ? rdya indicates transmit buffer has a character or becomes a parallel output out/out receiver ready/ fifo full/op4 r ? rdya indicates receive buffer has a character, the receiver fifo buffer is full or becomes a parallel output out/out/out dma request dre q2, dreq1 input that starts a dma process in dma acknowledge dack2, dack1 output that signals an access during dma out dma done done2, done1 bi-directional signal that indicates the last transfer i/o timer gate tgate2, tgate1 counter enable input to timer in timer input tin2, tin1 time reference input to timer in timer output tout2, tout1 output waveform from timer out test clock tck provides a clock for ieee 1149.1 test logic in test mode select tms controls test mode operations in test data in tdi shifts in instructions and test data in test data out tdo shifts out instructions and test data out synchronizer power v ccsyn quiet power supply to vco; also used to control synthesizer mode after reset. system power supply and ground v cc , gnd power supply and ground to the mc68340 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 2- 4 mc68340 user? manual motorola note the terms assert and negate are used throughout this section to avoid confusion when dealing with a mixture of active-low and active-high signals. the term assert or assertion indicates that a signal is active or true, independent of the level represented by a high or low voltage. the term negate or negation indicates that a signal is inactive or false. 2.2 address bus the address bus signals are outputs that define the address of the byte (or the most significant byte) to be transferred during a bus cycle. the mc68340 places the address on the bus at the beginning of a bus cycle. the address is valid while as is asserted. the address bus consists of the following two groups. refer to section 3 bus operation for information on the address bus and its relationship to bus operation. 2.2.1 address bus (a23?0) these three-state outputs (along with a31?24) provide the address for the current bus cycle, except in the cpu address space. 2.2.2 address bus (a31?24) these pins can be programmed as the most significant eight address bits, port a parallel i/o, or interrupt acknowledge signals. these pins can be used for more than one of their multiplexed functions as long as the external demultiplexing circuit properly resolves interaction between the different functions. a31?24 these pins can function as the most significant eight address bits. port a7?0 these eight pins can serve as a dedicated parallel i/o port. see section 4 system integration module for more information on programming these pins. iack7 iack1 the mc68340 asserts one of these pins to indicate the level of an external interrupt during an interrupt acknowledge cycle. peripherals can use the iack ? signals instead of monitoring the address bus and function codes to determine that an interrupt acknowledge cycle is in progress and to obtain the current interrupt level. 2.3 data bus (d15?0) this bidirectional, nonmultiplexed, parallel bus contains the data being transferred to or from the mc68340. a read or write operation may transfer 8 or 16 bits of data (one or two bytes) in one bus cycle. during a read cycle, the data is latched by the mc68340 on the f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 2- 5 last falling edge of the clock for that bus cycle. for a write cycle, all 16 bits of the data bus are driven, regardless of the port width or operand size. the mc68340 places the data on the data bus approximately one-half clock cycle after as is asserted in a write cycle. 2.4 function codes (fc3?c0) these signals are outputs that indicate one of 16 address spaces to which the address applies. fifteen of these spaces are designated as either user or supervisor, program or data, and normal or direct memory access (dma) spaces. one other address space is designated as cpu space to allow the cpu32 to acquire specific control information not normally associated with read or write bus cycles. the function code signals are valid while as is asserted. see table 2-2 for more information. table 2-2. address space encoding function code bits 3210 address spaces 0000 reserved (motorola) 0001 user data space 0010 user program space 0011 reserved (user ) 0100 reserved (motorola) 0101 supervisor data space 0110 supervisor program space 0111 cpu space 1 x x x dma space 2.5 chip selects (cs3?s0) these pins can be programmed to be chip select output signals, port b parallel i/o and autovector input, or additional interrupt request lines. refer to section 4 system integration module for more information on these signals. cs3 cs0 the chip select output signals enable peripherals at programmed addresses. these signals are inactive high (not high impedance) after reset. cs0 is the chip select for a boot rom containing the reset vector and initialization program. it functions as the boot chip select immediately after reset. irq4, irq2, irq1 interrupt request lines are external interrupt lines to the cpu32. these additional interrupt request lines are selected by the firq bit in the module configuration register. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 2- 6 mc68340 user? manual motorola port b4, b2, b1, avec this signal group functions as three bits of parallel i/o and the autovector input. avec requests an automatic vector during an interrupt acknowledge cycle. 2.6 interrupt request level (irq7, irq6, irq5, irq3) these pins can be programmed to be either prioritized interrupt request lines or port b parallel i/o. irq7, irq6 , irq5, irq3 irq7 , the highest priority, is nonmaskable. irq6?rq1 are internally maskable interrupts. refer to section 5 cpu32 for more information on interrupt request lines. port b7, b6, b5, b3 these pins can be used as port b parallel i/o. refer to section 4 system integration module for more information on parallel i/o signals. 2.7 bus control signals these signals control the bus transfer operations of the mc68340. refer to section 3 bus operation for more information on these signals. 2.7.1 data and size acknowledge ( dsack1, dsack0 ) these two active-low input signals allow asynchronous data transfers and dynamic data bus sizing between the mc68340 and external devices as listed in table 2-3. during bus cycles, external devices assert dsack1 and/or dsack0 as part of the bus protocol. during a read cycle, this signals the mc68340 to terminate the bus cycle and to latch the data. during a write cycle, this indicates that the external device has successfully stored the data and that the cycle may terminate. table 2-3. dsack ? encoding dsack 1 dsack 0 result 1 1 insert wait states in current bus cycle 1 0 complete cycle?ata bus port size is 8 bits 0 1 complete cycle?ata bus port size is 16 bits 0 0 reserved?efaults to 16-bit port size can be used for 32-bit dma cycles 2.7.2 address strobe ( as ) as is an output timing signal that indicates the validity of both an address on the address bus and many control signals. as is asserted approximately one-half clock cycle after the beginning of a bus cycle. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 2- 7 2.7.3 data strobe ( ds ) ds is an output timing signal that applies to the data bus. for a read cycle, the mc68340 asserts ds and as simultaneously to signal the external device to place data on the bus. for a write cycle, ds signals to the external device that the data to be written is valid. the mc68340 asserts ds approximately one clock cycle after the assertion of as during a write cycle. 2.7.4 transfer size (siz1, siz0) these output signals are driven by the bus master to indicate the number of operand bytes remaining to be transferred in the current bus cycle as noted in table 2-4. table 2-4. sizx signal encoding siz1 siz0 transfer size 0 1 byte 1 0 word 1 1 three byte 0 0 long word 2.7.5 read/write (r/ w ) this active-high output signal is driven by the bus master to indicate the direction of a data transfer on the bus. a logic one indicates a read from a slave device; a logic zero indicates a write to a slave device. 2.8 bus arbitration signals the following signals are the bus arbitration control signals used to determine the bus master. refer to section 3 bus operation for more information on these signals. 2.8.1 bus request ( br ) this active-low input signal indicates that an external device needs to become the bus master. 2.8.2 bus grant ( bg ) assertion of this active-low output signal indicates that the mc68340 has relinquished the bus. 2.8.3 bus grant acknowledge (bgack) assertion of this active-low input indicates that an external device has become the bus master. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 2- 8 mc68340 user? manual motorola 2.8.4 read-modify-write cycle ( rmc ) this output signal identifies the bus cycle as part of an indivisible read-modify-write operation. it remains asserted during all bus cycles of the read-modify-write operation to indicate that bus ownership cannot be transferred. 2.9 exception control signals these signals are used by the mc68340 to recover from an exception. 2.9.1 reset ( reset ) this active-low, open-drain, bidirectional signal is used to initiate a system reset. an external reset signal (as well as a reset from the sim40) resets the mc68340 and all external devices. a reset signal from the cpu32 (asserted as part of the reset instruction) resets external devices; the internal state of the cpu32 is not affected. the on-chip modules are reset, except for the sim40. however, the module configuration register for each on-chip module is not altered. when asserted by the mc68340, this signal is guaranteed to be asserted for a minimum of 512 clock cycles. refer to section 3 bus operation for a description of bus reset operation and section 5 cpu32 for information about the reset exception. 2.9.2 halt ( halt ) this active-low, open-drain, bidirectional signal is asserted to suspend external bus activity, to request a retry when used with berr , or to perform a single-step operation. as an output, halt indicates a double bus fault by the cpu32. refer to section 3 bus operation for a description of the effects of halt on bus operation. 2.9.3 bus error ( berr ) this active-low input signal indicates that an invalid bus operation is being attempted or, when used with halt , that the processor should retry the current cycle. refer to section 3 bus operation for a description of the effects of berr on bus operation. 2.10 clock signals these signals are used by the mc68340 for controlling or generating the system clocks. see section 4 system integration module for more information on the various clocking methods and frequencies. 2.10.1 system clock (clkout) this output signal is the system clock output and is used as the bus timing reference by external devices. clkout can be varied in frequency or slowed in low power stop mode to conserve power. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 2- 9 2.10.2 crystal oscillator (extal, xtal) these two pins are the connections for an external crystal to the internal oscillator circuit. if an external oscillator is used, it should be connected to extal, with xtal left open. 2.10.3 external filter capacitor (xfc) this pin is used to add an external capacitor to the filter circuit of the phase-locked loop. the capacitor should be connected between xfc and vccsyn. 2.10.4 clock mode select (modck) this pin selects the source of the internal system clock during reset. after reset, it can be programmed to be port b parallel i/o. modck the state of this active-high input signal during reset selects the source of the internal system clock. if modck is high during reset, the internal voltage-controlled oscillator (vco) furnishes the system clock in crystal mode. if modck is low during reset, an external clock source at the extal pin furnishes the system clock output in external clock mode. port b0 this pin can be used as a port b parallel i/o. 2.11 instrumentation and emulation signals these signals are used for test or software debugging. see section 5 cpu32 for more information on these signals and background debug mode. 2.11.1 instruction fetch (ifetch) this pin functions as ifetch in normal operation and as dsi in background debug mode . ifetch this active-low output signal indicates when the cpu32 is performing an instruction word prefetch and when the instruction pipeline has been flushed. dsi this development serial input signal helps to provide serial communications for background debug mode. 2.11.2 instruction pipe (ipipe) this pin functions as ipipe in normal operation and as dso in background debug mode. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 2- 10 mc68340 user? manual motorola ipipe this active-low output signal is used to track movement of words through the instruction pipeline. dso this development serial output signal helps to provide serial communications for background debug mode. 2.11.3 breakpoint (bkpt) this pin functions as bkpt in normal operation and as dsclk in background debug mode. bkpt this active-low input signal is used to signal a hardware breakpoint to the cpu32. dsclk this development serial clock input helps to provide serial communications for background debug mode. 2.11.4 freeze (freeze) assertion of this active-high output signal indicates that the cpu32 has acknowledged a breakpoint and has initiated background mode operation. 2.12 dma module signals the following signals are used by the direct memory access (dma) controller module to provide external handshake for either a source or destination. see section 6 dma module for additional information on these signals. 2.12.1 dma request ( dreq2, dreq1 ) this active-low input is asserted by a peripheral device to request an operand transfer between that peripheral and memory. the assertion of dreq ? starts the dma process. the assertion level in external burst mode is level sensitive; in external cycle steal mode, it is falling-edge sensitive. 2.12.2 dma acknowledge (dack2, dack1) this active-low output is asserted by the dma to signal to a peripheral that an operand is being transferred in response to a previous transfer request. 2.12.3 dma done ( done2, done1 ) this active-low bidirectional signal is asserted by the dma or a peripheral device during any dma bus cycle to indicate that the last data transfer is being performed. done ? is an active input in any mode. as an output, it is only active in external request mode. an external pullup resistor is required even during operation in the internal request mode. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 2- 11 2.13 serial module signals the following signals are used by the serial module for data and clock signals. see section 7 serial module for more information on these signals. 2.13.1 serial crystal oscillator (x2, x1) these pins furnish the connection to a crystal or external clock, which must be supplied when using the baud rate generator. an external clock is connected to the x1 pin; x2 is left floating. 2.13.2 serial external clock input (sclk) this input can be used as the external clock input for channel a or channel b, bypassing the baud rate generator. 2.13.3 receive data (rxda, rxdb) these signals are the receiver serial data input for each channel. data received on this signal is sampled on the rising edge of the clock source, with the least significant bit received first. 2.13.4 transmit data (txda, txdb) these signals are the transmitter serial data output for each channel. the output is held high ('mark' condition) when the transmitter is disabled, idle, or operating in the local loopback mode. data is shifted out on this signal at the falling edge of the clock source, with the least significant bit transmitted first. 2.13.5 clear to send (ctsa, ctsb) these active-low signals can be programmed as the clear-to-send inputs for each channel. 2.13.6 request to send (rtsa, rtsb) these active-low signals can be programmed as request-to-send outputs or used as discrete outputs. rtsb, rtsa when used for this function, these signals function as the request-to-send outputs. op1, op0 when used for this function, these outputs are controlled by the value of bit 1 and bit 0, respectively, in the output port data registers. 2.13.7 transmitter ready (t ? rdya) this active-low output can be programmed as the channel a transmitter ready status indicator or used as a discrete output. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 2- 12 mc68340 user? manual motorola t ? rdya when used for this function, this signal reflects the complement of the status of bit 2 of the channel a status register. this signal can be used to control parallel data flow by acting as an interrupt to indicate when the transmitter contains a character. op6 when used for this function, this output is controlled by bit 6 in the output port data registers. 2.13.8 receiver ready (r ? rdya) this active-low output signal can be programmed as the channel a receiver ready, channel a fifo full indicator, or a dedicated parallel output. r ? rdya when used for this function, this signal reflects the complement of the status of bit 1 of the interrupt status register. this signal can be used to control parallel data flow by acting as an interrupt to indicate when the receiver contains a character. ffulla when used for this function, this signal reflects the complement of the status of bit 1 of the interrupt status register. this signal can be used to control parallel data flow by acting as an interrupt to indicate when the receiver fifo is full. op4 when used for this function, this output is controlled by bit 4 in the output port data registers. 2.14 timer signals the following external signals are used by the timer modules. see section 8 timer modules for additional information on these signals. 2.14.1 timer gate ( tgate2, tgate1 ) these active-low inputs can be programmed to enable and disable the counters and prescalers. tgate ? can also be programmed as a simple input. 2.14.2 timer input (tin2, tin1) these inputs can be programmed as clocks that cause events to occur in the counters and prescalers. 2.14.3 timer output (tout2, tout1) these outputs drive the various output waveforms generated by the timers. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 2- 13 2.15 test signals the following signals are used with the on-board test logic defined by the ieee 1149.1 standard. see section 9 ieee 1149.1 test access port for more information on the use of these signals. 2.15.1 test clock (tck) this input provides a clock for on-board test logic defined by the ieee 1149.1 standard. 2.15.2 test mode select (tms) this input controls test mode operations for on-board test logic defined by the ieee 1149.1 standard. 2.15.3 test data in (tdi) this input is used for serial test instructions and test data for on-board test logic defined by the ieee 1149.1 standard. 2.15.4 test data out (tdo) this output is used for serial test instructions and test data for on-board test logic defined by the ieee 1149.1 standard. 2.16 synthesizer power (v ccsyn ) this pin supplies a quiet power source to the vco to provide greater frequency stability. it is also used to control the synthesizer mode after reset. see section 4 system integration module for more information. 2.17 system power and ground (v cc and gnd) these pins provide system power and ground to the mc68340. multiple pins are provided for adequate current capability. all power supply pins must have adequate bypass capacitance for high-frequency noise suppression. 2.18 signal summary table 2-5 presents a summary of all the signals discussed in the preceding paragraphs. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 2- 14 mc68340 user? manual motorola table 2-5. signal summary signal name mnemonic input/output active state three-state address bus a23?0 out yes address bus port a7?0/ interrupt acknowledge a31?24 out/i/o/out ??low yes data bus d15?0 i/o yes function codes fc3?c0 out yes chip select 3/interrupt request level/port b4, b2, b1 cs3?s1 out/in/i/o low/low/ no chip select 0/autovector cs0 out/in low/low no bus request br in low bus grant bg out low no bus grant acknowledge bgack in low data and size acknowledge dsack1, dsack0 in low read-modify-write cycle rmc out low yes address strobe as out low yes data strobe ds out low yes size siz1, siz0 out yes read/write r/ w out high/low yes interrupt request level/ port b7, b6, b5, b3 irq7, irq6, irq5, irq3 in/i/o low/ reset reset i/o low no halt halt i/o low no bus error berr in low system clock clkout out no crystal oscillator extal, xtal in, out external filter capacitor xfc in clock mode select/port b0 modck in/i/o / instruction fetch/ development serial in ifetch /dsi out/in low/ no/ instruction pipe/ development serial out ipipe /dso out/out low/ no/ breakpoint/ development serial clock bkpt /dsclk in/in low/ ? freeze freeze out high no receive data rxda, rxdb in f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 2- 15 table 2-5. signal summary (continued) signal name mnemonic input/output active state three-state transmit data txda, txdb out no clear-to-send ctsa, ctsb in low request-to-send/ op1, op0 rtsb, rtsa out/out low/ no serial clock sclk in transmitter ready/op6 t ? rdya out/out low/ no receiver ready/ fifo full/op4 r ? rdya out/out/out low/low/ no dma request dreq2, dreq1 in low dma acknowledge dack2, dack1 out low no dma done done2, done1 i/o low no timer gate tgate2, tgate1 in low timer input tin2, tin1 in timer output tout2, tout1 out yes test clock tck in test mode select tms in high test data in tdi in high test data out tdo out high synchronizer power v ccsyn system power supply and return v cc , gnd f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 3- 1 section 3 bus operation this section provides a functional description of the bus, the signals that control it, and the bus cycles provided for data transfer operations. it also describes the error and halt conditions, bus arbitration, and reset operation. operation of the external bus is the same whether the mc68340 or an external device is the bus master; the names and descriptions of bus cycles are from the viewpoint of the bus master. for exact timing specifications, refer to section 11 electrical characteristics . the mc68340 architecture supports byte, word, and long-word operands allowing access to 8- and 16-bit data ports through the use of asynchronous cycles controlled by the siz1/siz0 outputs and dsack1/dsack0 inputs. the mc68340 requires word and long- word operands to be located in memory on word boundaries. the only type of transfer that can be performed to an odd address is a single-byte transfer, referred to as an odd-byte transfer. for an 8-bit port, multiple bus cycles may be required for an operand transfer due to either misalignment or a word or long-word operand. 3.1 bus transfer signals the bus transfers information between the mc68340 and external memory or a peripheral device. external devices can accept or provide 8 bits or 16 bits in parallel and must follow the handshake protocol described in this section. the maximum number of bits accepted or provided during a bus transfer is defined as the port width. the mc68340 contains an address bus that specifies the address for the transfer and a data bus that transfers the data. control signals indicate the beginning and type of the cycle as well as the address space and size of the transfer. the selected device then controls the length of the cycle with the signal(s) used to terminate the cycle. strobe signals, one for the address bus and another for the data bus, indicate the validity of the address and provide timing information for the data. both asynchronous and synchronous operation is possible for any port width. in asynchronous operation, the bus and control input signals are internally synchronized to the mc68340 clock, introducing a delay. this delay is the time required for the mc68340 to sample an input signal, synchronize the input to the internal clocks, and determine whether it is high or low. in synchronous mode, the bus and control input signals must be timed to setup and hold times. since no synchronization is needed, bus cycles can be completed in three clock cycles in this mode. additionally, using the fast-termination option of the chip select signals, two-clock operation is possible. furthermore, for all inputs, the mc68340 latches the level of the input during a sample window around the falling edge of the clock signal. this window is illustrated in figure 3-1, where t su and t h are the input setup and hold times, respectively. to ensure that an input signal is recognized on a specific falling edge of the clock, that input must be stable during f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 3- 2 mc68340 user? manual motorola the sample window. if an input makes a transition during the window time period, the level recognized by the mc68340 is not predictable; however, the mc68340 always resolves the latched level to either a logic high or low before using it. in addition to meeting input setup and hold times for deterministic operation, all input signals must obey the protocols described in this section. sample window t su t h clkout ext figure 3-1. input sample window note the terms assert and negate are used throughout this section to avoid confusion when dealing with a mixture of active-low and active-high signals. the term assert or assertion indicates that a signal is active or true independent of the level represented by a high or low voltage. the term negate or negation indicates that a signal is inactive or false. 3.1.1 bus control signals the mc68340 initiates a bus cycle by driving the a31?0, sizx, fcx, and r/ w outputs. at the beginning of a bus cycle, siz1 and siz0 are driven with fc3?c0. siz1 and siz0 indicate the number of bytes remaining to be transferred during an operand cycle (consisting of one or more bus cycles). table 3-1 lists the encoding of the sizx signal. these signals are valid while as is asserted. the r/ w signal determines the direction of the transfer during a bus cycle. driven at the beginning of a bus cycle, r/ w is valid while as is asserted. r/ w only transitions when a write cycle is preceded by a read cycle or vice versa. the signal may remain low for consecutive write cycles. the rmc signal is asserted at the beginning of the first bus cycle of a read-modify-write operation and remains asserted until completion of the final bus cycle of the operation. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 3- 3 table 3-1. sizx signal encoding siz1 siz0 transfer size 0 1 byte 1 0 word 1 1 three bytes 0 0 long word 3.1.2 function code signals fc3?c0 are outputs that indicate one of 16 address spaces to which the address applies. fifteen of these spaces are designated as either user or supervisor, program or data, and normal or direct memory access (dma) spaces. one other address space is designated as cpu space to allow the cpu32 to acquire specific control information not normally associated with read or write bus cycles. fc3?c0 are valid while as is asserted. function codes (see table 3-2) can be considered as extensions of the 32-bit address that can provide up to 16 different 4-gbyte address spaces. function codes are automatically generated by the cpu32 to select address spaces for data and program at both user and supervisor privilege levels, a cpu address space for processor functions, and an alternate master address space. user programs access only their own program and data areas to increase protection of system integrity and can be restricted from accessing other information. the s-bit in the cpu32 status register is set for supervisor accesses and cleared for user accesses to provide differentiation. refer to 3.4 cpu space cycles for more information. table 3-2. address space encoding function code bits 3210 address spaces 0000 reserved (motorola) 0001 user data space 0010 user program space 0011 reserved (user ) 0100 reserved (motorola) 0101 supervisor data space 0110 supervisor program space 0111 cpu space 1 x x x dma space f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 3- 4 mc68340 user? manual motorola 3.1.3 address bus (a31?0) these signals are outputs that define the address of the byte (or the most significant byte) to be transferred during a bus cycle. the mc68340 places the address on the bus at the beginning of a bus cycle. the address is valid while as is asserted. 3.1.4 address strobe ( as ) this output timing signal indicates the validity of many control signals and the address on the address bus. as is asserted approximately one-half clock cycle after the beginning of a bus cycle. 3.1.5 data bus (d15?0) this bidirectional, nonmultiplexed, parallel bus contains the data being transferred to or from the mc68340. a read or write operation may transfer 8 or 16 bits of data (one or two bytes) in one bus cycle. during a read cycle, the data is latched by the mc68340 on the last falling edge of the clock for that bus cycle. for a write cycle, all 16 bits of the data bus are driven, regardless of the port width or operand size. the mc68340 places the data on the data bus approximately one-half clock cycle after as is asserted in a write cycle. 3.1.6 data strobe ( ds ) ds is an output timing signal that applies to the data bus. for a read cycle, the mc68340 asserts ds and as simultaneously to signal the external device to place data on the bus. for a write cycle, ds signals to the external device that the data to be written is valid. the mc68340 asserts ds approximately one clock cycle after the assertion of as during a write cycle. 3.1.7 bus cycle termination signals the following signals can terminate a bus cycle. 3.1.7.1 data transfer and size acknowledge signals ( dsack1 and dsack0 ). during bus cycles, external devices assert dsack1 and/or dsack0 as part of the bus protocol. during a read cycle, this signals the mc68340 to terminate the bus cycle and to latch the data. during a write cycle, this indicates that the external device has successfully stored the data and that the cycle may terminate. these signals also indicate to the mc68340 the size of the port for the bus cycle just completed (see table 3-3). refer to 3.3.1 read cycle for timing relationships of dsack1 and dsack0 . additionally, the system integration module (sim40) chip select address mask register can be programmed to internally generate dsack1 and dsack0 for external accesses, eliminating logic required to generate these signals. however, if external dsack ? signals are returned earlier than indicated by the dd bits in the chip select address mask register, the cycle will terminate sooner than programmed. refer to section 4 system integration module for additional information. the sim40 can alternatively be programmed to generate a fast termination cycle, providing a two-cycle external access. refer to 3.2.6 fast termination cycles for additional information on these cycles. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 3- 5 3.1.7.2 bus error ( berr ) . this signal is also a bus cycle termination indicator and can be used in the absence of dsack ? to indicate a bus error condition. berr can also be asserted in conjunction with dsack ? to indicate a bus error condition, provided it meets the appropriate timing described in this section and in section 11 electrical characteristics . additionally, berr and halt can be asserted together to indicate a retry termination. refer to 3.5 bus exception control cycles for additional information on the use of these signals. the internal bus monitor can be used to generate an internal bus error signal for internal and internal-to-external transfers. if the bus cycles of an external bus master are to be monitored, external berr generation must be provided since the internal bus error monitor has no information about transfers initiated by an external bus master. 3.1.7.3 autovector ( avec ). this signal can be used to terminate interrupt acknowledge cycles, indicating that the mc68340 should internally generate a vector (autovector) number to locate an interrupt handler routine. avec can be generated either externally or internally by the sim40 (see section 4 system integration module for additional information). avec is ignored during all other bus cycles. 3.2 data transfer mechanism the mc68340 supports byte, word, and long-word operands, allowing access to 8- and 16-bit data ports through the use of asynchronous cycles controlled by dsack1 and dsack0 . the mc68340 also supports byte, word, and long-word operands, allowing access to 8- and 16-bit data ports through the use of synchronous cycles controlled by the fast termination capability of the sim40. 3.2.1 dynamic bus sizing the mc68340 dynamically interprets the port size of the addressed device during each bus cycle, allowing operand transfers to or from 8- and 16-bit ports. during an operand transfer cycle, the slave device signals its port size (byte or word) and indicates completion of the bus cycle to the mc68340 through the use of the dsack ? inputs. refer to table 3-3 for dsack ? encoding. table 3-3. dsack ? encoding dsack1 dsack0 result 1 (negated) 1 (negated) insert wait states in current bus cycle 1 (negated) 0 (asserted) complete cycle?ata bus port size is 8 bits 0 (asserted) 1 (negated) complete cycle?ata bus port size is 16 bits 0 (asserted) 0 (asserted) reserved?efaults to 16-bit port size can be used for 32-bit dma cycles f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 3- 6 mc68340 user? manual motorola for example, if the mc68340 is executing an instruction that reads a long-word operand from a 16-bit port, the mc68340 latches the 16 bits of valid data and runs another bus cycle to obtain the other 16 bits. the operation from an 8-bit port is similar, but requires four read cycles. the addressed device uses dsack ? to indicate the port width. for instance, a 16-bit device always returns dsack ? for a 16-bit port (regardless of whether the bus cycle is a byte or word operation). dynamic bus sizing requires that the portion of the data bus used for a transfer to or from a particular port size be fixed. a 16-bit port must reside on data bus bits 15?, and an 8-bit port must reside on data bus bits 15?. this requirement minimizes the number of bus cycles needed to transfer data to 8- and 16-bit ports and ensures that the mc68340 correctly transfers valid data. the mc68340 always attempts to transfer the maximum amount of data on all bus cycles; for a word operation, it always assumes that the port is 16 bits wide when beginning the bus cycle. the bytes of operands are designated as shown in figure 3-2. the most significant byte of a long-word operand is op0, and op3 is the least significant byte. the two bytes of a word-length operand are op0 (most significant) and op1. the single byte of a byte-length operand is op0. these designations are used in the figures and descriptions that follow. figure 3-2 shows the required organization of data ports on the mc68340 bus for both 8- and 16-bit devices. the four bytes shown in figure 3-2 are connected through the internal data bus and data multiplexer to the external data bus. the data multiplexer establishes the necessary connections for different combinations of address and data sizes. the multiplexer takes the two bytes of the 16-bit bus and routes them to their required positions. the positioning of bytes is determined by the siz1/siz0 and a0 outputs. the siz1/siz0 outputs indicate the number of bytes to be transferred during the current bus cycle (see table 3-1). the number of bytes transferred during a read or write bus cycle is equal to or less than the size indicated by the siz1/siz0 outputs, depending on port width. for example, during the first bus cycle of a long-word transfer to a word port, the size outputs indicate that four bytes are to be transferred although only two bytes are moved on that bus cycle. the address line a0 also affects the operation of the data multiplexer. during an operand transfer, a31?1 indicate the word base address of that portion of the operand to be accessed, and a0 indicates the byte offset from the base (i.e., either odd or even byte). figure 3-2 lists the bytes required on the data bus for read cycles. the entries shown as opn are portions of the requested operand that are read or written during that bus cycle and are defined by siz1/siz0 and a0 for the bus cycle. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 3- 7 op1 op0 op0 op2 op1 op0 op3 op2 op1 op0 31 23 15 70 d0 d8 d15 d7 op0 op0 (op0) op0 op0 (op0) (op0) op0 (op1) op1 op0 (op1) op0 op1 a0 siz0 siz1 case (a) (b) (c) (d) (e) (f) (g) 01x10 0100x 0110x 10010 1000x 00010 0000x transfer case byte to byte byte to word (even) byte to word (odd) word to byte (aligned) word to word (aligned) long word to byte (aligned) long word to word (aligned) operand data bus dsack0 dsack1 notes: 1. operands in parentheses are ignored by the mc68340 during read cycles. 2. a 3-byte to byte transfer does occur as the second byte transfer of a long-word to byte port transfer. figure 3-2. mc68340 interface to various port sizes 3.2.2 misaligned operands in this architecture, the basic operand size is 16 bits. operand misalignment refers to whether an operand is aligned on a word boundary or overlaps the word boundary, determined by address line a0. when a0 is low, the address is even and is a word and byte boundary. when a0 is high, the address is odd and is a byte boundary only. a byte operand is properly aligned at any address; a word or long-word operand is misaligned at an odd address. at most, each bus cycle can transfer a word of data aligned on a word boundary. if the mc68340 transfers a long-word operand over a 16-bit port, the most significant operand word is transferred on the first bus cycle, and the least significant operand word is transferred on a following bus cycle. the cpu32 restricts all operands (both data and instructions) to be aligned. that is, word and long-word operands must be located on a word or long-word boundary, respectively. the only type of transfer that can be performed to an odd address is a single-byte transfer, referred to as an odd-byte transfer. if a misaligned access is attempted, the cpu32 generates an address error exception, and enters exception processing. refer to section 5 cpu32 for more information on exception processing. 3.2.3 operand transfer cases the following cases are examples of the allowable alignments of operands to ports. 3.2.3.1 byte operand to 8-bit port, odd or even (a0 = x). the mc68340 drives the address bus with the desired address and the sizx pins to indicate a single- byte operand. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 3- 8 mc68340 user? manual motorola dsack0 dsack1 a0 siz0 siz1 01x10 d0 d8 d15 d7 (op0) op0 op0 7 0 byte operand data bus cycle 1 for a read operation, the slave responds by placing data on bits 15? of the data bus, asserting dsack0 and negating dsack1 to indicate an 8-bit port. the mc68340 then reads the operand byte from bits 15? and ignores bits 7?. for a write operation, the mc68340 drives the single-byte operand on both bytes of the data bus because it does not know the port size until the dsack ? signals are read. the slave device reads the byte operand from bits 15? and places the operand in the specified location. the slave then asserts dsack0 to terminate the bus cycle. 3.2.3.2 byte operand to 16-bit port, even (a0 = 0). the mc68340 drives the address bus with the desired address and the sizx pins to indicate a single-byte operand. dsack0 dsack1 a0 siz0 siz1 0100x d0 d8 d15 d7 (op0) op0 op0 7 0 byte operand data bus cycle 1 for a read operation, the slave responds by placing data on bits 15? of the data bus and asserting dsack1 to indicate a 16-bit port. the mc68340 then reads the operand byte from bits 15? and ignores bits 7?. for a write operation, the mc68340 drives the single-byte operand on both bytes of the data bus because it does not know the port size until the dsack ? signals are read. the slave device reads the operand from bits 15? of the data bus and uses the address to place the operand in the specified location. the slave then asserts dsack1 to terminate the bus cycle. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 3- 9 3.2.3.3 byte operand to 16-bit port, odd (a0 = 1). the mc68340 drives the address bus with the desired address and the sizx pins to indicate a single-byte operand. dsack0 dsack1 a0 siz0 siz1 0110x d0 d8 d15 d7 (op0) op0 op0 7 0 byte operand data bus cycle 1 for a read operation, the slave responds by placing data on bits 7? of the data bus and asserting dsack1 to indicate a 16-bit port. the mc68340 then reads the operand byte from bits 7? and ignores bits 15?. for a write operation, the mc68340 drives the single-byte operand on both bytes of the data bus because it does not know the port size until the dsack ? signals are read. the slave device reads the operand from bits 7e0 of the data bus and uses the address to place the operand in the specified location. the slave then asserts dsack1 to terminate the bus cycle. 3.2.3.4 word operand to 8-bit port, aligned. the mc68340 drives the address bus with the desired address and the sizx pins to indicate a word operand. d0 d8 d15 d7 op0 op1 op0 op1 15 7 0 dsack0 dsack1 a0 siz0 siz1 10010 01110 word operand data bus cycle 1 cycle 2 (op1) (op1) 8 for a read operation, the slave responds by placing the most significant byte of the operand on bits 15? of the data bus and asserting dsack0 to indicate an 8-bit port. the mc68340 reads the most significant byte of the operand from bits 15? and ignores bits 7?. the mc68340 then decrements the transfer size counter, increments the address, and reads the least significant byte of the operand from bits 15? of the data bus. for a write operation, the mc68340 drives the word operand on bits 15? of the data bus. the slave device then reads the most significant byte of the operand from bits 15? of the data bus and asserts dsack0 to indicate that it received the data but is an 8-bit port. the mc68340 then decrements the transfer size counter, increments the address, and writes the least significant byte of the operand to bits 15? of the data bus. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 3- 10 mc68340 user? manual motorola 3.2.3.5 word operand to 16-bit port, aligned. the mc68340 drives the address bus with the desired address and the size pins to indicate a word operand. dsack0 dsack1 a0 siz0 siz1 1000x op0 op1 15 0 d0 d8 d15 d7 op0 op1 word operand data bus cycle 1 for a read operation, the slave responds by placing the data on bits 15? of the data bus and asserting dsack1 to indicate a 16-bit port. when dsack1 is asserted, the mc68340 reads the data on the data bus and terminates the cycle. for a write operation, the mc68340 drives the word operand on bits 15? of the data bus. the slave device then reads the entire operand from bits 15? of the data bus and asserts dsack1 to terminate the bus cycle. 3.2.3.6 long-word operand to 8-bit port, aligned. the mc68340 drives the address bus with the desired address and the sizx pins to indicate a long-word operand. dsack0 dsack1 a0 siz0 siz1 d0 d8 d15 d7 long-word operand data bus 11110 10010 01110 00010 op1 op0 op2 op3 31 23 15 7 0 op0 op1 op2 op3 (op1) (op1) (op3) (op3) cycle 2 cycle 3 cycle 4 cycle 1 for a read operation, shown in figure 3-3, the slave responds by placing the most significant byte of the operand on bits 15? of the data bus and asserting dsack0 to indicate an 8-bit port. the mc68340 reads the most significant byte of the operand (byte 0) from bits 15? and ignores bits 7?. the mc68340 then decrements the transfer size counter, increments the address, initiates a new cycle, and reads byte 1 of the operand from bits 15? of the data bus. the mc68340 repeats the process of decrementing the transfer size counter, incrementing the address, initiating a new cycle, and reading a byte to transfer the remaining two bytes. for a write operation, shown in figure 3-4, the mc68340 drives the two most significant bytes of the operand on bits 15? of the data bus. the slave device then reads only the most significant byte of the operand (byte 0) from bits 15? of the data bus and asserts dsack0 to indicate reception and an 8-bit port. the mc68340 then decrements the transfer size counter, increments the address, and writes byte 1 of the operand to bits 15? of the data bus. the mc68340 continues to decrement the transfer size counter, increment the address, and write a byte to transfer the remaining two bytes to the slave device. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 3- 11 clkout a31?0 fc3?c0 siz0 siz1 d15?8 d7?0 r/w as ds dsack0 dsack1 s0 s2 s4 s0 s2 s4 s0 s2 s4 s0 s2 s4 op0 4 bytes 3 bytes 2 bytes 1 byte byte read byte read byte read byte read op1 op2 op3 long-word operand read from 8-bit bus figure 3-3. long-word operand read timing from 8-bit port f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 3- 12 mc68340 user? manual motorola clkout a31?0 fc3?c0 siz0 siz1 d15?8 d7?0 r/w as ds dsack0 dsack1 s0 s2 s4 s0 s2 s4 s0 s2 s4 s0 s2 s4 4 bytes op0 op1 op2 op3 (op3) (op3) (op1) (op1) write write write write long-word operand write to 8-bit bus 2 bytes 1 byte 3 bytes figure 3-4. long-word operand write timing to 8-bit port 3.2.3.7 long-word operand to 16-bit port, aligned . figure 3-5 shows both long-word and word read and write timing to a 16-bit port. long-word operand data bus cycle 1 cycle 2 dsack0 dsack1 a0 siz0 siz1 0000x 1000x op1 op0 op2 op3 31 23 15 7 0 d0 d8 d15 d7 op0 op1 op2 op3 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 3- 13 clkout a31?0 fc3?c0 siz0 siz1 d15?8 d7?0 r/w as ds dsack0 dsack1 2 bytes 2 bytes 4 bytes s0 s2 s4 s0 s2 s4 s0 s2 s4 s0 s2 s4 s0 s2 s4 s0 s2 s4 2 bytes 2 bytes op0 op1 op2 op3 op0 op1 op0 op2 op0 op1 op3 op1 word read from 16-bit bus long word write to 16-bit bus word write to 16-bit bus long word read from 16-bit bus 4 bytes figure 3-5. long-word and word read and write timing?6-bit port the mc68340 drives the address bus with the desired address and drives the sizx pins to indicate a long-word operand. for a read operation, the slave responds by placing the two most significant bytes of the operand on bits 15? of the data bus and asserting dsack1 to indicate a 16-bit port. the mc68340 reads the two most significant bytes of the operand (bytes 0 and 1) from bits 15?. the mc68340 then decrements the transfer size counter by 2, increments the address by 2, initiates a new cycle, and reads bytes 2 and 3 of the operand from bits 15? of the data bus. for a write operation, the mc68340 drives the two most significant bytes of the operand on bits 15? of the data bus. the slave device then reads the two most significant bytes of the operand (bytes 0 and 1) from bits 15? of the data bus and asserts dsack1 to indicate reception and a 16-bit port. the mc68340 then decrements the transfer size counter by 2, increments the address by 2, and writes bytes 2 and 3 of the operand to bits 15? of the data bus. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 3- 14 mc68340 user? manual motorola 3.2.4 bus operation the mc68340 bus is asynchronous, allowing external devices connected to the bus to operate at clock frequencies different from the clock for the mc68340. bus operation uses the handshake lines ( as, ds, dsack1/dsack0, berr , and halt ) to control data transfers. as signals a valid address on the address bus, and ds is used as a condition for valid data on a write cycle. decoding the sizx outputs and lower address line a0 provides strobes that select the active portion of the data bus. the slave device (memory or peripheral) responds by placing the requested data on the correct portion of the data bus for a read cycle or by latching the data on a write cycle; the slave asserts the dsack1 / dsack0 combination that corresponds to the port size to terminate the cycle. alternatively, the sim40 can be programmed to assert the dsack1 / dsack0 combination internally and respond for the slave. if no slave responds or the access is invalid, external control logic may assert berr to abort the bus cycle or berr with halt to retry the bus cycle. dsack ? can be asserted before the data from a slave device is valid on a read cycle. the length of time that dsack ? may precede data must not exceed a specified value in any asynchronous system to ensure that valid data is latched into the mc68340. (see section 11 electrical characteristics for timing parameters.) note that no maximum time is specified from the assertion of as to the assertion of dsack ? . although the mc68340 can transfer data in a minimum of three clock cycles when the cycle is terminated with dsack ? , the mc68340 inserts wait cycles in clock-period increments until dsack ? is recognized. berr and/or halt can be asserted after dsack ? is asserted. berr and or halt must be asserted within the time specified after dsack ? is asserted in any asynchronous system. if this maximum delay time is violated, the mc68340 may exhibit erratic behavior. 3.2.5 synchronous operation with dsack ? although cycles terminated with dsack ? are classified as asynchronous, cycles terminated with dsack ? can also operate synchronously in that signals are interpreted relative to clock edges. the devices that use these cycles must synchronize the response to the mc68340 clock (clkout) to be synchronous. since the devices terminate bus cycles with dsack ? , the dynamic bus sizing capabilities of the mc68340 are available. the minimum cycle time for these cycles is also three clocks. to support systems that use the system clock to generate dsack ? and other asynchronous inputs, the asynchronous input setup time and the asynchronous input hold time are given. if the setup and hold times are met for the assertion or negation of a signal such as dsack ? , the mc68340 is guaranteed to recognize that signal level on that specific falling edge of the system clock. if the assertion of dsack ? is recognized on a particular falling edge of the clock, valid data is latched into the mc68340 (for a read cycle) on the next falling clock edge if the data meets the data setup time. in this case, the parameter for asynchronous operation can be ignored. the timing parameters are described in section 11 electrical characteristics . f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 3- 15 if a system asserts dsack ? for the required window around the falling edge of s2 and obeys the proper bus protocol by maintaining dsack ? (and/or berr / halt ) until and throughout the clock edge that negates as (with the appropriate asynchronous input hold time), no wait states are inserted. the bus cycle runs at its maximum speed for bus cycles terminated with dsack ? (three clocks per cycle). when berr (or berr and halt) is asserted after dsack ? , berr (and halt ) must meet the appropriate setup time prior to the falling clock edge one clock cycle after dsack ? is recognized. this setup time is critical, and the mc68340 may exhibit erratic behavior if it is violated. when operating synchronously, the data-in setup and hold times for synchronous cycles may be used instead of the timing requirements for data relative to ds . 3.2.6 fast termination cycles with an external device that has a fast access time, the chip select circuit fast termination enable (fte) can provide a two-clock external bus transfer. since the chip select circuits are driven from the system clock, the bus cycle termination is inherently synchronized with the system clock. refer to section 4 system integration module for more information on chip selects.when fast termination is selected, the dd bits of the corresponding address mask register are overridden. fast termination can only be used with zero wait states. to use the fast termination option, an external device should be fast enough to have data ready, within the specified setup time, by the falling edge of s4. figure 3-6 shows the dsack ? timing for a read with two wait states, followed by a fast termination read and write. when using the fast termination option, ds is asserted only in a read cycle, not in a write cycle. clkout r/w s0 s2 sw sw s4 s0 s4 s0 s4 s0 as ds dsackx d15ed0 s1 s3 s5 s1 s5 s1 s5 sw * sw * fast termination read two wait states in read * dsackx only internally asserted for fast termination cycles. fast termination write figure 3-6. fast termination timing f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 3- 16 mc68340 user? manual motorola 3.3 data transfer cycles the transfer of data between the mc68340 and other devices involves the following signals: address bus a31?0 data bus d15?0 control signals the address bus and data bus are parallel, nonmultiplexed buses. the bus master moves data on the bus by issuing control signals, and the bus uses a handshake protocol to ensure correct movement of the data. in all bus cycles, the bus master is responsible for de-skewing all signals it issues at both the start and end of the cycle. in addition, the bus master is responsible for de-skewing the acknowledge and data signals from the slave devices. the following paragraphs define read, write, and read-modify-write cycle operations. each bus cycle is defined as a succession of states that apply to the bus operation. these states are different from the mc68340 states described for the cpu32. the clock cycles used in the descriptions and timing diagrams of data transfer cycles are independent of the clock frequency. bus operations are described in terms of external bus states. 3.3.1 read cycle during a read cycle, the mc68340 receives data from a memory or peripheral device. if the instruction specifies a long-word or word operation, the mc68340 attempts to read two bytes at once. for a byte operation, the mc68340 reads one byte. the section of the data bus from which each byte is read depends on the operand size, address signal a0, and the port size. refer to 3.2.1 dynamic bus sizing and 3.2.2 misaligned operands for more information. figure 3-7 is a flowchart of a word read cycle. bus master slave address device 1. set r/w to read 2. drive address on a31?0 3. drive function code on fc3?c0 4. drive size pins for operand size acquire data 1. latch data 5. assert as and ds start next cycle 2. negate as and ds 1. decode address 2. place data on d15?0 present data 3. drive dsackx signals terminate cycle 1. remove data from d15?0 2. negate dsackx figure 3-7. word read cycle flowchart f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 3- 17 state 0?he read cycle starts in state 0 (s0). during s0, the mc68340 places a valid address on a31?0 and valid function codes on fc3?c0. the function codes select the address space for the cycle. the mc68340 drives r/ w high for a read cycle. siz1/siz0 become valid, indicating the number of bytes requested for transfer. state 1?ne-half clock later, in state 1 (s1), the mc68340 asserts as indicating a valid address on the address bus. the mc68340 also asserts ds during s1. the selected device uses r/ w , siz1 or siz0, a0, and ds to place its information on the data bus. one or both of the bytes (d15?8 and d7?0) are selected by siz1/siz0 and a0. state 2?s long as at least one of the dsack ? signals is recognized on the falling edge of s2 (meeting the asynchronous input setup time requirement), data is latched on the falling edge of s4, and the cycle terminates. state 3?f dsack ? is not recognized by the start of state 3 (s3), the mc68340 inserts wait states instead of proceeding to states 4 and 5. to ensure that wait states are inserted, both dsack1 and dsack0 must remain negated throughout the asynchronous input setup and hold times around the end of s2. if wait states are added, the mc68340 continues to sample dsack ? on the falling edges of the clock until one is recognized. state 4?t the falling edge of state 4 (s4), the mc68340 latches the incoming data and samples dsack ? to get the port size. state 5?he mc68340 negates as and ds during state 5 (s5). it holds the address valid during s5 to provide address hold time for memory systems. r/ w , siz1 and siz0, and fc3?c0 also remain valid throughout s5. the external device keeps its data and dsack ? signals asserted until it detects the negation of as or ds (whichever it detects first). the device must remove its data and negate dsack ? within approximately one clock period after sensing the negation of as or ds . dsack ? signals that remain asserted beyond this limit may be prematurely detected for the next bus cycle. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 3- 18 mc68340 user? manual motorola 3.3.2 write cycle during a write cycle, the mc68340 transfers data to memory or a peripheral device. figure 3-8 is a flowchart of a word write cycle. 1. negate ds and as 2. remove data from d15?0 bus master slave address device 1. set r/w to write 2. drive address on a31?0 3. drive function code on fc3?c0 4. drive size pins for operand size 5. assert as 6. place data on d15?0 7. assert ds terminate output transfer start next cycle 1. decode address 2. latch data from d15?0 accept data 3. assert dsackx signals terminate cycle 1. negate dsackx figure 3-8. word write cycle flowchart state 0?he write cycle starts in s0. during s0, the mc68340 places a valid address on a31?0 and valid function codes on fc3?c0. the function codes select the address space for the cycle. the mc68340 drives r/ w low for a write cycle. siz1/siz0 become valid, indicating the number of bytes to be transferred. state 1?ne-half clock later during s1, the mc68340 asserts as, indicating a valid address on the address bus. state 2?uring s2, the mc68340 places the data to be written onto d15?0, and samples dsack ? at the end of s2. state 3?he mc68340 asserts ds during s3, indicating that data is stable on the data bus. as long as at least one of the dsack ? signals is recognized by the end of s2 (meeting the asynchronous input setup time requirement), the cycle terminates one clock later. if dsack ? is not recognized by the start of s3, the mc68340 inserts wait states instead of proceeding to s4 and s5. to ensure that wait states are inserted, both dsack1 and dsack0 must remain negated throughout the asynchronous input setup and hold times around the end of s2. if wait states are added, the mc68340 continues to sample dsack ? on the falling edges of the clock until one is recognized. the selected device uses r/ w , siz1/siz0, and a0 to latch data from the appropriate byte(s) of d15?8 and d7?0. siz1/siz0 and a0 select the bytes of the data bus. if it has not already done so, the device asserts dsack ? to signal that it has successfully stored the data. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 3- 19 state 4?he mc68340 issues no new control signals during s4. state 5?he mc68340 negates as and ds during s5. it holds the address and data valid during s5 to provide address hold time for memory systems. r/ w , siz1/siz0, and fc3 fc0 also remain valid throughout s5. the external device must keep dsack ? asserted until it detects the negation of as or ds (whichever it detects first). the device must negate dsack ? within approximately one clock period after sensing the negation of as or ds . dsack ? signals that remain asserted beyond this limit may be prematurely detected for the next bus cycle. 3.3.3 read-modify-write cycle the read-modify-write cycle performs a read, conditionally modifies the data in the arithmetic logic unit, and may write the data out to memory. in the mc68340, this operation is indivisible, providing semaphore capabilities for multiprocessor systems. during the entire read-modify-write sequence, the mc68340 asserts rmc to indicate that an indivisible operation is occurring. the mc68340 does not issue a bg signal in response to a br signal during this operation. figure 3-9 is an example of a functional timing diagram of a read-modify-write instruction specified in terms of clock periods. clk a31?30 fc3?c0 s0 s2 s4 s2 s4 s0 s0 r/w siz1?iz0 as ds dsackx d15?0 read write indivisible cycle rmc out figure 3-9. read-modify-write cycle timing f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 3- 20 mc68340 user? manual motorola state 0?he mc68340 asserts rmc in s0 to identify a read-modify-write cycle. the mc68340 places a valid address on a31?0 and valid function codes on fc3?c0. the function codes select the address space for the operation. siz1/siz0 become valid in s0 to indicate the operand size. the mc68340 drives r/ w high for the read cycle. state 1?ne-half clock later during s1, the mc68340 asserts as indicating a valid address on the address bus. the mc68340 also asserts ds during s1. state 2?he selected device uses r/ w , siz1/siz0, a0, and ds to place information on the data bus. either or both of the bytes (d15?8 and d7?0) are selected by siz1/siz0 and a0. concurrently, the selected device may assert dsack ? . state 3?s long as at least one of the dsack ? signals is recognized by the end of s2 (meeting the asynchronous input setup time requirement), data is latched on the next falling edge of the clock, and the cycle terminates. if dsack ? is not recognized by the start of s3, the mc68340 inserts wait states instead of proceeding to s4 and s5. to ensure that wait states are inserted, both dsack1 and dsack0 must remain negated throughout the asynchronous input setup and hold times around the end of s2. if wait states are added, the mc68340 continues to sample the dsack ? signals on the falling edges of the clock until one is recognized. state 4?t the end of s4, the mc68340 latches the incoming data. state 5?he mc68340 negates as and ds during s5. if more than one read cycle is required to read in the operand(s), s0?5 are repeated for each read cycle. when finished reading, the mc68340 holds the address, r/ w , and fc3?c0 valid in preparation for the write portion of the cycle. the external device keeps its data and dsack ? signals asserted until it detects the negation of as or ds (whichever it detects first). the device must remove the data and negate dsack ? within approximately one clock period after sensing the negation of as or ds . dsack ? signals that remain asserted beyond this limit may be prematurely detected for the next portion of the operation. idle states?he mc68340 does not assert any new control signals during the idle states, but it may internally begin the modify portion of the cycle at this time. s0?5 are omitted if no write cycle is required. if a write cycle is required, r/ w remains in the read mode until s0 to prevent bus conflicts with the preceding read portion of the cycle; the data bus is not driven until s2. state 0?he mc68340 drives r/ w low for a write cycle. depending on the write operation to be performed, the address lines may change during s0. state 1?n s1, the mc68340 asserts as , indicating a valid address on the address bus. state 2?uring s2, the mc68340 places the data to be written onto d15?0. state 3?he mc68340 asserts ds during s3, indicating stable data on the data bus. as long as at least one of the dsack ? signals is recognized by the end of s2 (meeting the asynchronous input setup time requirement), the cycle terminates one clock later. if dsack ? is not recognized by the start of s3, the mc68340 inserts wait states instead of f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 3- 21 proceeding to s4 and s5. to ensure that wait states are inserted, both dsack1 and dsack0 must remain negated throughout the asynchronous input setup and hold times around the end of s2. if wait states are added, the mc68340 continues to sample dsack ? on the falling edges of the clock until one is recognized. the selected device uses r/ w , ds , siz1/siz0, and a0 to latch data from the appropriate section(s) of d15?8 and d7?0. siz1/siz0 and a0 select the data bus sections. if it has not already done so, the device asserts dsack ? when it has successfully stored the data. state 4?he mc68340 issues no new control signals during s4. state 5?he mc68340 negates as and ds during s5. it holds the address and data valid during s5 to provide address hold time for memory systems. r/ w and fc3?c0 also remain valid throughout s5. if more than one write cycle is required, states s0?5 are repeated for each write cycle. the external device keeps dsack ? asserted until it detects the negation of as or ds (whichever it detects first). the device must remove its data and negate dsack ? within approximately one clock period after sensing the negation of as or ds . 3.4 cpu space cycles fc3?c0 select user and supervisor program and data areas. the area selected by fc3 fc0 = $7 is classified as the cpu space. the breakpoint acknowledge, lpstop broadcast, module base address register access, and interrupt acknowledge cycles described in the following paragraphs use cpu space. the cpu space type, which is encoded on a19?16 during a cpu space operation, indicates the function that the mc68340 is performing. on the mc68340, four of the encodings are implemented as shown in figure 3-10. all unused values are reserved by motorola for additional cpu space types. 0000000000000000000 t0 bkpt# 19 16 cpu space cycles function code breakpoint acknowledge 0 0 00000 111111111111111110 19 16 0 address bus 1111 1 11111111111 1 level 19 16 0 cpu space type field 000000111111111100000000 19 16 0 111 0 low-power stop broadcast 111 0 interrupt acknowledge 11 1 0 11 1 0 module base address register access 0 0 3 3 3 3 0 0 0 0 0 0 0 0 0 0 31 31 111 1 1111 1 111 000 0 0000 0000 0000 31 31 figure 3-10. cpu space address encoding f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 3- 22 mc68340 user? manual motorola 3.4.1 breakpoint acknowledge cycle the breakpoint acknowledge cycle allows external hardware to insert an instruction directly into the instruction pipeline as the program executes. the breakpoint acknowledge cycle is generated by the execution of a breakpoint instruction (bkpt) or the assertion of the bkpt pin. the t-bit state (shown in figure 3-10) differentiates a software breakpoint cycle (t = 0) from a hardware breakpoint cycle (t = 1). when a bkpt instruction is executed (software breakpoint), the mc68340 performs a word read from cpu space, type 0, at an address corresponding to the breakpoint number (bits [2?] of the bkpt opcode) on a4?2, and the t-bit (a1) is cleared. if this bus cycle is terminated with berr (i.e., no instruction word is available), the mc68340 then performs illegal instruction exception processing. if the bus cycle is terminated by dsack ? , the mc68340 uses the data on d15?0 (for 16-bit ports) or two reads from d15?8 (for 8-bit ports) to replace the bkpt instruction in the internal instruction pipeline and then begins execution of that instruction. when the cpu32 acknowledges a bkpt pin assertion (hardware breakpoint) with background mode disabled, the cpu32 performs a word read from cpu space, type 0, at an address corresponding to all ones on a4?2 (bkpt#7), and the t-bit (a1) is set. if this bus cycle is terminated by berr , the mc68340 performs hardware breakpoint exception processing. if this bus cycle is terminated by dsack ? , the mc68340 ignores data on the data bus and continues execution of the next instruction. note the bkpt pin is sampled on the same clock phase as data and is latched with data as it enters the cpu32 pipeline. if bkpt is asserted for only one bus cycle and a pipeline flush occurs before bkpt is detected by the cpu32, bkpt is ignored. to ensure detection of bkpt by the cpu32, bkpt can be asserted until a breakpoint acknowledge cycle is recognized. the breakpoint operation flowchart is shown in figure 3-11. figures 3-12 and 3-13 show the timing diagrams for the breakpoint acknowledge cycle with instruction opcodes supplied on the cycle and with an exception signaled, respectively. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 3- 23 3.4.2 lpstop broadcast cycle the low power stop (lpstop) broadcast cycle is generated by the cpu32 executing the lpstop instruction. since the external bus interface must get a copy of the interrupt mask level from the cpu32, the cpu32 performs a cpu space type 3 write with the mask level encoded on the data bus, as shown in the following figure. the cpu space type 3 cycle waits for the bus to be available, and is shown externally to indicate to external devices that the mc68340 is going into lpstop mode. if an external device requires additional time to prepare for entry into lpstop mode, entry can be delayed by asserting halt . the sim40 provides internal dsack ? response to this cycle. for more information on how the sim40 responds to lpstop mode, see section 4 system integration module . 1514131211109876543210 i2 i1 i0 i2?0?nterrupt mask level the interrupt mask level is encoded on bits 2? of the data bus during an lpstop broadcast. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 3- 24 mc68340 user? manual motorola acknowledge breakpoint if breakpoint instruction executed: 1. set r/w to read 2. set function code to cpu space 3. place cpu space type 0 on a19?16 4. place breakpoint number on a2?4 5. clear t-bit (a1) 6. set size to word 7. assert as and ds if bkpt pin asserted: 1. set r/w to read 2. set function code to cpu space 3. place cpu space type 0 on a19?16 4. place all one's on a4?2 5. set t-bit (a-1) to one 6. set size to word 7. assert as and ds (a) (b) if breakpoint instruction executed: 1. place replacement opcode on data bus 2. assert dsackx -or- 1. assert berr to initiate exception processing if bkpt pin asserted: 1. assert dsackx -or- 1. assert berr to initiate exception processing 1. negate dsackx or berr breakpoint operation flow processor external device if breakpoint instruction executed and dsackx is asserted: 1. latch data 2. negate as and ds 3. go to (a) if bkpt pin asserted and dsackx is asserted: 1. negate as and ds 2. go to (a) if berr asserted: 1. negate as and ds 2. go to (b) if breakpoint instruction executed: 1. place latched data in instruction pipeline 2. continue processing if bkpt pin asserted: 1. continue processing if breakpoint instruction executed: 1. initiate illegal instruction processing if bkpt pin asserted: 1. initiate hardware breakpoint processing figure 3-11. breakpoint operation flowchart f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 3- 25 fc3?c0 siz0 d15?8 r/w dsackx berr halt as ds bkpt d7?0 siz1 cpu space fetched instruction execution breakpoint acknowledge instruction word fetch a15?5,a0 a19?16 clkout a31?20 a4?1 s0 s1 s2 s3 s4 s5 s0 s1 s2 s3 s4 s5 s0 s1 s2 s3 s4 s5 s0 breakpoint encoding (0000) breakpoint number/t-bit breakpoint occurs read figure 3-12. breakpoint acknowledge cycle timing (opcode returned) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 3- 26 mc68340 user? manual motorola exception stacking fc3?c0 siz0 d15?8 r/w dsackx berr halt as ds bkpt d7?0 siz1 cpu space a19?16 a15?5, a0 clkout a31?20 a4?1 s0 s1 s2 s3 s4 s5 breakpoint encoding (0000) breakpoint number/t-bit s0 s1 s2 s3 s4 s5 s0 s1 s2 s3 s4 s5 s0 breakpoint occurs read breakpoint acknowledge bus error asserted figure 3-13. breakpoint acknowledge cycle timing (exception signaled) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 3- 27 3.4.3 module base address register access all internal module registers, including the sim40, occupy a single 4-kbyte block that is relocatable along 4-kbyte boundaries. the location is fixed by writing the desired base address of the sim40 block to the module base address register using the moves instruction. the module base address register is only accessible in cpu space at address $0003ff00. the sfc or dfc register must indicate cpu space (fc3?c0 = $7), using the movec instruction, before accessing the module base address register. refer to section 4 system integration module for additional information on the module base address register. 3.4.4 interrupt acknowledge bus cycles the cpu32 makes an interrupt pending in three cases. the first case occurs when a peripheral device signals the cpu32 (with irq7?rq1 ) that the device requires service and the internally synchronized value on these signals indicates a higher priority than the interrupt mask in the status register. the second case occurs when a transition has occurred in the case of a level 7 interrupt. a recognized level 7 interrupt must be removed for one clock cycle before a second level 7 can be recognized. the third case occurs if, upon returning from servicing a level 7 interrupt, the request level stays at 7 and the processor mask level changes from 7 to a lower level, a second level 7 is recognized. the cpu32 takes an interrupt exception for a pending interrupt within one instruction boundary (after processing any other pending exception with a higher priority). the following paragraphs describe the types of interrupt acknowledge bus cycles that can be executed as part of interrupt exception processing. 3.4.4.1 interrupt acknowledge cycle?erminated normally. when the cpu32 processes an interrupt exception, it performs an interrupt acknowledge cycle to obtain the number of the vector that contains the starting location of the interrupt service routine. some interrupting devices have programmable vector registers that contain the interrupt vectors for the routines they use. the following paragraphs describe the interrupt acknowledge cycle for these devices. other interrupting conditions or devices that cannot supply a vector number will use the autovector cycle described in 3.4.4.2 autovector interrupt acknowledge cycle . f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 3- 28 mc68340 user? manual motorola the interrupt acknowledge cycle is a read cycle. it differs from the read cycle described in 3.3.1 read cycle in that it accesses the cpu address space. specifically, the differences are as follows: 1. fc3?c0 are set to $7 (fc3/fc2/fc1/fc0 = 0111) for cpu address space. 2. a3, a2, and a1 are set to the interrupt request level, and the iack ? strobe corresponding to the current interrupt level is asserted. (either the function codes and address signals or the iack ? strobes can be monitored to determine that an interrupt acknowledge cycle is in progress and the current interrupt level.) 3. the cpu32 space type field (a19?16) is set to $f (interrupt acknowledge). 4. other address signals (a31?20, a15?4, and a0) are set to one. 5. the siz0/siz1 and r/ w signals are driven to indicate a single-byte read cycle. the responding device places the vector number on the least significant byte of its data port (for an 8-bit port, the vector number must be on d15?8; for a 16-bit port, the vector must be on d7?0) during the interrupt acknowledge cycle. the cycle is then terminated normally with dsack ? . figure 3-14 is a flowchart of the interrupt acknowledge cycle; figure 3-15 shows the timing for an interrupt acknowledge cycle terminated with dsack ? . start next cycle release 1. negate dsackx mc68340 interrupting device request interrupt grant interrupt provide vector number acquire vector number 1. latch vector number 1. place vector number on least significant byte of data bus 2. assert dsackx (or avec if no vector number) 2. negate ds and as 1. synchronize irq7?rq1 2. compare irq1?rq7 to mask level and wait for instruction to complete 3. place interrupt level on a3?1; type field (a19?16) = $f 4. set r/w to read 5. set fc3?c0 to 0111 6. drive size pins to indicate a one-byte transfer 7. assert as and ds 8. assert the corresponding iackx strobe. figure 3-14. interrupt acknowledge cycle flowchart f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 3- 29 clkout a31?4 fc3?c0 s0 s2 s4 s2 s4 s0 siz0 dsackx d7?0 r/w as ds a3?1 a0 siz1 d15?8 s0 s1 s2 irq7?rq1 1 byte interrupt level read cycle internal arbitration iack cycle iack7?ack1 write stack vector from 16-bit port vector from 8-bit port cpu space 0? clocks* *internal arbitration may take between 0? clock cycles. figure 3-15. interrupt acknowledge cycle timing 3.4.4.2 autovector interrupt acknowledge cycle. when the interrupting device cannot supply a vector number, it requests an automatically generated vector (autovector). instead of placing a vector number on the data bus and asserting dsack ? , the device asserts avec to terminate the cycle. if the dsack ? signals are asserted during an interrupt acknowledge cycle terminated by avec , the dsack ? signals and f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 3- 30 mc68340 user? manual motorola data will be ignored if avec is asserted before or at the same time as the dsack ? signals. the vector number supplied in an autovector operation is derived from the interrupt level of the current interrupt. when avec is asserted instead of dsack ? during an interrupt acknowledge cycle, the mc68340 ignores the state of the data bus and internally generates the vector number (the sum of the interrupt level plus 24 ($18)). avec is multiplexed with cs0. the firq bit in the sim40 module configuration register controls whether the avec / cs0 pin is used as an autovector input or as cs0 (refer to section 4 system integration module for additional information). avec is only sampled during an interrupt acknowledge cycle. during all other cycles, avec is ignored. additionally, avec can be internally generated for external devices by programming the autovector register. seven distinct autovectors can be used, corresponding to the seven levels of interrupt available with signals irq7?rq1 . figure 3-16 shows the timing for an autovector operation. 3.4.4.3 spurious interrupt cycle. requested interrupts, whether internal or external, are arbitrated internally. when no internal module (including the sim40, which responds for external requests) responds during an interrupt acknowledge cycle by arbitrating for the interrupt acknowledge cycle internally, the spurious interrupt monitor generates an internal bus error signal to terminate the vector acquisition. the mc68340 automatically generates the spurious interrupt vector number (24) instead of the interrupt vector number in this case. when an external device does not respond to an interrupt acknowledge cycle with avec or dsack ? , a bus monitor must assert berr , which results in the cpu32 taking the spurious interrupt vector. if halt is also asserted, the mc68340 retries the interrupt acknowledge cycle instead of using the spurious interrupt vector. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 3- 31 read cycle internal arbitration iack cycle write stack s0 s2 s4 s2 s4 s0 s0 s1 s2 1 byte interrupt level clkout a31?4 fc3?c0 siz0 dsackx d15?0 r/w as ds a3?1 a0 siz1 avec irq7?rq1 iack7?ack1 cpu space 0? clocks* * internal arbitration may take between 0? clocks. figure 3-16. autovector operation timing f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 3- 32 mc68340 user? manual motorola 3.5 bus exception control cycles the bus architecture requires assertion of dsack ? from an external device to signal that a bus cycle is complete. neither dsack ? nor avec is asserted in the following cases: dsack ? / avec is programmed to respond internally. the external device does not respond. various other application-dependent errors occur. the mc68340 provides berr when no device responds by asserting dsack ? / avec within an appropriate period of time after the mc68340 asserts as . this mechanism allows the cycle to terminate and the mc68340 to enter exception processing for the error condition. halt is also used for bus exception control. this signal can be asserted by an external device for debugging purposes to cause single bus cycle operation, or, in combination with berr , a retry of a bus cycle in error. to properly control termination of a bus cycle for a retry or a bus error condition, dsack ? , berr , and halt can be asserted and negated with the rising edge of the mc68340 clock. this assures that when two signals are asserted simultaneously, the required setup and hold time for both is met for the same falling edge of the mc68340 clock. this or an equivalent precaution should be designed into the external circuitry to provide these signals. alternatively, the internal bus monitor could be used. the acceptable bus cycle terminations for asynchronous cycles are summarized in relation to dsack ? assertion as follows (case numbers refer to table 3-4): normal termination: dsack ? is asserted; berr and halt remain negated (case 1). halt termination: halt is asserted at the same time as or before dsackx , and berr remains negated (case 2). bus error termination: berr is asserted in lieu of, at the same time as, or before dsack ? (case 3) or after dsack ? (case 4), and halt remains negated; berr is negated at the same time as or after dsack ? . retry termination: halt and berr are asserted in lieu of, at the same time as, or before dsack ? (case 5) or after dsack ? (case 6); berr is negated at the same time as or after dsack ? , and halt may be negated at the same time as or after berr . table 3-4 lists various combinations of control signal sequences and the resulting bus cycle terminations. to ensure predictable operation, berr and halt should be negated according to the specifications given in section 11 electrical characteristics . dsack ? berr , and halt may be negated after as . if dsack ? or berr remain asserted into s2 of the next bus cycle, that cycle may be terminated prematurely. example a: a system uses a bus monitor timer to terminate accesses to an unpopulated address space. the timer asserts berr after timeout (case 3). f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 3- 33 example b: a system uses error detection and correction on ram contents. the designer may: 1. delay dsack ? until data is verified and assert berr and halt simultaneously to indicate to the mc68340 to automatically retry the error cycle (case 5), or if data is valid, assert dsack ? (case 1). 2. delay dsack ? until data is verified and assert berr with or without dsack ? if data is in error (case 3). this initiates exception processing for software handling of the condition. 3. return dsack ? prior to data verification; if data is invalid, berr is asserted on the next clock cycle (case 4). this initiates exception processing for software handling of the condition. 4. return dsack ? prior to data verification; if data is invalid, assert berr and halt on the next clock cycle (case 6). the memory controller can then correct the ram prior to or during the automatic retry. table 3-4. dsack ? , berr , and halt assertion results asserted on rising edge of state case num control signal n n + 2 result 1 dsack ? berr halt a na na s na x normal cycle terminate and continue. 2 dsack ? berr halt a na a/s s na s normal cycle terminate and halt; continue when halt negated. 3 dsack ? berr halt na/a a na x s x terminate and take bus error exception, possibly deferred. 4 dsack ? berr halt a na na x a na terminate and take bus error exception, possibly deferred. 5 dsack ? berr halt na/a a a/s x s s terminate and retry when halt negated. 6 dsack ? berr halt a na na x a a terminate and retry when halt negated. notes: n number of the current even bus state (e.g., s2, s4, etc.) a signal is asserted in this bus state na signal is not asserted in this state x don't care s signal was asserted in previous state and remains asserted in this state f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 3- 34 mc68340 user? manual motorola 3.5.1 bus errors berr can be used to abort the bus cycle and the instruction being executed. berr takes precedence over dsack ? provided it meets the timing constraints described in section 11 electrical characteristics . if berr does not meet these constraints, it may cause unpredictable operation of the mc68340. if berr remains asserted into the next bus cycle, it may cause incorrect operation of that cycle. when berr is issued to terminate a bus cycle, the mc68340 can enter exception processing immediately following the bus cycle, or it can defer processing the exception. the instruction prefetch mechanism requests instruction words from the bus controller before it is ready to execute them. if a bus error occurs on an instruction fetch, the mc68340 does not take the exception until it attempts to use that instruction word. should an intervening instruction cause a branch or should a task switch occur, the bus error exception does not occur. the bus error condition is recognized during a bus cycle in any of the following cases: dsack ? and halt are negated, and berr is asserted. halt and berr are negated, and dsack ? is asserted. berr is then asserted within one clock cycle ( halt remains negated). berr and halt are asserted simultaneously, indicating a retry. when the mc68340 recognizes a bus error condition, it terminates the current bus cycle in the normal way. figure 3-17 shows the timing of a bus error for the case in which dsack ? is not asserted. figure 3-18 shows the timing for a bus error that is asserted after dsack ? . exceptions are taken in both cases. refer to section 5 cpu32 for details of bus error exception processing. in the second case, in which berr is asserted after dsack ? is asserted, berr must be asserted within the time specified for purely asynchronous operation, or it must be asserted and remain stable during the sample window around the next falling edge of the clock after dsack ? is recognized. if berr is not stable at this time, the mc68340 may exhibit erratic behavior. berr has priority over dsack ? . in this case, data may be present on the bus, but it may not be valid. this sequence can be used by systems that have memory error detection and correction logic and by external cache memories. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 3- 35 clkout s0 s2 dsackx r/w as ds berr s0 s2 sw s4 sw s4 internal processing stack write read cycle with bus error fc3?c0 d15?0 a31?0 figure 3-17. bus error without dsack ? f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 3- 36 mc68340 user? manual motorola s0 s2 s4 s0 s2 s4 internal processing stack write write cycle clkout dsackx r/w as ds berr fc3?c0 d15?0 a31?0 figure 3-18. late bus error with dsack ? 3.5.2 retry operation when both berr and halt are asserted by an external device during a bus cycle, the mc68340 enters the retry sequence shown in figure 3-19. a delayed retry, which is similar to the delayed berr signal described previously, can also occur (see figure 3-20). the mc68340 terminates the bus cycle, places the control signals in their inactive state, and does not begin another bus cycle until the berr and halt signals are negated by external logic. after a synchronization delay, the mc68340 retries the previous cycle using the same access information (address, function code, size, etc.). berr should be negated before s2 of the retried cycle to ensure correct operation of the retried cycle. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 3- 37 s0 s2 s0 s2 sw s4 sw s4 read rerun halt read cycle with retry data ignored clkout dsackx r/w as ds berr a31?0 fc3?c0 d15?0 halt figure 3-19. retry sequence the mc68340 retries any read or write cycle of a read-modify-write operation separately; rmc remains asserted during the entire retry sequence. asserting br along with berr and halt provides a relinquish and retry operation. the mc68340 does not relinquish the bus during a read-modify-write operation. any device that requires the mc68340 to give up the bus and retry a bus cycle during a read-modify-write cycle must assert only berr and br ( halt must not be included). the bus error handler software should examine the read-modify-write bit in the special status word (see section 5 cpu32 ) and take the appropriate action to resolve this type of fault when it occurs. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 3- 38 mc68340 user? manual motorola s0 s2 s4 s0 s2 s4 halt write rerun write cycle clkout dsackx r/w as ds berr a31?0 fc3?c0 d15?10 halt figure 3-20. late retry sequence 3.5.3 halt operation when halt is asserted and berr is not asserted, the mc68340 halts external bus activity at the next bus cycle boundary (see figure 3-21). halt by itself does not terminate a bus cycle. negating and reasserting halt in accordance with the correct timing requirements provides a single-step (bus cycle to bus cycle) operation. since halt affects external bus cycles only, a program that does not require use of the external bus may continue executing. the single-cycle mode allows the user to proceed through (and debug) external mc68340 operations, one bus cycle at a time. since the occurrence of a bus error while halt is asserted causes a retry operation, the user must anticipate retry cycles while debugging in the single-cycle mode. the single-step operation and the software trace capability allow the system debugger to trace single bus cycles, single instructions, or changes in program flow. when the mc68340 completes a bus cycle with halt asserted, d15?0 is placed in the high-impedance state, and bus control signals are negated (not high-impedance state); the a31?0, fcx, sizx, and r/ w signals remain in the same state. the halt operation has no effect on bus arbitration (see 3.6 bus arbitration ). when bus arbitration occurs while the mc68340 is halted, the address and control signals are also placed in the high- impedance state. once bus mastership is returned to the mc68340, if halt is still f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 3- 39 asserted, the a31?0, fcx, sizx, and r/ w signals are again driven to their previous states. the mc68340 does not service interrupt requests while it is halted. clkout s0 s2 s4 r/w as ds halt s0 s2 s4 br bg bgack s0 read halt (arbitration permitted while the processor is halted) read dsackx a31?0 fc3?c0 d15?10 figure 3-21. halt timing 3.5.4 double bus fault a double bus fault results when a bus error or an address error occurs during the exception processing sequence for any of the following: a previous bus error a previous address error a reset for example, the mc68340 attempts to stack several words containing information about the state of the machine while processing a bus error exception. if a bus error exception f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 3- 40 mc68340 user? manual motorola occurs during the stacking operation, the second error is considered a double bus fault. when a double bus fault occurs, the mc68340 halts and asserts halt. only a reset operation can restart a halted mc68340. however, bus arbitration can still occur (see 3.6 bus arbitration ). a second bus error or address error that occurs after exception processing has completed (during the execution of the exception handler routine or later) does not cause a double bus fault. a bus cycle that is retried does not constitute a bus error or contribute to a double bus fault. the mc68340 continues to retry the same bus cycle as long as the external hardware requests it. reset can also be generated internally by the halt monitor (see section 5 cpu32 ). 3.6 bus arbitration the bus design of the mc68340 provides for a single bus master at any one time, either the mc68340 or an external device. one or more of the external devices on the bus can have the capability of becoming bus master for the external bus, but not the mc68340 internal bus. bus arbitration is the protocol by which an external device becomes bus master; the bus controller in the mc68340 manages the bus arbitration signals so that the mc68340 has the lowest priority. external devices that need to obtain the bus must assert the bus arbitration signals in the sequences described in the following paragraphs. systems having several devices that can become bus master require external circuitry to assign priorities to the devices so that, when two or more external devices attempt to become bus master at the same time, the one having the highest priority becomes bus master first. the sequence of the protocol is as follows: 1. an external device asserts br . 2. the mc68340 asserts bg to indicate that the bus is available. 3. the external device asserts bgack to indicate that it has assumed bus mastership. note the mc68340 does not place cs3?s0 in a high-impedance state after reset or when the bus is granted to an external master. br may be issued any time during a bus cycle or between cycles. bg is asserted in response to br . to guarantee operand coherency, bg is only asserted at the end of an operand transfer. additionally, bg is not asserted until the end of a read-modify-write operation (when rmc is negated) in response to a br signal. when the requesting device receives bg and more than one external device can be bus master, the requesting device should begin whatever arbitration is required. when the external device assumes bus mastership, it asserts bgack and maintains bgack during the entire bus cycle (or cycles) for which it is bus master. the following conditions must be met for an external device to assume mastership of the bus through the normal bus arbitration procedure: 1) it must have received bg through the arbitration process, and 2) bgack must be inactive, indicating that no other bus master has claimed ownership of the bus. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 3- 41 figure 3-22 is a flowchart showing bus arbitration for a single device. this technique allows processing of bus requests during data transfer cycles. refer to figures 3-23 and 3-24 for bus arbitration timing diagrams. br is negated at the time that bgack is asserted. this type of operation applies to a system consisting of the mc68340 and one device capable of bus mastership. in a system having a number of devices capable of bus mastership, br from each device can be wire- ored to the mc68340. in such a system, more than one bus request could be asserted simultaneously. bg is negated a few clock cycles after the transition of bgack . however, if bus requests are still pending after the negation of bg , the mc68340 asserts another bg within a few clock cycles after it was negated. this additional assertion of bg allows external arbitration circuitry to select the next bus master before the current bus master has finished using the bus. the following paragraphs provide additional information about the three steps in the arbitration process. bus arbitration requests are recognized during normal processing, halt assertion, and a cpu32 halt caused by a double bus fault. grant bus arbitration 1. assert bg terminate arbitration 1. negate bg (and wait for bgack to be negated) re-arbitrate or resume processor operation processor requesting device request the bus 1. assert br acknowledge bus mastership 1. external arbitration determines next bus master 2. next bus master waits for bgack to be negated 3. next bus master asserts bgack to become new master 4. bus master negates br operate as bus master release bus mastership 1. negate bgack 1. perform data transfers (read and write cycles) according to the same rules the processor uses figure 3-22. bus arbitration flowchart for single request f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 3- 42 mc68340 user? manual motorola clkout as d15?0 a31?0 br bg bgack figure 3-23. bus arbitration timing diagram?dle bus case clkout a31?0 r/w as ds d15?0 dsack0, dsack1 br bg bgack s0 s1 s2 s3 s4 s5 figure 3-24. bus arbitration timing diagram?ctive bus case f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 3- 43 3.6.1 bus request external devices capable of becoming bus masters request the bus by asserting br . this signal can be wire-ored to indicate to the mc68340 that some external device requires control of the bus. the mc68340 is effectively at a lower bus priority level than the external device and relinquishes the bus after it has completed the current bus cycle (if one has started). if no bgack is received while the br is active, the mc68340 remains bus master once br is negated. this prevents unnecessary interference with ordinary processing if the arbitration circuitry inadvertently responds to noise or if an external device determines that it no longer requires use of the bus before it has been granted mastership. 3.6.2 bus grant the mc68340 supports operand coherency; thus, if an operand transfer requires multiple bus cycles, the mc68340 does not release the bus until the entire transfer is complete. therefore, assertion of bg is subject to the following constraints: the minimum time for bg assertion after br is asserted depends on internal synchronization (see section 11 electrical characteristics ). during an external operand transfer, the mc68340 does not assert bg until after the last cycle of the transfer (determined by sizx and dsack ? ). during an external operand transfer, the mc68340 does not assert bg as long as rmc is asserted. if the show cycle bits shen1?hen0 = 01, the mc68340 does not assert bg to an external master. externally, the bg signal can be routed through a daisy-chained network or a priority- encoded network. the mc68340 is not affected by the method of arbitration as long as the protocol is obeyed. 3.6.3 bus grant acknowledge an external device cannot request and be granted the external bus while another device is the active bus master. a device that asserts bgack remains the bus master until it negates bgack . bgack should not be negated until all required bus cycles are completed. bus mastership is terminated at the negation of bgack . once an external device receives the bus and asserts bgack , it should negate br . if br remains asserted after bgack is asserted, the mc68340 assumes that another device is requesting the bus and prepares to issue another bg . f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 3- 44 mc68340 user? manual motorola 3.6.4 bus arbitration control the bus arbitration control unit in the mc68340 is implemented with a finite state machine. as discussed previously, all asynchronous inputs to the mc68340 are internally synchronized in a maximum of two cycles of the clock. as shown in figure 3-25 input signals labeled r and a are internally synchronized versions of br and bgack respectively. the bg output is labeled g, and the internal high-impedance control signal is labeled t. if t is true, the address, data, and control buses are placed in the high- impedance state after the next rising edge following the negation of as and rmc . all signals are shown in positive logic (active high) regardless of their true active voltage level. the state machine shown in figure 3-25 does not have a state 1 or state 4. state changes occur on the next rising edge of the clock after the internal signal is valid. the bg signal transitions on the falling edge of the clock after a state is reached during which g changes. the bus control signals (controlled by t) are driven by the mc68340 immediately following a state change, when bus mastership is returned to the mc68340. state 0, in which g and t are both negated, is the state of the bus arbiter while the mc68340 is bus master. r and a keep the arbiter in state 0 as long as they are both negated. the mc68340 does not allow arbitration of the external bus during the rmc sequence. for the duration of this sequence, the mc68340 ignores the br input. if mastership of the bus is required during an rmc operation, berr must be used to abort the rmc sequence. 3.6.5 show cycles the mc68340 can perform data transfers with its internal modules without using the external bus, but, when debugging, it is desirable to have address and data information appear on the external bus. these external bus cycles, called show cycles, are distinguished by the fact that as is not asserted externally. ds is used to signal address strobe timing in show cycles. after reset, show cycles are disabled and must be enabled by writing to the shen bits in the module configuration register (see 4.3.2.1 module configuration register (mcr) ). when show cycles are disabled, the a31?0, fcx, sizx, and r/ w signals continue to reflect internal bus activity. however, as and ds are not asserted externally, and the external data bus remains in a high-impedance state. when show cycles are enabled, ds indicates address strobe timing and the external data bus contains data. the following paragraphs are a state-by-state description of show cycles, and figure 3-26 illustrates a show cycle timing diagram. refer to section 11 electrical characteristics for specific timing information. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 3- 45 r state 5 gtv state 3 v g t state 2 v g t state 0 v g t state 6 gtv ra b ra ab r a b + r a r ra + ra ra a + r - bus request a - bus grant acknowledge b - bus cycle in progress g - bus grant t - three-state signal to bus control v - bus available to bus control r a r a r a figure 3-25. bus arbitration state diagram f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 3- 46 mc68340 user? manual motorola state 0?uring state 0, the a31?0 and fcx become valid, r/ w is driven to indicate a show read or write cycle, and the sizx pins indicate the number of bytes to transfer. during a read, the addressed peripheral is driving the data bus, and the user must take care to avoid bus conflicts. state 41?ne-half clock cycle later, ds (rather than as ) is asserted to indicate that address information is valid. state 42?o action occurs in state 42. the bus controller remains in state 42 (wait states will be inserted) until the internal read cycle is complete. state 43?hen ds is negated, show data is valid on the next falling edge of the system clock. the external data bus drivers are enabled so that data becomes valid on the external bus as soon as it is available on the internal bus. state 0?he a31?0, fcx, r/ w , and sizx pins change to begin the next cycle. data from the preceding cycle is valid through state 0. a31?0, fc2?c0, siz1?iz0 clkout s0 s42 s1 s41 s43 s2 s0 r/w as, cs ds d15?0 bkpt show cycle start of external cycle figure 3-26. show cycle timing diagram 3.7 reset operation the mc68340 has reset control logic to determine the cause of reset, synchronize it if necessary, and assert the appropriate reset lines. the reset control logic can independently drive three different lines: 1. extrst (external reset) drives the external reset pin. 2. clkrst (clock reset) resets the clock module. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 3- 47 3. intrst (internal reset) goes to all other internal circuits. synchronous reset sources are not asserted until the end of the current bus cycle, whether or not rmc is asserted. the internal bus monitor is automatically enabled for synchronous resets; therefore, if the current bus cycle does not terminate normally, the bus monitor terminates it. only single-byte or word transfers are guaranteed valid for synchronous resets. an external or clock reset is a synchronous reset source. asynchronous reset sources indicate a catastrophic failure, and the reset controller logic immediately resets the system. resetting the mc68340 causes any bus cycle in progress to terminate as if dsack ? or berr had been asserted. in addition, the mc68340 appropriately initializes registers for a reset exception. asynchronous reset sources include power-up, software watchdog, double bus fault resets, and execution of the reset instruction. if an external device drives reset low, reset should be asserted for at least 590 clock periods to ensure that the mc68340 resets. the reset control logic holds reset asserted internally until the external reset is released. when the reset control logic detects that external reset is no longer being driven, it drives both internal and external reset low for an additional 512 cycles to guarantee this length of reset to the entire system. figure 3-27 shows the reset timing. reset 1 clock 590 clock 512 clock pulled external driven by mc68340 figure 3-27. timing for external devices driving reset if reset is asserted from any other source, the reset control logic asserts reset for 328 input clock periods plus 512 output clock periods, and until the source of reset is negated. after any internal reset occurs, a 14-cycle rise time is allowed before testing for the presence of an external reset. if no external reset is detected, the cpu32 begins its vector fetch. figure 3-28 is a timing diagram of the power-up reset operation, showing the relationships between reset , v cc , and bus signals. during the reset period, the entire bus three- states except for non-three-statable signals, which are driven to their inactive state. once reset negates, all control signals are driven to their inactive state, the data bus is in read mode, and the address bus is driven. after this, the first bus cycle for reset exception processing begins. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 3- 48 mc68340 user? manual motorola clkout vco lock bus cycles reset v cc 1 23 4 bus state unknown address and control signals three-stated 512 tclkout 14 clocks notes: 1. internal start-up time. 2. ssp read here. 3. pc read here. 4. first instruction fetched here. 328 tclkin figure 3-28. power-up reset timing diagram when a reset instruction is executed, the mc68340 drives the reset signal for 512 clock cycles. the sim40 registers and the module control registers in each internal peripheral module (dma, timers, and serial modules) are not affected. all other peripheral module registers are reset the same as for a hardware reset. the external devices connected to the reset signal are reset at the completion of the reset instruction. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 4- 1 section 4 system integration module the mc68340 system integration module (sim40) consists of several functions that control the system start-up, initialization, configuration, and the external bus with a minimum of external devices. it also provides the ieee 1149.1 boundary scan capabilities. the sim40 includes the following functions: system configuration and protection clock synthesizer chip selects and wait states external bus interface bus arbitration dynamic bus sizing ieee 1149.1 test access port 4.1 module overview the sim40 is essentially identical to the sim implemented in the mc68330. the sim40 has similar features to the sim in the mc68331, mc68332, and mc68333. the periodic interrupt timer, double bus fault monitor, software watchdog, internal bus monitor, and spurious interrupt monitor are identical. however, many of the other features in the sim's differ in their use and details. the system configuration and protection function controls system configuration and provides various monitors and timers, including the internal bus monitor, double bus fault monitor, spurious interrupt monitor, software watchdog timer, and the periodic interrupt timer. the clock synthesizer generates the clock signals used by the sim40 and the other on- chip modules, as well as clkout used by external devices. the programmable chip select function provides four chip select signals that can enable external memory and peripheral circuits, providing all handshaking and timing signals. each chip select signal has an associated base address register and an address mask register that contain the programmable characteristics of that chip select. up to three wait states can be programmed by setting bits in the address mask register. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 4- 2 mc68340 user? manual motorola the external bus interface (ebi) handles the transfer of information between the internal cpu32 and memory, peripherals, or other processing elements in the external address space. see section 3 bus operation for further information. the mc68340 dynamically interprets the port size of an addressed device during each bus cycle, allowing operand transfers to or from 8-, 16-, and 32-bit ports. the device signals its port size and indicates completion of the bus cycle through the use of the dsack ? inputs. dynamic bus sizing allows a programmer to write code that is not bus- width specific. for a discussion on dynamic bus sizing, see section 3 bus operation. the mc68340 includes dedicated user-accessible test logic that is fully compliant with the ieee 1149.1 standard test access port and boundary scan architecture . problems associated with testing high-density circuit boards have led to the development of this standard under the sponsorship of the ieee test technology committee and joint test action group (jtag). the mc68340 implementation supports circuit-board test strategies based on this standard. refer to section 9 ieee 1149.1 test access port for additional information. 4.2 module operation the following paragraphs describe the operation of the module base address register, system configuration and protection, clock synthesizer, chip select functions, and the external bus interface. note the terms assert and negate are used throughout this section to avoid confusion when dealing with a mixture of active-low and active-high signals. the term assert or assertion indicates that a signal is active or true independent of the level represented by a high or low voltage. the term negate or negation indicates that a signal is inactive or false. 4.2.1 module base address register operation the module base address register (mbar) controls the location of all internal module registers (see 4.3.1 module base address register (mbar) ). the address stored in this register is the base address (starting location) for all internal registers. all internal module registers are contained in a single 4-kbyte block (see figure 4-1) that is relocatable along 4-kbyte boundaries. the location of the internal registers is fixed by writing the desired base address of the 4-kbyte block to the mbar using the moves instruction to address $0003ff00 in cpu space. the source function code (sfc) and destination function code (dfc) registers contain the address space values (fc3?c0) for the read or write operand of the moves instruction (see section 5 cpu32 or m68000pm/ad, programmer? reference manual ). therefore, the sfc or dfc register must indicate cpu space (fc3?c0 = $7), using the movec instruction, before accessing mbar. the offset from the base address is shown above each register diagram. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 4- 3 . mc68340 relocatable module block ram (typical) $00000000 $xxxxxfff mbar ($0003ff00 fc=0111) $xxxxx000 $fff $07f $000 $ffffffff note: $xxxxx is the value contained in the mbar bits ba31-ba12. dma serial ports timer modules sim 40 $7bf $780 $721 $67f $600 $700 figure 4-1. sim40 module register block 4.2.2 system configuration and protection operation the sim40 allows the user to control certain features of system configuration by writing bits in the module configuration register (mcr). this register also contains read-only status bits that show the state of the sim40. all m68000 family members are designed to provide maximum system safeguards. as an extension of the family, the mc68340 promotes the same basic concepts of safeguarded design present in all m68000 members. in addition, many functions that normally must be provided by external circuits are incorporated in this device. the following features are provided in the system configuration and protection function: sim40 module configuration the sim40 allows the user to configure the system to the particular requirements. the functions include control of freeze and show cycle operation, the function of the cs ? signals, the access privilege of the supervisor/user registers, the level of interrupt arbitration, and automatic vectoring for external interrupts. reset status the reset status register provides the user with information on the cause of the most recent reset. the possible causes of reset include: external, power-up, software watchdog, double bus fault, loss of clock, and reset instruction. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 4- 4 mc68340 user? manual motorola internal bus monitor the sim40 provides an internal bus monitor to monitor the dsack ? response time for all internal bus accesses. an option allows the monitoring of external bus accesses. for external bus accesses, four selectable response times are provided to allow for variations in response speed of memory and peripherals used in the system. a bus error signal is asserted internally if the dsack ? response limit is exceeded. berr is not asserted externally. this monitor can be disabled for external bus cycles only. double bus fault monitor the double bus fault monitor causes a reset to occur if the internal halt is asserted by the cpu32, indicating a double bus fault. a double bus fault results when a bus or address error occurs during the exception processing sequence for a previous bus or address error, a reset, or while the cpu32 is loading information from a bus error stack frame during an rte instruction. this function can be disabled. see section 3 bus operation for more information. spurious interrupt monitor if no interrupt arbitration occurs during an interrupt acknowledge (iack) cycle, the bus error signal is asserted internally. this function cannot be disabled. software watchdog the software watchdog asserts reset or a level 7 interrupt (as selected by the system protection and control register) if the software fails to service the software watchdog for a designated period of time (i.e., because it is trapped in a loop or lost). there are eight selectable timeout periods. this function can be disabled. periodic interrupt timer the sim40 provides a timer to generate periodic interrupts. the periodic interrupt time period can vary from 122 m s to 15.94 s (with a 32.768-khz crystal used to generate the system clock). this function can be disabled. figure 4-2 shows a block diagram of the system configuration and protection function. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 4- 5 software reset request or irq7 halt reset berr software watchdog periodic interrupt timer irq7-irq1 clock reset status 2 prescaler 9 module configuration request bus monitor spurious interrupt monitor double bus fault monitor figure 4-2. system configuration and protection function 4.2.2.1 system configuration. aspects of the system configuration are controlled by the mcr and the autovector register (avr). the configuration of port b is controlled by the combination of the firq bit in the mcr and the port b pin assignment register (pparb). port b pins can function as dedicated i/o lines, chip selects, interrupts, or autovector input. for debug purposes, internal bus accesses can be shown on the external bus. this function is called show cycles. the shen1, shen0 bits in the mcr control show cycles. bus arbitration can be either enabled or disabled during show cycles. arbitration for servicing interrupts is controlled by the value programmed into the interrupt arbitration (iarb) field of the mcr. each module that generates interrupts, including the sim40, has an iarb field. the value of the iarb field allows arbitration during an iack cycle among modules that simultaneously generate the same interrupt level. no two modules should share the same iarb value. the iarb must contain a value other than $0 for all modules that can generate interrupts; interrupts with iarb = 0 are discarded as extraneous. the sim40 arbitrates for both its own interrupts and externally generated interrupts. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 4- 6 mc68340 user? manual motorola there are eight arbitration levels for access to the intermodule bus (imb). the sim40 is fixed at the highest level (above the programmable level 7), and the cpu32 is fixed at the lowest level (below level 0). the direct memory access (dma) module is the only other module that can become bus master and arbitrate for the bus. it must be initialized with a level other than 0 or 7. the avr contains bits that correspond to external interrupt levels that require an autovector response. the sim40 supports up to seven discrete external interrupt requests. if the bit corresponding to an interrupt level is set in the avr, the sim40 returns an autovector in response to the iack cycle servicing that external interrupt request. otherwise, external circuitry must either return an interrupt vector or assert the external avec signal. 4.2.2.2 internal bus monitor. the internal bus monitor continually checks for the bus cycle termination response time by checking the dsack ? , berr , and halt status or the avec status during an iack cycle. the monitor initiates a bus error if the response time is excessive. the bus monitor feature cannot be disabled for internal accesses to an internal module. the internal bus monitor cannot check the dsack ? response on the external bus unless the mc68340 is the bus master. the bme bit in the system protection control register (sypcr) enables the internal bus monitor for internal-to-external bus cycles. if the system contains external bus masters whose bus cycles must be monitored, an external bus monitor must be implemented. in this case, the internal-to-external bus monitor option must be disabled. the bus cycle termination response time is measured in clock cycles, and the maximum- allowable response time is programmable. the bus monitor response time period ranges from 8 to 64 system clocks (see table 4-8). these options are provided to allow for different response times of peripherals that might be used in the system. 4.2.2.3 double bus fault monitor. a double bus fault is caused by a bus error or address error during the exception processing sequence. the double bus fault monitor responds to an assertion of halt on the internal bus. refer to section 3 bus operation for more information. the dbf bit in the reset status register (rsr) indicates that the last reset was caused by the double bus fault monitor. the double bus fault monitor reset can be enabled by the dbfe bit in the sypcr. 4.2.2.4 spurious interrupt monitor. the spurious interrupt monitor issues berr if no interrupt arbitration occurs during an iack cycle. normally, during an iack cycle, one or more internal modules recognize that the cpu32 is responding to interrupt request(s) and arbitrate for the privilege of returning a vector or asserting avec . (the sim40 reports and arbitrates for externally generated interrupts.) this feature cannot be disabled. 4.2.2.5 software watchdog. the sim40 provides a software watchdog option to prevent system lock-up in case the software becomes trapped in loops with no controlled exit. once enabled by the swe bit in the sypcr, the software watchdog requires a special service sequence to be executed on a periodic basis. if this periodic servicing action does not occur, the software watchdog times out and issues a reset or a level 7 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 4- 7 interrupt (as programmed by the swri bit in the sypcr). the address of the interrupt service routine for the software watchdog interrupt is stored in the software interrupt vector register (swiv). figure 4-3 shows a block diagram of the software watchdog as well as the clock control circuits for the periodic interrupt timer. the watchdog clock rate is determined by the swp bit in the periodic interrupt timer register (pitr) and the swt bits in the sypcr. see table 4-7 for a list of watchdog timeout periods. the software watchdog service sequence consists of the following steps: 1) write $55 to the software service register (swsr) and 2) write $aa to the swsr. both writes must occur in the order listed prior to the watchdog timeout, but any number of instructions or accesses to the swsr can be executed between the two writes. clock disable prescaler (2 ) clock mux extal 15 stage divider chain (2 ) lpstop swp ptp freeze swclk pitclk preclk 9 15 . . 22 22 9 11 13 15 reset 4 modulus counter pit interrupt pitr figure 4-3. software watchdog block diagram 4.2.2.6 periodic interrupt timer. the periodic interrupt timer consists of an 8-bit modulus counter that is loaded with the value contained in the pitr (see figure 4-3). the modulus counter is clocked by a signal derived from the extal input pin unless an external frequency source is used. when an external frequency source is used (modck low during reset), the default state of the prescaler control bits (swp and ptp) in the pitr is changed to enable both prescalers. either clock source (extal or extal ? 512) is divided by 4 before driving the modulus counter (pitclk). when the modulus counter value reaches zero, an interrupt is generated. the level of the generated interrupt is programmed into the pirql bits in the periodic interrupt control register (picr). during the iack cycle, the sim40 places the periodic interrupt vector, programmed into the piv bits in the picr, onto the internal bus. the value of bits 7? in the pitr is then loaded again into the modulus counter, and the counting process starts over. if a new value is written to the pitr, this value is loaded into the modulus counter when the current count is completed. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 4- 8 mc68340 user? manual motorola 4.2.2.6.1 periodic timer period calculation. the period of the periodic timer can be calculated using the following equation: pitr count value periodic interrupt timer period = extal frequency/prescaler value 2 2 solving the equation using a crystal frequency of 32.768-khz with the prescaler disabled gives: pitr count value periodic interrupt timer period = 32768/1 2 2 periodic interrupt timer period = pitr count value 8192 this gives a range from 122 m s, with a pitr value of $01 (00000001 binary), to 31.128 ms, with a pitr value of $ff (11111111 binary). solving the equation with the prescaler enabled (ptp=1 in the pitr) gives the following values: pitr count value periodic interrupt timer period = 32768/512 2 2 periodic interrupt timer period = pitr count value 16 this gives a range from 62.5 ms, with a pitr value of $01, to 15.94 s, with a pitr value of $ff. for fast calculation of periodic timer period using a 32.768-khz crystal, the following equations can be used: with prescaler disabled: programmable interrupt timer period = pitr (122 m s) with prescaler enabled: programmable interrupt timer period = pitr (62.5 ms) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 4- 9 4.2.2.6.2 using the periodic timer as a real-time clock. the periodic interrupt timer can be used as a real-time clock interrupt by setting it up to generate an interrupt with a one-second period. rearranging the periodic timer period equation to solve for the desired count value: pitr count value = (pit period) (extal frequency) (prescaler value) (2 2 ) pitr count value = (1) (32768) (512) (2 2 ) pitr count value = 16 (decimal) therefore, when using a 32.768-khz crystal, the pitr should be loaded with a value of $10 with the prescaler enabled to generate interrupts at a one-second rate. 4.2.2.7 simultaneous interrupts by sources in the sim40. if multiple interrupt sources at the same interrupt level are simultaneously asserted in the sim40, it will prioritize and service the interrupts in the following order: 1) software watchdog, 2) periodic interrupt timer, and 3) external interrupts. 4.2.3 clock synthesizer operation the clock synthesizer can operate with either an external crystal or an external oscillator for reference, using the internal phase-locked loop (pll) and voltage-controlled oscillator (vco), or an external clock can directly drive the clock signal at the operating frequency. the four modes of clock operation are listed in table 4-1. table 4-1. clock operating modes mode description modck reset value v ccsyn operating value crystal mode external crystal or oscillator used with the on-chip pll and vco to generate a system clock and clkout of programmable rates. 5 v 5 v external clock mode without pll the desired operating frequency is driven into extal resulting in a system clock and clkout of the same frequency, not tightly coupled. 0 v 0 v external clock mode with pll the desired operating frequency is driven into extal, resulting in a system clock and clkout of the same frequency, with a tight skew between input and output signals. 0 v 5 v limp mode upon input signal loss for either clock mode using the pll, operation continues at approximately one-half operating speed (affected by the value of the x-bit in the syncr). x 5 v in crystal mode (see figure 4-4), the clock synthesizer can operate from the on-chip pll and vco, using a parallel resonant crystal connected between the extal and xtal pins, or an external oscillator connected to extal as a reference frequency source. the oscillator circuit is shown in figure 4-5. a 32.768-khz watch crystal provides an inexpensive reference, but the reference crystal or external oscillator frequency can be any frequency in the range specified in section 11 electrical characteristics . when f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 4- 10 mc68340 user? manual motorola using crystal mode, the system clock frequency is programmable (using the w, x, and y bits in the syncr) over the range specified in section 11 electrical characteristics (see table 4-2.). extal phase c omparato r low-pass filter vco crystal o scillato r xtal xfc pin v ddsyn xfc v ddsyn 0.1 m f 0.01 m f 0.1 m f note 1: must be low-leakage capacitor. 20 pf 20 pf 20 m 330 k 1 ? 4 modulus divider y w feedback divider 0 1 sel mux 0 $3f ? 64 8 6 sel 0 1 mux 2 0 x clkout figure 4-4. clock block diagram for crystal operation . xtal e xtal 60 k w 60 k w figure 4-5. mc68340 crystal oscillator a separate power pin (v ccsyn ) is used to allow the clock circuits to run with the rest of the device powered down and to provide increased noise immunity for the clock circuits. the source for v ccsyn should be a quiet power supply with adequate external bypass capacitors placed as close as possible to the v ccsyn pin to ensure a stable operating frequency. figure 4-4 shows typical values for the bypass and pll external capacitors. the crystal manufacturer's documentation should be consulted for specific recommendations for external components. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 4- 11 to use an external clock source (see figure 4-6), the operating clock frequency can be driven directly into the extal pin (the xtal pin must be left floating for this case). this approach results in a system clock and clkout that are the same as the input signal frequency, but not tightly coupled to it. to enable this mode, modck must be held low during reset, and v ccsyn held at 0 v while the chip is in operation. clkout phase comparator low-pass filter vco crystal oscillator system clock clock control xfc pin v ccsyn xfc v ccsyn .01 ? 0.1 ? notes: 1. must be low-leakage capacitor. 2. external mode uses this path only. feedback divider extal xtal 1 external clock 2 figure 4-6. clock block diagram for external oscillator operation alternatively, an external clock signal can be directly driven into extal (with xtal left floating) using the on-chip pll. this configuration results in an internal clock and clkout signal of the same frequency as the input signal, with a tight skew between the external clock and the internal clock and clkout signals. to enable this mode, modck must be held low during reset, and v ccsyn should be connected to a quiet 5-v source. if an input signal loss for either of the clock modes utilizing the pll occurs, chip operation can continue in limp mode with the vco running at approximately one-half the operating speed (affected by the value of the x-bit in the syncr), using an internal voltage reference. the slimp bit in the syncr indicates that a loss of input signal reference has been detected. the rsten bit in the syncr controls whether an input signal loss causes a system reset or causes the device to operate in limp mode. the slock bit in the syncr indicates when the vco has locked onto the desired frequency or if an external clock is being used. 4.2.3.1 phase comparator and filter. the phase comparator takes the output of the frequency divider and compares it to an external input signal reference. the result of f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 4- 12 mc68340 user? manual motorola this compare is low-pass filtered and used to control the vco. the comparator also detects when the external crystal or oscillator stops running to initiate the limp mode for the system clock. the pll requires an external low-leakage filter capacitor, typically in the range from 0.01 to 0.1 m f, connected between the xfc and v ccsyn pins. the xfc capacitor should provide 50-m w insulation but should not be electrolytic. smaller values of the external filter capacitor provide a faster response time for the pll, and larger values provide greater frequency stability. for external clock mode without pll, the xfc pin can be left open. 4.2.3.2 frequency divider. the frequency divider circuits divide the vco frequency down to the reference frequency for the phase comparator. the frequency divider consists of 1) a 2-bit prescaler controlled by the w-bit in the syncr and 2) a 6-bit modulo downcounter controlled by the y-bits in the syncr. several factors are important to the design of the system clock. the resulting system clock frequency must be within the limits specified for the device. the frequency of the system clock is given by the following equation: f system = f crystal [2 (2+2w+x) ] (y+1) the maximum vco frequency limit must also be observed. the vco frequency is given by the following equation: f vco = f system [2 (2?) ] since clearing the x-bit causes the vco to run at twice the system frequency, the vco upper frequency limit must be considered when programming the syncr. both the system clock and vco frequency limits are given in section 11 electrical characteristics . table 4-2 lists some frequencies available from various combinations of syncr bits with a reference frequency of 32.768-khz. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 4- 13 table 4-2. system frequencies from 32.768-khz reference y w = 0; x = 0 w = 0; x = 1 w = 1; x = 0 w = 1; x = 1 000000 131 262 524 1049 000101 786 1573 3146 6291 001010 1442 2884 5767 11534 001111 2097 4194 8389 16777 010100 2753 5505 11010 22020 011001 3408 6816 13631 011111 4194 8389 16777 100011 4719 9437 18874 101000 5374 10748 21496 101101 6029 12059 24117 110010 6685 13369 110111 7340 14680 111100 7995 15991 111111 8389 16777 note: system frequencies are in khz. 4.2.3.3 clock control. the clock control circuits determine the source used for both internal and external clocks during special circumstances, such as low-power stop (lpstop) execution. table 4-3 summarizes the clock activity during lpstop in crystal mode operation. any clock in the off state is held low. the stext and stsim bits in the syncr control clock activity during lpstop. refer to 4.2.6 low-power stop for additional information. table 4-3. clock control signals control bits clock outputs stsim stext simclk clkout 0 0 extal off 0 1 extal extal 1 0 vco off 1 1 vco vco note: simclk runs the periodic interrupt reset and irq ? pin synchronizers in lpstop mode. 4.2.4 chip select operation typical microprocessor systems require external hardware to provide select signals to external memory and peripherals. the mc68340 integrates these functions on chip to provide the cost, speed, and reliability benefits of a higher level of integration. the chip select function contains register pairs for each external chip select signal. the pair consists of a base address register and an address mask register that define the characteristics of a single chip select. the register pair provides flexibility for a wide variety of chip select functions. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 4- 14 mc68340 user? manual motorola 4.2.4.1 programmable features. the chip select function supports the following programmable features: four programmable chip select circuits all four chip select circuits are independently programmable from the same list of selectable features. each chip select circuit has an individual base address register and address mask register that contain the programmed characteristics of that chip select. the base address register selects the starting address for the address block in 256-byte increments. the address mask register specifies the size of the address block range. the base address register v-bit indicates that the register information for that chip select is valid. a global chip select ( cs0 ) allows address decode for a boot rom before system initialization occurs. variable block sizes the block size, starting from the specified base address, can vary in size from 256 bytes up to 4 gbytes in 2 n increments. the specified base address must be on a multiple of the the block size. the block size is specified in the address mask register. both 8- and 16-bit ports supported the 8-bit ports are accessible on both odd and even addresses when connected to data bus bits 15?; the 16-bit ports can be accessed as odd bytes, even bytes, or even words. the port size is specified by the ps bits in the address mask register. write protect capability the wp bit in each base address register can restrict write access to its range of addresses. fast termination option programming the fte bit in the base address register for the fast termination option causes the chip select to terminate the cycle by asserting the internal dsack ? early, providing a two-cycle external access. internal dsack ? generation for external accesses with programmable wait states dsack ? can be generated internally with up to three wait states for a particular device using the dd bits in the address mask register. full 32-bit address decode with address space checking the fc bits in the base address register and fcm bits in the address mask register are used to select address spaces for which the chip selects will be asserted. 4.2.4.2 global chip select operation. global chip select operation allows address decode for a boot rom before system initialization occurs. cs0 is the global chip select output, and its operation differs from the other external chip select outputs following reset. when the cpu32 begins fetching after reset, cs0 is asserted for every address until the v-bit is set in the cs0 base address register. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 4- 15 note if an access matches multiple chip selects, the lowest numbered chip select will have priority. for example, if cs0 and cs2 "overlap" for a certain range, cs0 will assert when accessing the "overlapped" address range, and cs2 will not. global chip select provides a 16-bit port with three wait states, which allows a boot rom to be located in any address space and still provide the stack pointer and program counter values at $00000000 and $00000004, respectively. global chip select does not provide write protection and responds to all function codes. while cs0 is a global chip select, no other chip select ( cs1, cs2, cs3 ) can be used. cs0 operates in this manner until the v-bit is set in the cs0 base address register, which will then allow the use of cs3?s1 . provided the desired address range is first loaded into the cs0 base address register, cs0 can be programmed to continue decode for a range of addresses after the v-bit is set, after the v-bit is set for cs0 , global chip select can only be restarted with a system reset. a system can use an 8-bit boot rom if an external 8-bit dsack ? that responds in two or less wait states is generated. the 8-bit dsack ? must respond in two or less wait states so that the global chip select, which responds with three wait states, will not be used. see section 10 applications for a detailed discussion. 4.2.5 external bus interface operation this section describes port a and port b functions. refer to section 3 bus operation for more information about the ebi. 4.2.5.1 port a. port a pins can be independently programmed to function as either addresses a31?24, discrete i/o pins, or iackx pins. the port a pin assignment registers (ppara1 and ppara2) control the function of the port a pins as listed in table 4-4. upon reset, port a is configured as input pins. if the system uses these signals as addresses, pulldowns should be put on these signals to avoid indeterminate values until the port a registers can be programmed. table 4-4. port a pin assignment register pin function signal ppara1 = 0 ppara1 = 1 ppara1 = 0 ppara2 = 0 ppara2 = x ppara2 = 1 a31 a31 port a7 iack7 a30 a30 port a6 iack6 a29 a29 port a5 iack5 a28 a28 port a4 iack4 a27 a27 port a3 iack3 a26 a26 port a2 iack2 a25 a25 port a1 iack1 a24 a24 port a0 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 4- 16 mc68340 user? manual motorola 4.2.5.2 port b. port b pins can be independently programmed to function as chip selects, irq ? and modck pins, or discrete i/o pins. these pins are multiplexed as shown in figure 4-7. selection of a pin function is accomplished by a combination of the port b pin assignment register (pparb) and the firq bit of the mcr. see table 4-5 for port b combinations. by changing the value of the firq bit and the corresponding bits in the pparb for a particular signal, the port b pins can be configured for different pin functions. upon reset, port b is configured as modck, irq7, irq6, irq5, irq3 , and cs3?s0 . interrupt port logic full irq mux avec chip- select module cs1/irq1/port b1 cs3 cs2 cs1 cs0 cs0/avec firq cs2/irq2/port b2 cs3/irq4/port b4 irq3/port b3 irq5/port b5 irq6/port b6 irq7/port b7 modck/port b0 irq4/port b4 irq2/port b2 irq1/port b1 figure 4-7. full interrupt request multiplexer table 4-5. port b pin assignment register pin function signal firq = 0 firq = 0 firq = 1 firq = 1 pparb = 0 pparb = 1 pparb = 0 pparb = 1 irq7 portb7 irq7 portb7 irq7 irq6 portb6 irq6 portb6 irq6 irq5 portb5 irq5 portb5 irq5 irq3 portb3 irq3 portb3 irq3 cs3 cs3 cs3 portb4 irq4 cs2 cs2 cs2 portb2 irq2 cs1 cs1 cs1 portb1 irq1 cs0 cs0 cs0 avec avec modck portb0 modck portb0 modck note: modck has no function after reset. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 4- 17 the number of wait states programmed into the internal wait state generation logic by a chip select can be used even though the pin is not used as a cs ? signal. the programmed number of wait states in the cs ? signal applies to the port b pins configured as irq ? or i/o pins. this is done by programming the chip select with the number of wait states to be added, as though it were to be used. the dd1/dd0 and ps1/ps0 bits in the chip select address mask register must be set to add the desired number of wait states (the v-bit in the module base address register should be set). 4.2.6 low-power stop executing the lpstop instruction provides reduced power consumption when the mc68340 is idle; only the sim40 remains active. operation of the sim40 clock and clkout during lpstop is controlled by the stsim and stext bits in the syncr (see table 4-3). lpstop disables the clock to the software watchdog in the low state. the software watchdog remains stopped until the lpstop mode ends; it begins to run again on the next rising clock edge. note when the cpu32 executes the stop instruction (as opposed to lpstop), the software watchdog continues to run. if the software watchdog is enabled, it issues a reset or interrupt when timeout occurs. the periodic interrupt timer does not respond to an lpstop instruction; thus, it can be used to exit lpstop as long as the interrupt request level is higher than the cpu32 interrupt mask level. to stop the periodic interrupt timer while in lpstop, the pitr must be loaded with a zero value before lpstop is executed. the bus monitor, double bus fault monitor, and spurious interrupt monitor are all inactive during lpstop. the stp bit in the mcr of each on-chip module (dma, timers, and serial modules) should be set prior to executing the lpstop instruction. setting the stp bit stops all clocks within each of the modules, except for the clock from the imb. the clock from the imb remains active to allow the cpu32 access to the mcr of each module. the system clock stops on the low phase of the clock and remains stopped until the stp bit is cleared by the cpu32 or until reset. for more information, see the description of the mcr stp bit for each module. if an external device requires additional time to prepare for entry into lpstop mode, entry can be delayed by asserting halt ( see 3.4.2 lpstop broadcast cycle ). 4.2.7 freeze freeze is asserted by the cpu32 if a breakpoint is encountered with background mode enabled. refer to section 5 cpu32 for more information on the background mode. when freeze is asserted, the double bus fault monitor and spurious interrupt monitor continue to operate normally. however, the software watchdog, the periodic interrupt timer and the internal bus monitor will be affected. when freeze is asserted, setting the frz1 bit in f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 4- 18 mc68340 user? manual motorola the mcr disables the software watchdog and periodic interrupt timer, and setting the frz0 bit in the mcr disables the bus monitor. 4.3 programming model figure 4-8 is a programming model (register map) of all registers in the sim40. for more information about a particular register, refer to the description of the module or function indicated in the right column. the addr (address) column indicates the offset of the register from the address stored in the module base address register. the fc (function code) column indicates whether a register is restricted to supervisor access (s) or programmable to exist in either supervisor or user space (s/u). for the registers discussed in the following pages, the number in the upper right-hand corner indicates the offset of the register from the address stored in the module base address register. the numbers on the top line of the register represent the bit position in the register. the second line contains the mnemonic for the bit. the numbers below the register represent the bit values after a hardware reset. the access privilege is indicated in the lower right-hand corner. note: a cpu32 reset instruction will not affect any of the sim40 registers. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 4- 19 addr fc 15 8 7 0 000 s module configuration register (mcr) system protection 004 s clock synthesizer control register (syncr) clock 006 s autovector register (avr) reset status register (rsr) system protection 010 s/u reserved port a data (porta) ebi 012 s/u reserved port a data direction (ddra) ebi 014 s reserved port a pin assignment 1 (ppra1) ebi 016 s reserved port a pin assignment 2 (ppra2) ebi 018 s/u reserved port b data (portb) ebi 01a s/u reserved port b data (portb1) ebi 01c s/u reserved port b data direction (ddrb) ebi 01e s reserved port b pin assignment (pparb) ebi 020 s sw interrupt vector (swiv) system protection control (sypcr) system protection 022 s periodic interrupt control register (picr) system protection 024 s periodic interrupt timing register (pitr) system protection 026 s reserved software service (swsr) system protection 040 s address mask 1 cs0 chip select 042 s address mask 2 cs0 chip select 044 s base address 1 cs0 chip select 046 s base address 2 cs0 chip select 048 s address mask 1 cs1 chip select 04a s address mask 2 cs1 chip select 04c s base address 1 cs1 chip select 04e s base address 2 cs1 chip select 050 s address mask 1 cs2 chip select 052 s address mask 2 cs2 chip select 054 s base address 1 cs2 chip select 056 s base address 2 cs2 chip select 058 s address mask 1 cs3 chip select 05a s address mask 2 cs3 chip select 05c s base address 1 cs3 chip select 05e s base address 2 cs3 chip select figure 4-8. sim40 programming model f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 4- 20 mc68340 user? manual motorola 4.3.1 module base address register (mbar) mbar 1 $0003ff00 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 ba31 ba30 ba29 ba28 ba27 ba26 ba25 ba24 ba23 ba22 ba21 ba20 ba19 iba18 ba17 ba16 reset: 0000000000000000 cpu space only mbar 2 $0003ff02 1514131211109876543210 ba15 ba14 ba13 ba12 0 0 as8 as7 as6 as5 as4 as3 as2 as1 as0 v reset 0000000000000000 cpu space only ba31?a12?ase address bits 31?2 the base address field is the upper 20 bits of the mbar that provides for block starting locations in increments of 4-kbytes. bits 11, 10?eserved as8?s0?ddress space bits 8? the address space field allows particular address spaces to be masked, placing the 4k module block into a particular address space(s). if an address space is masked, an access to the register block location in that address space becomes an external access. the module block is not accessed. the address space bits are as follows: as8?ask dma space address space (fc3?c0 = 1xxx) as7?ask cpu space address space (fc3?c0 = 0111) as6?ask supervisor program address space (fc3?c0 = 0110) as5?ask supervisor data address space (fc3?c0 = 0101) as4?ask reserved [motorola] address space (fc3?c0 = 0100) as3?ask reserved [user] address space (fc3?c0 = 0011) as2?ask user program address space (fc3?c0 = 0010) as1?ask user data address space (fc3?c0 = 0001) as0?ask reserved [motorola] address space (fc3?c0 = 0000) for each address space bit: 1 = mask this address space from the internal module selection. the bus cycle goes external. 0 = decode for the internal module block. v?alid bit this bit indicates when the contents of the mbar are valid. the base address value is not used; therefore, all internal module registers are not accessible until the v-bit is set. 1 = contents are valid. 0 = contents are not valid. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 4- 21 note an access to this register does not affect external space since the cycle is not run externally. example code for accessing the mbar is as follows: register d0 will contain the value of mbar. mbar can be read using the following code: move.l #7,d0 load d0 with the cpu space function code movec.l d0,sfc load sfc to indicate cpu space lea.l $0003ff00,a0 load a0 with the address of mbar moves.l (a0),d0 load d0 with the contents of mbar address $0003ff00 in cpu space (mbar) will be loaded with the value $fffff001. this value will set the base address of the internal registers to $fffff. mbar can be written to using the following code: move.l #7,d0 load d0 with the cpu space function code movec.l d0,dfc load dfc to indicate cpu space lea.l $0003ff00,a0 load a0 with the address of mbar move.l #$fffff001,d0 load d0 with the value to be written into mbar moves.l d0,(a0) write the value contained in d0 into mbar 4.3.2 system configuration and protection registers the following paragraphs provide descriptions of the system configuration and protection registers. 4.3.2.1 module configuration register (mcr). the mcr, which controls the sim40 configuration, can be read or written at any time. mcr $000 1514131211109876543210 0 frz1 frz0 firq 0 0 shen1 shen0 supv 0 0 0 iarb3 iarb2 iarb1 iarb0 reset: 0110000010001111 supervisor only bits 15, 11, 10, 6??eserved frz1?reeze software enable 1 = when freeze is asserted, the software watchdog and periodic interrupt timer counters are disabled, preventing interrupts from occurring during software debug. 0 = when freeze is asserted, the software watchdog and periodic interrupt timer counters continue to run. see 4.2.7 freeze for more information. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 4- 22 mc68340 user? manual motorola frz0?reeze bus monitor enable 1 = when freeze is asserted, the bus monitor is disabled. 0 = when freeze is asserted, the bus monitor continues to operate as programmed. firq?ull interrupt request mode 1 = configures port b for seven interrupt request lines, autovector, and no external chip selects. 0 = configures port b for four interrupt request lines and four external chip selects. see table 4-5 for pin function selection. shen1, shen0?how cycle enable these two control bits determine what the ebi does with the external bus during internal transfer operations (see table 4-6). a show cycle allows internal transfers to be externally monitored. the address, data, and control signals (except for as) are driven externally. ds is used to signal address strobe timing for show cycles. data is valid on the next falling clock edge after ds is negated. however, data is not driven externally, and as and ds are not asserted externally for internal accesses unless show cycles are enabled. if external bus arbitration is disabled, the ebi will not recognize an external bus request until arbitration is enabled again. to prevent bus conflicts, external peripherals must not attempt to initiate cycles during show cycles with arbitration disabled. table 4-6. shenx control bits shen1 shen0 action 0 0 show cycles disabled, external arbitration enabled 0 1 show cycles enabled, external arbitration disabled 1 x show cycles enabled, external arbitration enabled supv?upervisor/user data space the supv bit defines the sim40 registers as either supervisor data space or user (unrestricted) data space. 1 = the sim40 registers defined as supervisor/user are restricted to supervisor data access (fc3?c0 = $5). an attempted user-space write is ignored and returns berr . 0 = the sim40 registers defined as supervisor/user data are unrestricted (fc2 is a don't care). iarb3?arb0?nterrupt arbitration bits 3? these bits are used to arbitrate for the bus in the case that two or more modules simultaneously generate an interrupt at the same priority level. no two modules can share the same iarb value. the reset value of iarb is $f, allowing the sim40 to arbitrate during an iack cycle immediately after reset. the system software should initialize the iarb field to a value from $f (highest priority) to $1 (lowest priority). a f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 4- 23 value of $0 prevents arbitration and causes all sim40 interrupts, including external interrupts, to be discarded as extraneous. 4.3.2.2 autovector register (avr). the avr contains bits that correspond to external interrupt levels that require an autovector response. setting a bit allows the sim40 to assert an internal avec during the iack cycle in response to the specified interrupt request level. this register can be read and written at any time. avr $006 76543210 av7 av6 av5 av4 av3 av2 av1 0 reset: 00000000 supervisor only note: the iarb field in the mcr must contain a value other than $0 for the sim40 to autovector for external interrupts. 4.3.2.3 reset status register (rsr). the rsr contains a bit for each reset source to the sim40. a set bit indicates the last type of reset that occurred, and only one bit can be set in the register. the rsr is updated by the reset control logic when the sim40 comes out of reset. this register can be read at any time; a write has no effect. for more information, see section 3 bus operation. rsr $007 76543210 ext pow sw dbf 0 loc sys 0 supervisor only ext?xternal reset 1 = the last reset was caused by an external signal driving reset . pow?ower-up reset 1 = the last reset was caused by the power-up reset circuit. sw?oftware watchdog reset 1 = the last reset was caused by the software watchdog circuit. dbf?ouble bus fault monitor reset 1 = the last reset was caused by the double bus fault monitor. bits 3, 0?eserved f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 4- 24 mc68340 user? manual motorola loc?oss of clock reset 1 = the last reset was caused by a loss of frequency reference to the clock synthesizer. this reset can only occur if the rsten bit in the syncr is set and the vco is enabled. sys?ystem reset 1 = the last reset was caused by the cpu32 executing a reset instruction. the system reset does not load a reset vector or affect any internal cpu32 registers, sim40 configuration registers, or the mcr in each internal peripheral module (dma, timers, and serial modules). it will, however, reset external devices and all other registers in the peripheral modules. 4.3.2.4 software interrupt vector register (swiv). the swiv contains the 8-bit vector that is returned by the sim40 during an iack cycle in response to an interrupt generated by the software watchdog. this register can be read or written at any time. this register is set to the uninitialized vector, $0f, at reset. swiv $020 76543210 swiv7 swiv6 swiv5 swiv4 swiv3 swiv2 swiv1 swiv0 reset: 00001111 supervisor only 4.3.2.5 system protection control register (sypcr). the sypcr controls the system monitors, the prescaler for the software watchdog, and the bus monitor timing. this register can be read at any time, but can be written only once after reset. sypcr $021 76543210 swe swri swt1 swt0 dbfe bme bmt1 bmt0 reset: 00000000 supervisor only swe?oftware watchdog enable 1 = software watchdog is enabled. 0 = software watchdog is disabled. see 4.2.2.5 software watchdog for more information. swri?oftware watchdog reset/interrupt select 1 = software watchdog causes a system reset. 0 = software watchdog causes a level 7 interrupt to the cpu32. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 4- 25 swt1, swt0?oftware watchdog timing these bits, along with the swp bit in the pitr, control the divide ratio used to establish the timeout period for the software watchdog. the software watchdog timeout period is given by the following formula: divide count extal frequency the software watchdog timeout period, listed in table 4-7, gives the formula to derive the software watchdog timeout for any clock frequency. the timeout periods are listed for a 32.768-khz crystal used with the vco and for a 16.777-mhz external oscillator. table 4-7. deriving software watchdog timeout swp swt1 swt0 software timeout period 32.768-khz crystal period 16.777-mhz external clock period 000 2 9 /extal input frequency 15.6 ms 30 m s 0012 11 /extal input frequency 62.5 ms 122 m s 0102 13 /extal input frequency 250 ms 488 m s 0112 15 /extal input frequency 1 s 1.95 ms 1002 18 /extal input frequency 8 s 15.6 ms 1012 20 /extal input frequency 32 s 62.5 ms 1102 22 /extal input frequency 128 s 250 ms 1112 24 /extal input frequency 512 s 1 s note: when the swp and swt bits are modified to select a software timeout other than the default, the software service sequence ($55 followed by $aa written to the software service register) must be performed before the new timeout period takes effect. refer to 4.2.2.5 software watchdog for more information. dbfe?ouble bus fault monitor enable 1 = enable double bus fault monitor function. 0 = disable double bus fault monitor function. for more information, see 4.2.2.3 double bus fault monitor and section 5 cpu32 . bme?us monitor external enable 1 = enable bus monitor function for an internal-to-external bus cycle. 0 = disable bus monitor function for an internal-to-external bus cycle. for more information see 4.2.2.2 internal bus monitor . bmt1, bmt0?us monitor timing these bits select the timeout period for the bus monitor (see table 4-8). upon reset, the bus monitor is set to 64 system clocks. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 4- 26 mc68340 user? manual motorola table 4-8. bmtx encoding bmt1 bmt0 bus monitor timeout period 0 0 64 system clocks (clkout) 0 1 32 system clocks 1 0 16 system clocks 1 1 8 system clocks 4.3.2.6 periodic interrupt control register (picr). the picr contains the interrupt level and the vector number for the periodic interrupt request. this register can be read or written at any time. bits 15?1 are unimplemented and always return zero; a write to these bits has no effect. picr $022 1514131211109876543210 00000 pirql2 pirql1 pirql0 piv7 piv6 piv5 piv4 piv3 piv2 piv1 piv0 reset: 0000000000001111 supervisor only bits 15?1?eserved pirql2?irql0?eriodic interrupt request level these bits contain the periodic interrupt request level. table 4-9 lists which interrupt request level is asserted during an iack cycle when a periodic interrupt is generated. the periodic timer continues to run when the interrupt is disabled. table 4-9. pirql encoding pirql2 pirql1 pirql0 interrupt request level 0 0 0 periodic interrupt disabled 0 0 1 interrupt request level 1 0 1 0 interrupt request level 2 0 1 1 interrupt request level 3 1 0 0 interrupt request level 4 1 0 1 interrupt request level 5 1 1 0 interrupt request level 6 1 1 1 interrupt request level 7 note: use caution with a level 7 interrupt encoding due to the sim40's interrupt servicing order. see 4.2.2.7 simultaneous interrupts by sources in the sim40 for the servicing order. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 4- 27 piv7?iv0?eriodic interrupt vector bits 7? these bits contain the value of the vector generated during an iack cycle in response to an interrupt from the periodic timer. when the sim40 responds to the iack cycle, the periodic interrupt vector from the picr is placed on the bus. this vector number is multiplied by four to form the vector offset, which is added to the vector base register to obtain the address of the vector. 4.3.2.7 periodic interrupt timer register (pitr). the pitr contains control for prescaling the software watchdog and periodic timer as well as the count value for the periodic timer. this register can be read or written at any time. bits 15?0 are not implemented and always return zero when read. a write does not affect these bits. pitr $024 1514131211109876543210 000000swpptp pitr7 pitr6 pitr5 pitr4 pitr3 pitr2 pitr1 pitr0 reset: 000000 modck modck 00000000 supervisor only bits 15?0?eserved swp?oftware watchdog prescale this bit controls the software watchdog clock source as shown in 4.3.2.5 system protection control register (sypcr) . 1 = software watchdog clock prescaled by a value of 512. 0 = software watchdog clock not prescaled. the swp reset value is the inverse of the modck bit state on the rising edge of reset. ptp?eriodic timer prescaler control this bit contains the prescaler control for the periodic timer. 1 = periodic timer clock prescaled by a value of 512. 0 = periodic timer clock not prescaled. the ptp reset value is the inverse of the modck bit state on the rising edge of reset. pitr7?itr0?eriodic interrupt timer register bits 7? the remaining bits of the pitr contain the count value for the periodic timer. a zero value turns off the periodic timer. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 4- 28 mc68340 user? manual motorola 4.3.2.8 software service register (swsr). the swsr is the location to which the software watchdog servicing sequence is written. the software watchdog can be enabled or disabled by the swe bit in the sypcr. swsr can be written at any time, but returns all zeros when read. swsr $027 76543210 swsr7 swsr6 swsr5 swsr4 swsr3 swsr2 swsr1 swsr0 reset: 00000000 supervisor only 4.3.3 clock synthesizer control register (syncr) the syncr can be read or written only in supervisor mode. the reset state of syncr produces an operating frequency of 8.39 mhz when the pll is referenced to a 32.768- khz reference signal. the system frequency is controlled by the frequency control bits in the upper byte of the syncr as follows: f system = f crystal [2 (2+2w+x) ] (y+1) syncr $004 1514131211109876543210 w x y5 y4 y3 y2 y1 y0 rsvd 0 0 slimp slock rsten stsim stext reset: 00111111000uu000 u = unaffected by reset supervisor only w?requency control bit this bit controls the prescaler tap in the synthesizer feedback loop. setting the bit increases the vco speed by a factor of 4, requiring a time delay for the vco to relock (see equation for determining system frequency). x?requency control bit this bit controls a divide-by-two prescaler, which is not in the synthesizer feedback loop. setting the bit doubles the system clock speed without changing the vco speed, as specified in the equation for determining system frequency; therefore, no delay is incurred to relock the vco. y5?0?requency control bits the y-bits, with a value from 0?3, control the modulus downcounter in the synthesizer feedback loop, causing it to divide by the value of y+1 (see the equation for determining system frequency). changing these bits requires a time delay for the vco to relock. bits 7??eserved bit 7 is reserved for factory testing. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 4- 29 slimp?imp mode 1 = a loss of input signal reference has been detected, and the vco is running at approximately one-half the maximum speed (affected by the x-bit ), determined from an internal voltage reference. 0 = external input signal frequency is at vco reference. slock?ynthesizer lock 1 = vco has locked onto the desired frequency (or system clock is driven externally). 0 = vco is enabled, but has not yet locked. rsten?eset enable 1 = loss of input signal causes a system reset. 0 = loss of input signal causes the vco to operate at a nominal speed without external reference (limp mode), and the device continues to operate at that speed. stsim?top mode system integration clock 1 = when lpstop is executed, the sim40 clock is driven from the vco. 0 = when lpstop is executed, the sim40 clock is driven from an external crystal or oscillator, and the vco is turned off to conserve power. stext?top mode external clock 1 = when the lpstop instruction is executed, the external clock pin (clkout) is driven from the sim40 clock as determined by the stsim bit. 0 = when the lpstop instruction is executed, the external clock (clkout) is held low to conserve power. no external clock will be driven in lpstop mode. 4.3.4 chip select registers the following paragraphs provide descriptions of the registers in the chip select function, and an example of how to program the registers. the chip select registers cannot be used until the v-bit in the mbar is set. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 4- 30 mc68340 user? manual motorola 4.3.4.1 base address registers. there are four 32-bit base address registers in the chip select function, one for each chip select signal. base address 1 $044, $04c, $054, $05c 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 ba31 ba30 ba29 ba28 ba27 ba26 ba25 ba24 ba23 ba22 ba21 ba20 ba19 ba18 ba17 ba16 reset: uuuuuuuuuuuuuuuu supervisor only base address 2 $046, $04e, $056, $05e 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 ba15 ba14 ba13 ba12 ba11 ba10 ba9 ba8 bfc3 bfc2 bfc1 bfc0 wp fte ncs v reset: uuuuuuuuuuuuuu0 0 u = unaffected by reset supervisor only ba31?a8?ase address bits 31? the base address field, the upper 24 bits of each base address register, selects the starting address for the chip select. the specified base address must be on a multiple of the selected block size. the corresponding bits, am31?m8, in the address mask register define the size of the block for the chip select. the base address field (and the base function code field) is compared to the address on the address bus to determine if a chip select should be generated. bfc3?fc0?ase function code bits 3? the value programmed into this field causes a chip select to be asserted for a certain address space type. there are nine function code address spaces (see section 3 bus operation ) specified as either user or supervisor, program or data, cpu, and dma. these bits should be used to allow access to one type of address space. if access to more than one type of address space is desired, the fcmx bits should be used in addition to the bfcx bits. to prevent access to cpu space, set the ncs bit. wp?rite protect this bit can restrict write accesses to the address range in a base address register. an attempt to write to the range of addresses specified in a base address register that has this bit set returns berr . 1 = only read accesses are allowed. 0 = either read or write accesses are allowed. fte?ast-termination enable this bit causes the cycle to terminate early with an internal dsack ? , giving a fast two- clock external access. when clear, all external cycles are at least three clocks. if fast termination is enabled, the dd bits of the corresponding address mask register are overridden (see section 3 bus operation ). 1 = fast termination cycle enabled (termination determined by ps bits). 0 = fast termination cycle disabled (termination determined by dd and ps bits). f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 4- 31 ncs?o cpu space this bit specifies whether or not a chip select will assert on a cpu space access cycle (fc3?c0 = $7 or $f). if both supervisor data and program accesses are desired, while ignoring cpu space accesses, then this bit should be set. the ncs bit is cleared at reset. 1 = suppress the chip select on a cpu space access. 0 = assert the chip select on a cpu space access. v?alid bit this bit indicates that the contents of its base address register and address mask register pair are valid. the programmed chip selects do not assert until the v-bit is set. a reset clears the v-bit in each base address register, but does not change any other bits in the base address and address mask registers ( cs0 is a special case, see 4.2.4.2 global chip select operation ). 1 = contents are valid. 0 = contents are not valid. 4.3.4.2 address mask registers. there are four 32-bit address mask registers in the chip select function, one for each chip select signal. address mask 1 $040, $048, $050, $058 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 am31 am30 am29 am28 am27 am26 am25 am24 am23 am22 am21 am20 am19 am18 am17 am16 reset: uuuuuuuuuuuuuuuu supervisor only address mask 2 $042, $04a, $052, $05a 1514131211109876543210 am15 am14 am13 am12 am11 am10 am9 am8 fcm3 fcm2 fcm1 fcm0 dd1 dd0 ps1 ps0 reset: uuuuuuuuuuuuuuuu u = unaffected by reset supervisor only am31?m8?ddress mask bits 31? the address mask field, the upper 24 bits of each address mask register, defines the chip select block size. the block size is equal to 2 n , where n = (number of bits set in the address mask field) + 8. any set bit masks the corresponding base address register bit (the base address register bit becomes a don? care). by masking the address bits independently, external devices of different size address ranges can be used. address mask bits can be set or cleared in any order in the field, allowing a resource to reside in more than one area of the address map. this field can be read or written at any time. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 4- 32 mc68340 user? manual motorola fcm3?cm0?unction code mask bits 3? this field can be used to mask certain function code bits, allowing more than one address space type to be assigned to a chip select. any set bit masks the corresponding function code bit. dd1, dd0?sack delay bits 1 and 0 this field determines the number of wait states added before an internal dsack ? is returned for that entry. table 4-10 lists the encoding for the dd bits. note: the port size field must be programmed for an internal dsack ? response and the fte bit in the base address register must be cleared for the ddx bits to have significance. if external dsack ? signals are returned earlier than indicated by the ddx bits, the cycle will terminate sooner than programmed. see 4.2.5.2 port b for a discussion on using the internal dsack ? generation without using the cs ? signal. table 4-10. ddx encoding dd1 dd0 response 0 0 zero wait state 0 1 one wait state 1 0 two wait states 1 1 three wait states ps1, ps0?ort size bits 1 and 0 this field determines whether a given chip select responds with dsack ? and, if so, what port size is returned. table 4-11 lists the encoding for the psx bits. table 4-11. psx encoding ps1 ps0 mode 0 0 reserved* 0 1 16-bit port 1 0 8-bit port 1 1 external dsack ? response *use only for 32-bit dma transfers. to use the external dsack ? response, ps1?s0 = 11 should be selected to suppress internal dsack ? generation . the ddx bits then have no significance. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 4- 33 4.3.4.3 chip select registers programming example. the following listing is an example of programming a chip select at starting address $00040000, for a block size of 256 kbytes, accessing supervisor and user data spaces with a 16-bit port requiring two wait states. there will be no write protection, no fast termination, and no cpu space accesses. base address 1 = $0004 base address 2 = $0013 address mask 1 = $0003 address mask 2 = $ff49 note if an access matches multiple chip selects, the lowest numbered chip select will have priority. for example, if cs0 and cs2 "overlap" for a certain range, cs0 will assert when accessing the "overlapped" address range, and cs2 will not. 4.3.5 external bus interface control the following paragraphs describe the registers that control the i/o pins used with the ebi. refer to the section 3 bus operation for more information about the ebi. for a list of pin numbers used with port a and port b, see the pinout diagram in section 12 ordering information and mechanical data. section 2 signal descriptions shows a block diagram of the port control circuits. 4.3.5.1 port a pin assignment register 1 (ppara1). ppara1 selects between an address and discrete i/o function for the port a pins. any set bit defines the corresponding pin to be an i/o pin, controlled by the port a data and data direction registers. any cleared bit defines the corresponding pin to be an address bit as defined in the following register diagram. bits set in this register override the configuration setting of ppara2. the $ff reset value of ppara1 configures it as an input port. this register can be read or written at any time. ppara1 $015 76543210 prta7 (a31) prta6 (a30) prta5 (a29) prta4 (a28) prta3 (a27) prta2 (a26) prta1 (a25) prta0 (a24) reset: 11111111 supervisor only f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 4- 34 mc68340 user? manual motorola 4.3.5.2 port a pin assignment register 2 (ppara2). ppara2 selects between an address and iack ? function for the port a pins. any set bit defines the corresponding pin to be an iack ? output pin. any cleared bit defines the corresponding pin to be an address bit as defined in the register diagram. any set bits in ppara1 override the configuration set in ppara2. bit 0 has no function in this register because there is no level 0 interrupt. this register can be read or written at any time. ppara2 $017 76543210 iack7 (a31) iack6 (a30) iack5 (a29) iack4 (a28) iack3 (a27) iack2 (a26) iack1 (a25) 0 reset: 00000000 supervisor only the iack ? signals are asserted if a bit in ppara2 is set and the cpu32 services an external interrupt at the corresponding level. iack ? signals have the same timing as address strobes. note: upon reset, port a is configured as an input port. 4.3.5.3 port a data direction register (ddra). ddra controls the direction of the pin drivers when the pins are configured as i/o. any set bit configures the corresponding pin as an output. any cleared bit configures the corresponding pin as an input. this register affects only pins configured as discrete i/o. this register can be read or written at any time. ddra $013 76543210 dd7 dd6 dd5 dd4 dd3 dd2 dd1 dd0 reset: 00000000 supervisor/user 4.3.5.4 port a data register (porta). porta affects only pins configured as discrete i/o. a write to porta is stored in the internal data latch, and if any port a pin is configured as an output, the value stored for that bit is driven on the pin. a read of porta returns the value at the pin only if the pin is configured as discrete input. otherwise, the value read is the value stored in the internal data latch. this register can be read or written at any time. porta $011 76543210 p7 p6 p5 p4 p3 p2 p1 p0 reset: uuuuuuuu supervisor/user f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 4- 35 4.3.5.5 port b pin assignment register (pparb). pparb controls the function of each port b pin. any set bit defines the corresponding pin to be an irq ? input or cs ? as defined in table 4-5. any cleared bit defines the corresponding pin to be a discrete i/o pin (or cs ? if the firq bit of the mcr is zero) controlled by the port b data and data direction registers. the modck signal has no function after reset. pparb is configured to all ones at reset to provide for modck, irq7 , irq6 , irq5 , irq3 , and cs3 cs0 . this register can be read or written at any time. pparb $01f 76543210 pparb7 (irq7) pparb6 (irq6) pparb5 (irq5) pparb4 (irq4) pparb3 (irq3) pparb2 (irq2) pparb1 (irq1) pparb0 (modck) reset: 11111111 supervisor only 4.3.5.6 port b data direction register (ddrb). ddrb controls the direction of the pin drivers when the pins are configured as i/o. any set bit configures the corresponding pin as an output; any cleared bit configures the corresponding pin as an input. this register affects only pins configured as discrete i/o. this register can be read or written at any time. ddrb $01d 76543210 dd7 dd6 dd5 dd4 dd3 dd2 dd1 dd0 reset: 00000000 supervisor/user 4.3.5.7 port b data register (portb, portb1). this is a single register that can be accessed at two different addresses. this register affects only those pins configured as discrete i/o. a write is stored in the internal data latch, and if any port b pin is configured as an output, the value stored for that bit is driven on the pin. a read of this register returns the value stored in the register only if the pin is configured as a discrete output. otherwise, the value read is the value of the pin. this register can be read or written at any time. portb, portb1 $019, 01b 76543210 p7 p6 p5 p4 p3 p2 p1 p0 reset: uuuuuuuu supervisor/user f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 4- 36 mc68340 user? manual motorola 4.4 mc68340 initialization sequence the following paragraphs discuss a suggested method for initializing the mc68340 after power-up. 4.4.1 startup reset is asserted by the mc68340 during the time in which v cc is ramping up, the vco is locking onto the frequency, and the mc68340 is going through the reset operation. after reset is negated, four bus cycles are run, with global cs0 being asserted to fetch the 32-bit supervisor stack pointer (ssp) and the 32-bit program counter (pc) from the boot rom. until programmed differently, cs0 is a global, 16-bit-wide, three-wait-state chip select. cs0 can be programmed to continue decode for a range of addresses after the v-bit is set, provided the desired address range is first loaded into the cs0 base address register. after the v-bit is set for cs0 , global chip select can only be restarted with a system reset. after the ssp and the pc are fetched, the module base address register (mbar) should be initialized, and the mbar v-bit should be set (cpu space address $0003ff00) with the desired base address for the internal modules. 4.4.2 sim40 module configuration the order of the following sim40 register initializations is not important; however, time can be saved by initializing the syncr first to quickly increase to the desired processor operating frequency. the module base address register must be initialized prior to any of following steps. clock synthesizer control register (syncr): set frequency control bits (w, x, y) to specify frequency. select action taken during loss of crystal (rsten bit): activate a system reset or operate in limp mode. select system clock and clkout during lpstop (stsim and stext bits). module configuration register (mcr) if using the software watchdog, periodic interrupt timer, and/or the bus monitor, select action taken when freeze is asserted (frzx bits). select port b configuration (firq bit). note that this bit is used in combination with the bits in the pparb to program the function of the port b pins. select the access privilege for the supervisor/user registers (supv bit). select the interrupt arbitration level for the sim40 (iarbx bits). autovector register (avr) select the desired external interrupt levels for internal autovectoring. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 4- 37 system protection control register (sypcr) (note that this register can only be written once after reset.) enable the software watchdog, if desired (swe bit). if the watchdog is enabled, select whether a system reset or a level 7 interrupt is desired at timeout (swri bit). if the watchdog is enabled, select the timeout period (swtx bits). enable the double bus fault monitor, if desired (dbfe bit). enable the external bus monitor, if desired (bme bit). select timeout period for bus monitor (bmtx bits). software watchdog interrupt vector register (swiv) if using the software watchdog, program the vector number for a software watchdog interrupt. periodic interrupt timer register (pitr) if using the software watchdog, select whether or not to prescale (swp bit). if using the periodic interrupt timer, select whether or not to prescale (ptp bit). program the count value for the periodic timer, or program a zero value to turn off the periodic timer (pitrx bits). periodic interrupt control register (picr) if using the periodic timer, program the desired interrupt level for the periodic interrupt timer (pirqlx bits). if using the periodic timer, program the vector number for a periodic timer interrupt. chip select base address and address mask registers initialize and set the v-bits in the necessary chip select base address and address mask registers. following this step, other system resources requiring the cs ? signals can be accessed. care must be exercised when changing the address for cs0 . the address of the instruction following the move instruction to the cs0 base address register must match the value of the pc at that time. cs0 must be taken out of global chip select mode by setting the v-bit in the base address register before cs3 cs1 can be used. port a and b registers program the desired function of the port a signals (ppara1 and ppara2 registers). program the desired function of the port b signals (pparb register). f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 4- 38 mc68340 user? manual motorola 4.4.3 sim40 example configuration code the following code is an example configuration sequence for the sim40 module. *************************************************************************** * mc68340 basic sim40 register initialization example code: * this code is used to initialize the mc68340's internal sim40 registers, * providing basic functions for operation. * it includes chip select programming for external devices. * this code would be programmed beginning at offset $0 into rom which is * relocated to address $60000 by the initialization code. * the ssp_vec and rst_vec vectors used to initialize the system stack * pointer and initial pc, respectively, are located at offset $0 after * reset. *************************************************************************** * equates *************************************************************************** ssp_init equ $10000 stack pointer initial value - top of ram mbar equ $0003ff00 address of module base address reg. modbase equ $fffff000 default module base address value **************************************** * sim40 register offsets from mbar base address mcr equ $00 syncr equ $04 sypcr equ $21 csam0 equ $40 csbar0 equ $44 csam1 equ $48 csbar1 equ $4c csam2 equ $50 csbar2 equ $54 csam3 equ $58 csbar3 equ $5c *************************************************************************** * reset vectors * these two vectors should be located at addresses $0 and $4 after a processor * hardware reset. *************************************************************************** org $60000 ssp_vec dc.l ssp_init supervisor stack pointer - initial value rst_vec dc.l init340 reset vector pointing to initialization code f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 4- 39 *************************************************************************** * initialization code *************************************************************************** * start chip select initialization: init340 move.w #$2700,sr init sr - interrupts masked *************************************************************************** * set up default module base address value moveq.l #7,d0 mbar is in cpu space movec.l d0,dfc load dfc to indicate cpu space move.l #modbase+1,d0 set address/valid bit moves.l d0,mbar write to mbar *************************************************************************** * set up system protection register: * software watchdog disabled, double bus fault monitor disabled, bus * monitor berr after 16 clocks. move.b #6,sypcr+modbase *************************************************************************** * clock synthesizer control register: * switch from 8.3 to 16.7 mhz move.w #$7f00,syncr+modbase x-bit doubles the default speed *************************************************************************** * module configuration register: * when freeze is asserted, software watchdog and periodic interrupt timer * are disabled, bus monitor is enabled. port b = 4 irqs, 4 chip selects. * show cycles enabled, external arbitration enabled. supervisor/user * sim registers unrestricted, interrupt arbitration at priority $f move.w #$420f,mcr+modbase *************************************************************************** * now, set up address masks and base addresses for the chip selects: lea csam0+modbase,a0 point to cs0 addr. mask location. moveq #7,d set up a loop counter. lea csam0$,a1 point to addr mask memory location. loop move.l (a1)+,(a0)+ init. addr mask and base addr reg dbra d0,loop f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 4- 40 mc68340 user? manual motorola *************************************************************************** * data table for chip select initialization *************************************************************************** * cs0 - eprom - 00060000-0007ffff, 3-wait states, 16-bit term., write protect csam0$ dc.l $0001fffd csbar0$ dc.l $00060009 * cs1 - ram - 00000000-0000ffff, fast termination csam1$ dc.l $0000fff0 csbar1$ dc.l $00000005 * cs2 - external device - 00ffe8xx, external termination csam2$ dc.l $000000f3 csbar2$ dc.l $00ffe801 * cs3 - secondary memory - 00000000-0003ffff, 3-wait states, 16-bit term. csam3$ dc.l $0003fffd csbar3$ dc.l $00000001 *************************************************************************** end f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 1 section 5 cpu32 the cpu32, the first-generation instruction processing module of the m68300 family, is based on the industry-standard mc68000 core processor. it has many features of the mc68010 and mc68020 as well as unique features suited for high-performance processor applications. the cpu32 provides a significant performance increase over the mc68000 cpu, yet maintains source-code and binary-code compatibility with the m68000 family. 5.1 overview the cpu32 is designed to interface to the intermodule bus (imb), allowing interaction with other imb submodules. in this manner, integrated processors can be developed that contain useful peripherals on chip. this integration provides high-speed accesses among the imb submodules, increasing system performance. another advantage of the cpu32 is low power consumption. the cpu32 is implemented in high-speed complementary metal-oxide semiconductor (hcmos) technology, providing low power use during normal operation. during periods of inactivity, the lpstop instruction can be executed, shutting down the cpu32 and other imb modules, greatly reducing power consumption. ease of programming is an important consideration when using an integrated processor. the cpu32 instruction format reflects a predominate register-memory interaction philosophy. all data resources are available to all operations that require them. the programming model includes eight multifunction data registers and seven general-purpose addressing registers. the data registers readily support 8-bit (byte), 16-bit (word), and 32- bit (long-word) operand lengths for all operations. address manipulation is supported by word and long-word operations. although the program counter (pc) and stack pointers (sp) are special-purpose registers, they are also available for most data addressing activities. ease of program checking and diagnosis is enhanced by trace and trap capabilities at the instruction level. as processor applications become more complex and programs become larger, high-level language (hll) will become the system designer's choice in programming languages. hll aids in the rapid development of complex algorithms with less error and is readily portable. the cpu32 instruction set will efficiently support hll. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 2 mc68340 user? manual motorola 5.1.1 features features of the cpu32 are as follows: fully upward object-code compatible with m68000 family virtual memory implementation loop mode of instruction execution fast multiply, divide, and shift instructions fast bus interface with dynamic bus port sizing improved exception handling for embedded control applications additional addressing modes ?scaled index ?address register indirect with base displacement and index ?expanded pc relative modes ?32-bit branch displacements instruction set additions ?high-precision multiply and divide ?trap on condition codes ?upper and lower bounds checking enhanced breakpoint instruction trace on change of flow table lookup and interpolate instruction lpstop instruction hardware bkpt signal, background mode fully static implementation a block diagram of the cpu32 is shown in figure 5-1. the major blocks depicted operate in a highly independent fashion that maximizes concurrences of operation while managing the essential synchronization of instruction execution and bus operation. the bus controller loads instructions from the data bus into the decode unit. the sequencer and control unit provide overall chip control, managing the internal buses, registers, and functions of the execution unit. 5.1.2 virtual memory a system that supports virtual memory has a limited amount of high-speed physical memory that can be accessed directly by the processor and maintains an image of a much larger virtual memory on a secondary storage device. when the processor attempts to access a location in the virtual memory map that is not resident in physical memory, a page fault occurs. the access to that location is temporarily suspended while the necessary data is fetched from secondary storage and placed in physical memory. the f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 3 cpu32 uses instruction restart, which requires that only a small portion of the internal machine state be saved. after correcting the page fault, the machine state is restored, and the instruction is refetched and restarted. this process is completely transparent to the application program. bus control instruction prefetch and decode execution unit sequencer control unit bus control address bus data bus 16 32 figure 5-1. cpu32 block diagram 5.1.3 loop mode instruction execution the cpu32 has several features that provide efficient execution of program loops. one of these features is the dbcc looping primitive instruction. to increase the performance of the cpu32, a loop mode has been added to the processor. the loop mode is used by any single-word instruction that does not change the program flow. loop mode is implemented in conjunction with the dbcc instruction. figure 5-2 shows the required form of an instruction loop for the processor to enter loop mode. one-word instruction dbcc dbcc displacement $fffc = 4 figure 5-2. loop mode instruction sequence the loop mode is entered when the dbcc instruction is executed and the loop displacement is ?. once in loop mode, the processor performs only the data cycles associated with the instruction and suppresses all instruction fetches. the termination f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 4 mc68340 user? manual motorola condition and count are checked after each execution of the data operations of the looped instruction. the cpu32 automatically exits the loop mode on interrupts or other exceptions. 5.1.4 vector base register the vector base register (vbr) contains the base address of the 1024-byte exception vector table, which consists of 256 exception vectors. exception vectors contain the memory addresses of routines that begin execution at the completion of exception processing. these routines perform a series of operations appropriate for the corresponding exceptions. because the exception vectors contain memory addresses, each consists of one long word, except for the reset vector. the reset vector consists of two long words: the address used to initialize the supervisor stack pointer (ssp) and the address used to initialize the pc. the address of an interrupt exception vector is derived from an 8-bit vector number and the vbr. the vector numbers for some exceptions are obtained from an external device; other numbers are supplied automatically by the processor. the processor multiplies the vector number by 4 to calculate the vector offset, which is added to the vbr. the sum is the memory address of the vector. all exception vectors are located in supervisor data space, except the reset vector, which is located in supervisor program space. only the initial reset vector is fixed in the processor's memory map; once initialization is complete, there are no fixed assignments. since the vbr provides the base address of the vector table, the vector table can be located anywhere in memory; it can even be dynamically relocated for each task that is executed by an operating system. refer to 5.5 exception processing for additional details. 31 0 vector base register (vbr) 5.1.5 exception handling the processing of an exception occurs in four steps, with variations for different exception causes. during the first step, a temporary internal copy of the status register (sr) is made, and the sr is set for exception processing. during the second step, the exception vector is determined. during the third step, the current processor context is saved. during the fourth step, a new context is obtained, and the processor then proceeds with instruction processing. exception processing saves the most volatile portion of the current context by pushing it on the supervisor stack. this context is organized in a format called the exception stack frame. this information always includes the sr and pc context of the processor when the exception occurred. to support generic handlers, the processor places the vector offset in the exception stack frame. the processor also marks the frame with a frame format. the format field allows the return-from-exception (rte) instruction to identify what information is on the stack so that it may be properly restored. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 5 5.1.6 addressing modes addressing in the cpu32 is register oriented. most instructions allow the results of the specified operation to be placed either in a register or directly in memory; this flexibility eliminates the need for extra instructions to store register contents in memory. the seven basic addressing modes are as follows: register direct register indirect register indirect with index program counter indirect with displacement program counter indirect with index absolute immediate included in the register indirect addressing modes are the capabilities to postincrement, predecrement, and offset. the pc relative mode also has index and offset capabilities. in addition to these addressing modes, many instructions implicitly specify the use of the sr, sp and/or pc. addressing is explained fully in the m68000pm/ad, m68000 family programmer? reference manual . 5.1.7 instruction set the instruction set of the cpu32 is very similar to that of the mc68020 (see table 5-1). two new instructions have been added to facilitate embedded control applications: lpstop and table lookup and interpolate (tbl). the following m68020 instructions are not implemented on the cpu32: bfxxx bit field instructions (bfchg, bfclr, bfexts, bfextu, bfffo, bfins, bfset, bftst) callm, rtm call module, return module cas, cas2 compare and set (read-modify-write instructions) cpxxx coprocessor instructions (cpbcc, cpdbcc, cpgen, cprestore, cpsave, cpscc, cptrapcc) pack, unpk pack, unpack bcd instructions the cpu32 traps on unimplemented instructions or illegal effective addressing modes, allowing user-supplied code to emulate unimplemented capabilities or to define special- purpose functions. however, motorola reserves the right to use all currently unimplemented instruction operation codes for future m68000 core enhancements. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 6 mc68340 user? manual motorola table 5-1. instruction set mnemonic description mnemonic description abcd add decimal with extend movea move address add add move ccr move condition code register adda add address move sr move to/from status register addi add immediate move usp move user stack pointer addq add quick movec move control register and logical and movem move multiple registers andi logical and immediate movep move peripheral data asl arithmetic shift left moveq move quick asr arithmetic shift right moves move alternate address space bcc branch conditionally (16 tests) muls signed multiply bchg bit test and change mulu unsigned multiply bclr bit test and clear nbcd negate decimal with extend bgnd enter background mode neg negate bkpt breakpoint negx negate with extend bra branch always nop no operation bset bit test and set not ones complement bsr branch to subroutine or logical inclusive or btst bit test ori logical inclusive or immediate chk check register against bounds pea push effective address chk2 check register against upper and reset reset external devices lower bounds rol, ror rotate left and right clr clear operand roxl, roxr rotate with extend left and right cmp compare rtd return and deallocate cmpa compare address rte return from exception cmpi compare immediate rtr return and restore cmpm compare memory rts return from subroutine cmp2 compare register against upper sbcd subtract decimal with extend and lower bounds scc set conditionally dbcc test condition, decrement and stop stop branch (16 tests) sub subtract divs, divsl signed divide suba subtract address divu, divul unsigned divide subi subtract immediate eor logical exclusive or subq subtract quick eori logical exclusive or immediate subx subtract with extend exg exchange registers swap swap data register halves ext, extb sign extend tas test and set operand illegal take illegal instruction trap tbls, tblsn table lookup and interpolate, jmp jump signed jsr jump to subroutine tblu, tblun table lookup and interpolate, lea load effective address unsigned link link and allocate trapcc trap conditionally (16 tests) lpstop low-power stop trapv trap on overflow lsl, lsr logical shift left and right tst test move move unlk unlink f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 7 5.1.7.1 table lookup and interpolate instructions. to maximize throughput for real-time applications, reference data is often ?articulated?and stored in memory for quick access. the storage of each data point would require an inordinate amount of memory. the table instruction requires only a sample of data points stored in the array, thus reducing memory requirements. intermediate values are recovered with this instruction via linear interpolation. the results may be rounded by a round-to-nearest algorithm. 5.1.7.2 low-power stop instruction. in applications where power consumption is a consideration, the cpu32 forces the device into a low-power standby mode when immediate processing is not required. the low-power stop mode is entered by executing the lpstop instruction. the processor will remain in this mode until a user-specified (or higher) interrupt level or reset occurs. 5.1.8 processing states the processor is always in one of four processing states: normal, exception, halted, or background. the normal processing state is that associated with instruction execution; the bus is used to fetch instructions and operands and to store results. the exception processing state is associated with interrupts, trap instructions, tracing, and other exception conditions. the exception may be internally generated explicitly by an instruction or by an unusual condition arising during the execution of an instruction. externally, exception processing can be forced by an interrupt, a bus error, or a reset. the halted processing state is an indication of catastrophic hardware failure. for example, if during the exception processing of a bus error another bus error occurs, the processor assumes that the system is unusable and halts. the background processing state is initiated by breakpoints, execution of special instructions, or a double bus fault. background processing allows interactive debugging of the system via a simple serial interface. refer to 5.4 processing states for details. 5.1.9 privilege states the processor operates at one of two levels of privilege?upervisor or user. the supervisor level has higher privileges than the user level. not all instructions are permitted to execute in the lower privileged user level, but all instructions are available at the supervisor level. this scheme allows the supervisor to protect system resources from uncontrolled access. the processor uses the privilege level indicated by the s-bit in the sr to select either the user or supervisor privilege level and either the user stack pointer (usp) or ssp for stack operations. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 8 mc68340 user? manual motorola 5.2 architecture summary the cpu32 is upward source- and object-code compatible with the mc68000 and mc68010. it is downward source- and object-code compatible with the mc68020. within the m68000 family, architectural differences are limited to the supervisory operating state. user state programs can be executed unchanged on upward-compatible devices. the major cpu32 features are as follows: 32-bit internal data path and arithmetic hardware 32-bit address bus supported by 32-bit calculations rich instruction set eight 32-bit general-purpose data registers seven 32-bit general-purpose address registers separate user and supervisor stack pointers separate user and supervisor state address spaces separate program and data address spaces many data types flexible addressing modes full interrupt processing expansion capability 5.2.1 programming model the cpu32 programming model consists of two groups of registers that correspond to the user and supervisor privilege levels. user programs can only use the registers of the user model. the supervisor programming model, which supplements the user programming model, is used by cpu32 system programmers who wish to protect sensitive operating system functions. the supervisor model is identical to that of mc68010 and later processors. the cpu32 has eight 32-bit data registers, seven 32-bit address registers, a 32-bit pc, separate 32-bit ssp and usp, a 16-bit sr, two alternate function code registers, and a 32-bit vbr (see figures 5-3 and 5-4). f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 9 31 16 15 8 7 0 d0 d1 d2 d3 data registers d4 d5 d6 d7 31 16 15 a0 a1 a2 a3 address registers a4 a5 a6 31 16 15 0 a7 (usp) user stack pointer 31 0 pc program counter 15 8 7 0 0 ccr condition code register figure 5-3. user programming model 31 16 15 0 a7' (ssp) supervisor stack pointer 15 8 7 0 (ccr) sr status register 31 0 pc program counter 31 3 2 0 sfc alternate function dfc code registers figure 5-4. supervisor programming model supplement f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 10 mc68340 user? manual motorola 5.2.2 registers registers d7?0 are used as data registers for bit, byte (8-bit), word (16-bit), long-word (32-bit), and quad-word (64-bit) operations. registers a6 to a0 and the usp and ssp are address registers that may be used as software sps or base address registers. register a7 (shown as a7 and a7' in figures 5-3 and 5-4) is a register designation that applies to the usp in the user privilege level and to the ssp in the supervisor privilege level. in addition, address registers may be used for word and long-word operations. all of the 16 general-purpose registers (d7?0, a7?0) may be used as index registers. the pc contains the address of the next instruction to be executed by the cpu32. during instruction execution and exception processing, the processor automatically increments the contents of the pc or places a new value in the pc, as appropriate. the sr (see figure 5-5) contains condition codes, an interrupt priority mask (three bits), and three control bits. condition codes reflect the results of a previous operation. the codes are contained in the low byte (ccr) of the sr. the interrupt priority mask determines the level of priority an interrupt must have to be acknowledged. the control bits determine trace mode and privilege level. at user privilege level, only the ccr is available. at supervisor privilege level, software can access the full sr. the vbr contains the base address of the exception vector table in memory. the displacement of an exception vector is added to the value in this register to access the vector table. alternate source and destination function code registers (sfc and dfc) contain 3-bit function codes. the cpu32 generates a function code each time it accesses an address. specific codes are assigned to each type of access. the codes can be used to select eight dedicated 4-gbyte address spaces. the movec instruction can use registers sfc and dfc to specify the function code of a memory address. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 t1 t0 s 0 0 i2 i1 i0 0 0 0 x n z v c extend negative zero overflow carry interrupt priority mask supervisor/user state trace enable system byte user byte (condition code register) figure 5-5. status register f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 11 5.3 instruction set the following paragaphs describe the set of instructions provided in the cpu32 and demonstrate their use. descriptions of the instruction format and the operands used by instructions are included. after a summary of the instructions by category, a detailed description of each instruction is listed in alphabetical order. complete programming information is provided, as well as a description of condition code computation and an instruction format summary. the cpu32 instructions include machine functions for all the following operations: data movement arithmetic operations logical operations shifts and rotates bit manipulation conditionals and branches system control the large instruction set encompasses a complete range of capabilities and, combined with the enhanced addressing modes, provides a flexible base for program development. 5.3.1 m68000 family compatibility it is the philosophy of the m68000 family that all user-mode programs can execute unchanged on a more advanced processor and that supervisor-mode programs and exception handlers should require only minimal alteration. the cpu32 can be thought of as an intermediate member of the m68000 family. object code from an mc68000 or mc68010 may be executed on the cpu32, and many of the instruction and addressing mode extensions of the mc68020 are also supported. 5.3.1.1 new instructions. two instructions have been added to the m68000 instruction set for use in embedded control applications: lpstop and table lookup and interpolation (tbl). 5.3.1.1.1 low-power stop (lpstop). in applications where power consumption is a consideration, the cpu32 can force the device into a low-power standby mode when immediate processing is not required. the low-power mode is entered by executing the lpstop instruction. the processor remains in this mode until a user-specified or higher level interrupt or a reset occurs. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 12 mc68340 user? manual motorola 5.3.1.1.2 table lookup and interpolation (tbl). to maximize throughput for real-time applications, reference data is often precalculated and stored in memory for quick access. the storage of sufficient data points can require an inordinate amount of memory. the tbl instruction uses linear interpolation to recover intermediate values from a sample of data points, and thus conserves memory. when the tbl instruction is executed, the cpu32 looks up two table entries bounding the desired result and performs a linear interpolation between them. byte, word, and long- word operand sizes are supported. the result can be rounded according to a round-to- nearest algorithm or returned unrounded along with the fractional portion of the calculated result (byte and word results only). this extra precision can be used to reduce cumulative error in complex calculations. see 5.3.4 using the tbl instructions for examples. 5.3.1.2 unimplemented instructions. the ability to trap on unimplemented instructions allows user-supplied code to emulate unimplemented capabilities or to define special-purpose functions. however, motorola reserves the right to use all currently unimplemented instruction operation codes for future m68000 enhancements. see 5.5.2.8 illegal or unimplemented instructions for more details. 5.3.2 instruction format and notation all instructions consist of at least one word. some instructions can have as many as seven words, as shown in figure 5-6. the first word of the instruction, called the operation word, specifies instruction length and the operation to be performed. the remaining words, called extension words, further specify the instruction and operands. these words may be immediate operands, extensions to the effective address mode specified in the operation word, branch displacements, bit number, special register specifications, trap operands, or argument counts. 15 0 operation word (one word, specifies operation and modes) special operand specifiers (if any, one or two words) immediate operand or source address extension (if any, one to three words) destination effective address extension (if any, one to three words) figure 5-6. instruction word general format f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 13 besides the operation code, which specifies the function to be performed, an instruction defines the location of every operand for the function. instructions specify an operand location in one of three ways: register specification a register field of the instruction contains the number of the register. effective address an effective address field of the instruction contains address mode information. implicit reference the definition of an instruction implies the use of specific registers. the register field within an instruction specifies the register to be used. other fields within the instruction specify whether the register is an address or data register and how it is to be used. the m68000pm/ad, m68000 family programmer? reference manual , contains detailed register information. except where noted, the following notation is used in this section: data immediate data from an instruction destination destination contents source source contents vector location of exception vector an any address register (a7?0) ax, ay address registers used in computation dn any data register (d7?0) rc control register (vbr, sfc, dfc) rn any address or data register dh, dl data registers, high- and low-order 32 bits of product dr, dq data registers, division remainder, division quotient dx, dy data registers, used in computation dym, dyn data registers, table interpolation values xn index register [an] address extension cc condition code d # displacement example: d 16 is a 16-bit displacement ea ? effective address # data ? immediate data; a literal integer label assembly program label list list of registers example: d3?0 [...] bits of an operand examples: [7] is bit 7; [31:24] are bits 31?4 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 14 mc68340 user? manual motorola (...) contents of a referenced location example: (rn) refers to the contents of rn ccr condition code register (lower byte of sr) x?xtend bit n?egative bit z?ero bit v?verflow bit c?arry bit pc program counter sp active stack pointer sr status register ssp supervisor stack pointer usp user stack pointer fc function code dfc destination function code register sfc source function code register + arithmetic addition or postincrement arithmetic subtraction or predecrement / arithmetic division or conjunction symbol arithmetic multiplication = equal to 1 not equal to > greater than 3 greater than or equal to < less than less than or equal to l logical and v logical or ? logical exclusive or ~ invert; operand is logically complemented bcd binary-coded decimal, indicated by subscript example: source 10 is a bcd source operand. lsw least significant word msw most significant word {r/w} read/write indicator in a description of an operation, a destination operand is placed to the right of source operands and is indicated by an arrow ( t). f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 15 5.3.3 instruction summary the instructions form a set of tools to perform the following operations: data movement bit manipulation integer arithmetic binary-coded decimal arithmetic logic program control shift and rotate system control the complete range of instruction capabilities combined with the addressing modes described previously provide flexibility for program development. all cpu32 instructions are summarized in table 5-2. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 16 mc68340 user? manual motorola table 5-2. instruction set summary opcode operation syntax abcd source 10 + destination 10 + x t destination abcd dy,dx abcd ?ay),?ax) add source + destination t destination add ea ? ,dn add dn, ea ? adda source + destination t destination adda ea ? ,an addi immediate data + destination t destination addi # data ?, ea ? addq immediate data + destination t destination addq # data ?, ea ? addx source + destination + x t destination addx dy,dx addx ?ay),?ax) and source l destination t destination and ea ?, dn and dn, ea ? andi immediate data l destination t destination andi # data ?, ea ? andi to ccr source l ccr t ccr andi # data ? ,ccr andi to sr if supervisor state the source l sr t sr else trap andi # data ? ,sr asl,asr destination shifted by count ? t destination asd dx,dy asd # data ? ,dy asd ea ? bcc if (condition true) then pc + d t pc bcc label ? bchg ~( number ? of destination) t z; ~( number ? of destination) t bit number ? of destination bchg dn, ea ? bchg # data ?, ea ? bclr ~( number ? of destination) t z; 0 t bit number ? of destination bclr dn, ea ? bclr # data ?, ea ? bgnd if (background mode enabled) then enter background mode else format/vector offset t ?ssp) pc t ?ssp) sr t ?ssp) (vector) t pc bgnd bkpt run breakpoint acknowledge cycle; trap as illegal instruction bkpt # data ? bra pc + d t pc bra label ? bset ~( number ? of destination) t z; 1 t bit number ? of destination bset dn, ea ? bset # data ?, ea ? bsr sp ?4 t sp; pc t (sp); pc + d t pc bsr label ? btst ?( number ? of destination) t z; btst dn, ea ? btst # data ?, ea ? chk if dn < 0 or dn > source then trap chk ea ? ,dn chk2 if rn < lower bound or if rn > upper bound then trap chk2 ea ? ,rn clr 0 t destination clr ea ? cmp destination ?source t cc cmp ea ? ,dn cmpa destination ?source cmpa ea ? ,an cmpi destination ?immediate data cmpi # data ?, ea ? cmpm destination ?source t cc cmpm (ay)+,(ax)+ f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 17 table 5-2. instruction set summary (continued) opcode operation syntax cmp2 compare rn < lower-bound or rn > upper-bound and set condition codes cmp2 ea ? ,rn dbcc if condition false then (dn ?1 t dn; if dn 1 ? then pc + d t pc) dbcc dn, label ? divs divsl destination/source t destination divs.w ea ? ,dn 32/16 t 16r:16q divs.l ea ? ,dq 32/32 t 32q divs.l ea ? ,dr:dq 64/32 t 32r:32q divsl.l ea ? ,dr:dq 32/32 t 32r:32q divu divul destination/source t destination divu.w ea ? ,dn 32/16 t 16r:16q divu.l ea ? ,dq 32/32 t 32q divu.l ea ? ,dr:dq 64/32 t 32r:32q divul.l ea ? ,dr:dq 32/32 t 32r:32q eor source ? destination t destination eor dn, ea ? eori immediate data ? destination t destination eori # data ?, ea ? eori to ccr source ? ccr t ccr eori # data ? ,ccr eori to sr if supervisor state the source ? sr t sr else trap eori # data ? ,sr exg rx ? ry exg dx,dy exg ax,ay exg dx,ay exg ay,dx ext extb destination sign-extended t destination ext.w dn extend byte to word ext.l dn extend word to long word extb.l dn extend byte to long word llegal ssp ?2 t ssp; vector offset t (ssp); ssp ?4 t ssp; pc t (ssp); ssp ?2 t ssp; sr t (ssp); illegal instruction vector address t pc illegal jmp destination address t pc jmp ea ? jsr sp? t sp; pc t (sp) destination address t pc jsr ea ? lea ea ? t an lea ea ? ,an link sp ?4 t sp; an t (sp) sp t an, sp + d t sp link an,# displacement ? lpstop if supervisor state immediate data t sr interrupt mask t external bus interface (ebi) stop else trap lpstop # data ? lsl,lsr destination shifted by count ? t destination lsd 1 dx,dy lsd 1 # data ? ,dy lsd 1 ea ? move source t destination move ea ?, ea ? movea source t destination movea ea ? ,an move from ccr ccr t destination move ccr, ea ? f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 18 mc68340 user? manual motorola table 5-2. instruction set summary (continued) opcode operation syntax move to ccr source t ccr move ea ? ,ccr move from sr if supervisor state then sr t destination else trap move sr, ea ? move to sr if supervisor state then source t sr else trap move ea ? ,sr move usp if supervisor state then usp t an or an t usp else trap move usp,an move an,usp movec if supervisor state then rc t rn or rn t rc else trap movec rc,rn movec rn,rc movem registers t destination source t registers movem register list, ea ? movem ea ? ,register list movep source t destination movep dx,(d,ay) movep (d,ay),dx moveq immediate data t destination moveq # data ? ,dn moves if supervisor state then rn t destination [dfc] or source [sfc] t rn else trap moves rn, ea ? moves ea ? ,rn muls source destination t destination muls.w ea ? ,dn 16 16 t 32 muls.l ea ? ,dl 32 32 t 32 muls.l ea ? ,dh:dl 32 32 t 64 mulu source destination t destination mulu.w ea ? ,dn 16 16 t 32 mulu.l ea ? ,dl 32 32 t 32 mulu.l ea ? ,dh:dl 32 32 t 64 nbcd 0 (destination 10 ) ?x t destination nbcd ea ? neg 0 ?(destination) t destination neg ea ? negx 0 (destination) ?x t destination negx ea ? nop none nop not ~destination t destination not ea ? or source v destination t destination or ea ? ,dn or dn, ea ? ori immediate data v destination t destination ori # data ? , ea ? ori to ccr source v ccr t ccr ori # data ? ,ccr ori to sr if supervisor state then source v sr t sr else trap ori # data ? ,sr pea sp ?4 t sp; ea ? t (sp) pea ea ? reset if supervisor state then assert reset else trap reset rol,ror destination rotated by count ?t destination rod 1 rx,dy rod 1 # data ? ,dy rod 1 ea ? f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 19 table 5-2. instruction set summary (concluded) opcode operation syntax roxl,roxr destination rotated with x by count ? t destination roxd 1 rx,dy roxd 1 # data ? ,dy roxd 1 ea ? rtd (sp) t pc; sp + 4 + d t sp rtd # displacement ? rte if supervisor state the (sp) t sr; sp + 2 t sp; (sp) t pc; sp + 4 t sp; restore state and deallocate stack according to (sp) else trap rte rtr (sp) t ccr; sp + 2 t sp; (sp) t pc; sp + 4 t sp rtr rts (sp) t pc; sp + 4 t sp rts sbcd destination 10 ?source 10 ?x t destination sbcd dx,dy sbcd ?ax),?ay) scc if condition true then 1s t destination else 0s t destination scc ea ? stop if supervisor state then immediate data t sr; stop else trap stop # data ? sub destination ?source t destination sub ea ? ,dn sub dn, ea ? suba destination ?source t destination suba ea ? ,an subi destination ?immediate data t destination subi # data ? , ea ? subq destination ?immediate data t destination subq # data ? , ea ? subx destination ?source ?x t destination subx dx,dy subx ?ax),?ay) swap register [31:16] ? register [15:0] swap dn tas destination tested t condition codes; 1 t bit 7 of destination tas ea ? tbls entry(n) + {(entry(n + 1) ?entry(n)) * d x[7:0]} / 256 t dx tbls. size ? ea ? , dx tbls. size ? dym:dyn, dx tblsn entry(n) 256 + {(entry(n + 1) ?entry(n)) * dx [7:0]} t dx tblsn. size ? ea ? ,dx tblsn. size ? dym:dyn, dx tblu entry(n) + {(entry(n + 1) ?entry(n)) * dx[7:0]} / 256 t dx tblu. size ? ea ? ,dx tblu. size ? dym:dyn, dx tblun entry(n) ?256 + {(entry(n + 1) ?entry(n)) dx[7:0]} t dx tblun. size ? ea ? ,dx tblun. size ? dym:dyn,dx trap ssp ?2 t ssp; format/offset t (ssp); ssp ?4 t ssp; pc t (ssp); ssp ?2 t ssp; sr t (ssp); vector address t pc trap # vector ? trapcc if cc then trap trapcc trapcc.w # data ? trapcc.l # data ? trapv if v then trap trapv tst destination tested t condition codes tst ea ? unlk an t sp; (sp) t an; sp + 4 t sp unlk an note 1: d is direction, l or r. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 20 mc68340 user? manual motorola 5.3.3.1 condition code register. the ccr portion of the sr contains five bits that indicate the result of a processor operation. table 5-3 lists the effect of each instruction on these bits. the carry bit and the multiprecision extend bit are separate in the m68000 family to simplify programming techniques that use them. refer to table 5-7 as an example. table 5-3. condition code computations operations x n z v c special definition abcd * u ? u ? c = decimal carry z = z l r ? l ... l r0 add, addi, addq * * * ? ? v = sm l dm l r ? v s ? l d ? l rm c = sm l dm v r ? l dm v sm l r ? addx * * ? ? ? v = sm l dm l r ? v s ? l d ? l rm c = sm l dm v r ? l dm v sm l r ? z = z l r ? l ... l r0 and, andi, eor, eori, moveq, move, or, ori, clr, ext, not, tas, tst * * 0 0 chk * u u u chk2, cmp2 u ? u ? z = (r = lb) v ( r = ub ) c = (lb < ub) l (ir < lb) v ( r > ub) v ( ub < lb) l (r > ub) l (r < lb) sub, subi, subq * * * ? ? v = s ? l dm l r ? v sm l d ? l rm c = sm l d ? v rm l d ? v sm l rm subx * * ? ? ? v = s ? l dm l r ? v sm l d ? l rm c = sm l d ? v rm l d ? v sm l rm z = z l r ? l ... l r0 cmp, cmpi, cmpm * * ? ? v = s ? l dm l r ? v sm l d ? l rm c = sm l d ? v rm l d ? v sm l rm divs, divu * * ? 0 v = division overflow muls, mulu * * ? 0 v = multiplication overflow sbcd, nbcd * u ? u ? c = decimal borrow z = z l r ? l ... l r0 neg * * * ? ? v = dm l rm c = dm v rm negx * * ? ? ? v = dm l rm c = dm v rm z = z l r ? l ... l r0 asl * * * ? ? v = dm l ( d ? ?1 v ... v d ? ? r ) v d ? l (dm? v ... + dm ?r) c = d ? ? r + 1 asl (r = 0) * * 0 0 lsl, roxl ***0?c = dm r + 1 lsr (r = 0) * * 0 0 roxl (r = 0) * * 0 ? c = x rol * * 0 ? c = dm ?r + 1 rol (r = 0) * * 0 0 asr, lsr, roxr ***0?c = dr 1 asr, lsr (r = 0) * * 0 0 roxr (r = 0) * * 0 ? c = x f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 21 table 5-3. condition code computations (continued) operations x n z v c special definition ror ** 0 ? c = dr ?1 ror (r = 0) ** 00 note : the following notations apply to this table only. = not affected sm = source operand msb u = undefined dm = destination operand msb ? = see special definition rm = result operand msb * = general case r = register tested x = c n = bit number n = rm r = shift count z= rm l ... l r0 lb = lower bound l= boolean and ub = upper bound v = boolean or rm = not rm 5.3.3.2 data movement instructions. the move instruction is the basic means of transferring and storing address and data. move instructions transfer byte, word, and long-word operands from memory to memory, memory to register, register to memory, and register to register. address movement instructions (move or movea) transfer word and long-word operands and ensure that only valid address manipulations are executed. in addition to the general move instructions, there are several special data movement instructions?ove multiple registers (movem), move peripheral data (movep), move quick (moveq), exchange registers (exg), load effective address (lea), push effective address (pea), link stack (link), and unlink stack (unlk). table 5-4 is a summary of the data movement operations. table 5-4. data movement operations instruction operand syntax operand size operation exg rn, rn 32 rn t rn lea ea ? , an 32 ea ? t an link an, # d ? 16, 32 sp 4 t sp, an t (sp); sp t an, sp + d t sp move ea ? , ea ? 8, 16, 32 source t destination movea ea ? , an 16, 32 t 32 source t destination movem list, ea ? ea ? , list 16, 32 16, 32 t 32 listed registers t destination source t listed registers movep dn, (d 16 , an) (d 16 , an), dn 16, 32 dn [31:24] t (an + d); dn [23:16] t (an + d + 2); dn [15:8] t (an + d + 4); dn [7:0] t (an + d + 6) (an + d) t dn [31:24]; (an + d + 2) t dn [23:16]; (an + d + 4) t dn [15:8]; (an + d + 6) t dn [7:0] moveq # data ?, dn 8 t 32 immediate data t destination pea ea ? 32 sp ?4 t sp; ea ? t sp unlk an 32 an t sp; (sp) t an, sp + 4 t sp f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 22 mc68340 user? manual motorola 5.3.3.3 integer arithmetic operations. the arithmetic operations include the four basic operations of add (add), subtract (sub), multiply (mul), and divide (div) as well as arithmetic compare (cmp, cmpm, cmp2), clear (clr), and negate (neg). the instruction set includes add, cmp, and sub instructions for both address and data operations with all operand sizes valid for data operations. address operands consist of 16 or 32 bits. the clear and negate instructions apply to all sizes of data operands. signed and unsigned mul and div instructions include: word multiply to produce a long-word product long-word multiply to produce a long-word or quad-word product division of a long-word dividend by a word divisor (word quotient and word remainder) division of a long-word or quad-word dividend by a long-word divisor (long-word quotient and long-word remainder) a set of extended instructions provides multiprecision and mixed-size arithmetic. these instructions are add extended (addx), subtract extended (subx), sign extend (ext), and negate binary with extend (negx). refer to table 5-5 for a summary of the integer arithmetic operations. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 23 table 5-5. integer arithmetic operations instruction operand syntax operand size operation add dn, ea ? ea ? , dn 8, 16, 32 8, 16, 32 source + destination t destination adda ea ? , an 16, 32 source + destination t destination addi # data ?, ea ? 8, 16, 32 immediate data + destination t destination addq # data ?, ea ? 8, 16, 32 immediate data + destination t destination addx dn, dn ?(an), ?(an) 8, 16, 32 8, 16, 32 source + destination + x t destination clr ea ? 8, 16, 32 0 t destination cmp ea ? , dn 8, 16, 32 (destination ?source), ccr shows results cmpa ea ? , an 16, 32 (destination ?source), ccr shows results cmpi # data ?, ea ? 8, 16, 32 (destination ?immediate data), ccr shows results cmpm (an) +, (an) + 8, 16, 32 (destination ?source), ccr shows results cmp2 ea ? , rn 8, 16, 32 lower bound rn upper bound, ccr shows results divs/divu divsl/divul ea ? , dn ea ? , dr:dq ea ? , dq ea ? , dr:dq 32/16 t 16:16 64/32 t 32:32 32/32 t 32 32/32 t 32:32 destination/source t destination (signed or unsigned) ext dn dn 8 t 16 16 t 32 sign extended destination t destination extb dn 8 t 32 sign extended destination t destination muls/mulu ea ? , dn ea ? , dl ea ? , dh:dl 16 16 t 32 32 32 t 32 32 32 t 64 source destination t destination (signed or unsigned) neg ea ? 8, 16, 32 0 ?destination t destination negx ea ? 8, 16, 32 0 ?destination ?x t destination sub ea ? , dn dn, ea ? 8, 16, 32 destination ?source t destination suba ea ? , an 16, 32 destination ?source t destination subi # data ?, ea ? 8, 16, 32 destination ?immediate data t destination subq # data ?, ea ? 8, 16, 32 destination ?immediate data t destination subx dn, dn ?(an), ?(an) 8, 16, 32 8, 16, 32 destination ?source ?x t destination tbls/tblu ea ? , dn dym:dyn, dn 8, 16, 32 dyn ?dym t temp (temp dn [7:0]) t temp (dym 256) + temp t dn tblsn/tblun ea ? , dn dym:dyn, dn 8, 16, 32 dyn ?dym t temp (temp dn [7:0]) / 256 t temp dym + temp t dn f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 24 mc68340 user? manual motorola 5.3.3.4 logic instructions. the logical operation instructions (and, or, eor, and not) perform logical operations with all sizes of integer data operands. a similar set of immediate instructions (andi, ori, and eori) provide these logical operations with all sizes of immediate data. the test (tst) instruction arithmetically compares the operand with zero, placing the result in the ccr. table 5-6 summarizes the logical operations. table 5-6. logic operations instruction operand syntax operand size operation and ea ? , dn dn, ea ? 8, 16, 32 8, 16, 32 source l destination t destination andi # data ?, ea ? 8, 16, 32 immediate data l destination t destination eor dn, ea ? 8, 16, 32 source ? destination t destination eori # data ?, ea ? 8, 16, 32 immediate data ? destination t destination not ea ? 8, 16, 32 destination t destination or ea ? , dn dn, ea ? 8, 16, 32 8, 16, 32 source v destination t destination ori # data ?, ea ? 8, 16, 32 immediate data v destination t destination tst ea ? 8, 16, 32 source ?0, to set condition codes 5.3.3.5 shift and rotate instructions. the arithmetic shift instructions, asr and asl, and logical shift instructions, lsr and lsl, provide shift operations in both directions. the ror, rol, roxr, and roxl instructions perform rotate (circular shift) operations, with and without the extend bit. all shift and rotate operations can be performed on either registers or memory. register shift and rotate operations shift all operand sizes. the shift count may be specified in the instruction operation word (to shift from 1 to 8 places) or in a register (modulo 64 shift count). memory shift and rotate operations shift word-length operands one bit position only. the swap instruction exchanges the 16-bit halves of a register. performance of shift/rotate instructions is enhanced so that use of the ror and rol instructions with a shift count of eight allows fast byte swapping. table 5-7 is a summary of the shift and rotate operations. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 25 table 5-7. shift and rotate operations instruction operand syntax operand size operation asl dn, dn # data ?, dn ea ? 8, 16, 32 8, 16, 32 16 x/c 0 asr dn, dn # data ?, dn ea ? 8, 16, 32 8, 16, 32 16 x/c lsl dn, dn # data ?, dn ea ? 8, 16, 32 8, 16, 32 16 x/c 0 lsr dn, dn # data ?, dn ea ? 8, 16, 32 8, 16, 32 16 x/c 0 rol dn, dn # data ?, dn ea ? 8, 16, 32 8, 16, 32 16 c ror dn, dn # data ?, dn ea ? 8, 16, 32 8, 16, 32 16 c roxl dn, dn # data ?, dn ea ? 8, 16, 32 8, 16, 32 16 x c roxr dn, dn # data ?, dn ea ? 8, 16, 32 8, 16, 32 16 x c swap dn 16 msw lsw 5.3.3.6 bit manipulation instructions. bit manipulation operations are accomplished using the following instructions: bit test (btst), bit test and set (bset), bit test and clear (bclr), and bit test and change (bchg). all bit manipulation operations can be performed on either registers or memory. the bit number is specified as immediate data or in a data register. register operands are 32 bits long, and memory operands are 8 bits long. table 5-8 is a summary of bit manipulation instructions. table 5-8. bit manipulation operations instruction operand syntax operand size operation bchg dn, ea ? # data ?, ea ? 8, 32 8, 32 ~( bit number ? of destination) t z t bit of destination bclr dn, ea ? # data ?, ea ? 8, 32 8, 32 ~( bit number ? of destination) t z; 0 t bit of destination bset dn, ea ? # data ?, ea ? 8, 32 8, 32 ~( bit number ? of destination) t z; 1 t bit of destination btst dn, ea ? # data ?, ea ? 8, 32 8, 32 ~ ( bit number ? of destination) t z f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 26 mc68340 user? manual motorola 5.3.3.7 binary-coded decimal (bcd) instructions. five instructions support operations on bcd numbers. the arithmetic operations on packed bcd numbers are add decimal with extend (abcd), subtract decimal with extend (sbcd), and negate decimal with extend (nbcd). table 5-9 is a summary of the bcd operations. table 5-9. binary-coded decimal operations instruction operand syntax operand size operation abcd dn, dn ?(an), ?(an) 8 8 source 10 + destination 10 + x t destination nbcd ea ? 8 8 0 ?destination 10 ?x t destination sbcd dn, dn ?(an), ?(an) 8 8 destination 10 ?source 10 ?x t destination 5.3.3.8 program control instructions. a set of subroutine call and return instructions and conditional and unconditional branch instructions perform program control operations. table 5-10 summarizes these instructions. table 5-10. program control operations instruction operand syntax operand size operation conditional bcc label ? 8, 16, 32 if condition true, then pc + d t pc dbcc dn , label ? 16 if condition false, then dn ?1 t pc; if dn 1 ( ?1), then pc + d t pc scc ea ? 8 if condition true, then destination bits are set to 1; else destination bits are cleared to 0 unconditional bra label ? 8, 16, 32 pc + d t pc bsr label ? 8, 16, 32 sp 4 t sp; pc t (sp); pc + d t pc jmp ea ? none destination t pc jsr ea ? none sp 4 t sp; pc t (sp); destination t pc nop none none pc + 2 t pc returns rtd # d ? 16 (sp) t pc; sp + 4 + d t sp rtr none none (sp) t ccr; sp + 2 t sp; (sp) t pc; sp + 4 t sp rts none none (sp) t pc; sp + 4 t sp f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 27 to specify conditions for change in program control, condition codes must be substituted for the letters "cc" in conditional program control opcodes. condition test mnemonics are given below. refer to 5.3.3.10 condition tests for detailed information on condition codes. cc carry clear ls low or same cs carry set lt less than eq equal mi minus f false * ne not equal ge greater or equal pl plus gt greater than t true hi high vc overflow clear le less or equal vs overflow set * not applicable to the bcc instruction 5.3.3.9 system control instructions. privileged instructions, trapping instructions, and instructions that use or modify the ccr provide system control operations. all of these instructions cause the processor to flush the instruction pipeline. table 5-11 summarizes the instructions. the preceding list of condition tests also applies to the trapcc instruction. refer to 5.3.3.10 condition tests for detailed information on condition codes. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 28 mc68340 user? manual motorola table 5-11. system control operations instruction operand syntax operand size operation privileged andi # data ? , sr 16 immediate data l sr t sr eori # data ? , sr 16 immediate data ? sr t sr move ea ? , sr sr, ea ? 16 16 source t sr sr t destination movea usp, an an, usp 32 32 usp t an an t usp movec rc, rn rn, rc 32 32 rc t rn rn t rc moves rn, ea ? ea ? , rn 8, 16, 32 rn t destination using dfc source using sfc t rn ori # data ? , sr 16 immediate data v sr t sr reset none none assert reset line rte none none (sp) t sr; sp + 2 t sp; (sp) t pc; sp + 4 t sp; restore stack according to format stop # data ? 16 immediate data t sr; stop lpstop # data ? none immediate data t sr; interrupt mask t ebi; stop trap generating bkpt # data ? none if breakpoint cycle acknowledged, then execute returned operation word, else trap as illegal instruction. bgnd none none if background mode enabled, then enter background mode, else format/vector offset t ?(ssp); pc t ?(ssp); sr t ?(ssp); (vector) t pc chk ea ? , dn 16, 32 if dn < 0 or dn < (ea), then chk exception chk2 ea ? , rn 8, 16, 32 if rn < lower bound or rn > upper bound, then chk exception illegal none none ssp ?2 t ssp; vector offset t (ssp); ssp ?4 t ssp; pc t (ssp); ssp ?2 t ssp; sr t (ssp); llegal instruction vector address t pc trap # data ? none ssp ?2 t ssp; format/vector offset t (ssp); ssp ?4 t ssp; pc t (ssp); sr t (ssp); vector address t pc trapcc none # data ? none 16, 32 if cc true, then trap exception trapv none none if v set, then overflow trap exception condition code register andi # data ?, ccr 8 immediate data l ccr t ccr eori # data ?, ccr 8 immediate data ? ccr t ccr move ea ? , ccr ccr, ea ? 16 16 source t ccr ccr t destination ori # data ?, ccr 8 immediate data v ccr t ccr f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 29 5.3.3.10 condition tests. conditional program control instructions and the trapcc instruction execute on the basis of condition tests. a condition test is the evaluation of a logical expression related to the state of the ccr bits. if the result is 1, the condition is true. if the result is 0, the condition is false. for example, the t condition is always true, and the eq condition is true only if the z-bit condition code is true. table 5-12 lists each condition test. table 5-12. condition tests mnemonic condition encoding test t true 0000 1 f * false 0001 0 hi high 0010 c z ls low or same 0011 c + z cc carry clear 0100 c cs carry set 0101 c ne not equal 0110 z eq equal 0111 z vc overflow clear 1000 v vs overflow set 1001 v pl plus 1010 n mi minus 1011 n ge greater or equal 1100 n v + n v lt less than 1101 n v + n v gt greater than 1110 n v z + n v z le less or equal 1111 z + n v + n v * not available for the bcc instruction. = boolean and + = boolean or n = boolean not 5.3.4 using the tbl instructions there are four tbl instructions. tbls returns a signed, rounded byte, word, or long-word result. tblsn returns a signed, unrounded byte, word, or long-word result. tblu returns an unsigned, rounded byte, word, or long-word result. tblun returns an unsigned, unrounded byte, word, or long-word result. all four instructions support two types of interpolation data: an n-element table stored in memory and a two-element range stored in a pair of data registers. the latter form provides a means of performing surface (3d) interpolation between two previously calculated linear interpolations. the following examples show how to compress tables and use fewer interpolation levels between table entries. example 1 (see figure 5-7) demonstrates tbl for a 257-entry table, allowing up to 256 interpolation levels between entries. example 2 (see figure 5-8) reduces table length for the same data to four entries. example 3 (see figure 5-9) demonstrates use of an 8-bit independent variable with an instruction. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 30 mc68340 user? manual motorola two additional examples show how tblsn can reduce cumulative error when multiple table lookup and interpolation operations are used in a calculation. example 4 demonstrates addition of the results of three table interpolations. example 5 illustrates use of tblsn in surface interpolation. 5.3.4.1 table example 1: standard usage. the table consists of 257 word entries. as shown in figure 5-7, the function is linear within the range 32768 x 49152. table entries within this range are as given in table 5-13 . table 5-13. standard usage entries entry number x value y value 128 * 32768 1311 162 41472 1659 163 41728 1669 164 41984 1679 165 42240 1690 192* 49152 1966 * these values are the end points of the range. all entries between these points fall on the line. x 16384 32768 49152 65536 independent variable dependent variable y figure 5-7. table example 1 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 31 the table instruction is executed with the following bit pattern in dx: 31 16 15 0 not used 1010001110000000 table entry offset t dx [8:15] = $a3 = 163 interpolation fraction t dx [0:7] = $80 = 128 using this information, the table instruction calculates dependent variable y: y = 1669 + (128 (1679 ?1669)) / 256 = 1674 5.3.4.2 table example 2: compressed table. in example 2 (see figure 5-8), the data from example 1 has been compressed by limiting the maximum value of the independent variable. instead of the range 0 x = 65535, x is limited to 0 x 1023. the table has been compressed to only five entries, but up to 256 levels of interpolation are allowed between entries. x 256 512 786 1024 independent variable dependent variable y figure 5-8. table example 2 note extreme table compression with many levels of interpolation is possible only with highly linear functions. the table entries within the range of interest are listed in table 5-14. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 32 mc68340 user? manual motorola table 5-14. compressed table entries entry number x value y value 2 512 1311 3 786 1966 since the table is reduced from 257 to 5 entries, independent variable x must be scaled appropriately. in this case the scaling factor is 64, and the scaling is done by a single instruction: lsr.w #6,dx thus, dx now contains the following bit pattern: 31 16 15 0 not used 0000001010001110 table entry offset t dx [8:15] = $02 = 2 interpolation fraction t dx [0:7] = $8e = 142 using this information, the table instruction calculates dependent variable y: y = 1331 + (142 (1966 ?1311)) / 256 = 1674 the function chosen for examples 1 and 2 is linear between data points. if another function had been been used, interpolated values might not have been identical. 5.3.4.3 table example 3: 8-bit independent variable. this example shows how to use a table instruction within an interpolation subroutine. independent variable x is calculated as an 8-bit value, allowing 16 levels of interpolation on a 17-entry table. x is passed to the subroutine, which returns an 8-bit result. the subroutine uses the data listed in table 5-15, based on the function shown in figure 5-9. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 33 y x 1024 2048 3072 4096 independent variable independent variable figure 5-9. table example 3 table 5-15. 8-bit independent variable entries x (subroutine) x (instruction) y 000 1 256 16 2 512 32 3 768 48 4 1024 64 5 1280 80 6 1536 96 7 1792 112 8 2048 128 9 2304 112 10 2560 96 11 2816 80 12 3072 64 13 3328 48 14 3584 32 15 3840 16 16 4096 0 the first column is the value passed to the subroutine, the second column is the value expected by the table instruction, and the third column is the result returned by the subroutine. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 34 mc68340 user? manual motorola the following value has been calculated for independent variable x: 31 16 15 0 not used 0000000010111101 since x is an 8-bit value, the upper four bits are used as a table offset and the lower four bits are used as an interpolation fraction. the following results are obtained from the subroutine: table entry offset t dx [4:7] = $b = 11 interpolation fraction t dx [0:3] = $d = 13 thus, y is calculated as follows: y = 80 + (13 (64 ?80)) / 16 = 67 if the 8-bit value for x were used directly by the table instruction, interpolation would be incorrectly performed between entries 0 and 1. data must be shifted to the left four places before use: lsl.w #4, dx the new range for x is 0 x 4096; however, since a left shift fills the least significant digits of the word with zeros, the interpolation fraction can only have one of 16 values. after the shift operation, dx contains the following value: 31 16 15 0 not used 000010111 1 010000 execution of the table instruction using the new value in dx yields: table entry offset t dx [8:15] = $0b = 11 interpolation fraction t dx [0:7] = $d0 = 208 thus, y is calculated as follows: y = 80 + (208 (64 ?80)) / 256 = 67 5.3.4.4 table example 4: maintaining precision. in this example, three tbl operations are performed and the results are summed. the calculation is done once with the result of each tbl rounded before addition and once with only the final result rounded. assume that the result of the three interpolations are as follows (a ".'' indicates the binary radix point). tbl # 1 0010 0000 . 0111 0000 tbl# 2 0011 1111 . 0111 0000 tbl # 3 0000 0001 . 0111 0000 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 35 first, the results of each tbl are rounded with the tbls round-to-nearest-even algorithm. the following values would be returned by tbls: tbl # 1 0010 0000 . tbl # 2 0011 1111 . tbl # 3 0000 0001 . summing, the following result is obtained: 0010 0000 . 0011 1111 . 0000 0001 . 0110 0000 . now, using the same tbl results, the sum is first calculated and then rounded according to the same algorithm: 0010 0000 . 0111 0000 0011 1111 . 0111 0000 0000 0001 . 0111 0000 0110 0001 . 0101 0000 rounding yields: 0110 0001 . the second result is preferred. the following code sequence illustrates how addition of a series of table interpolations can be performed without loss of precision in the intermediate results: l0: tblsn.b ea ?, dx tblsn.b ea ?, dx tblsn.b ea ?, dl add.l dx, dm long addition avoids problems with carry add.l dm, dl asr.l #8, dl move radix point bcc.b l1 fraction msb in carry addq.b #1, dl l1: . . . f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 36 mc68340 user? manual motorola 5.3.4.5 table example 5: surface interpolations. the various forms of table can be used to perform surface (3d) tbls. however, since the calculation must be split into a series of 2d tbls, the possibility of losing precision in the intermediate results is possible. the following code sequence, incorporating both tbls and tblsn, eliminates this possibility. l0: move.w dx, dl copy entry number and fraction number tblsn.b ea ? , dx tblsn.b ea ?, dl tbls.w dx:dl, dm surface interpolation, with round asr.l #8, dm read just the result bcc.b l1 no round necessary addq.b #1, dl half round up l1: . . . before execution of this code sequence, dx must contain fraction and entry numbers for the two tbl, and dm must contain the fraction for surface interpolation. the ea ? fields in the tblsn instructions point to consecutive columns in a 3d table. the tbls size parameter must be word if the tblsn size parameter is byte, and must be long word if tblsn is word. increased size is necessary because a larger number of significant digits is needed to accommodate the scaled fractional results of the 2d tbl. 5.3.5 nested subroutine calls the link instruction pushes an address onto the stack, saves the stack address at which the address is stored, and reserves an area of the stack for use. using this instruction in a series of subroutine calls will generate a linked list of stack frames. the unlk instruction removes a stack frame from the end of the list by loading an address into the sp and pulling the value at that address from the stack. when the instruction operand is the address of the link address at the bottom of a stack frame, the effect is to remove the stack frame from both the stack and the linked list. 5.3.6 pipeline synchronization with the nop instruction although the no operation (nop) instruction performs no visible operation, it does force synchronization of the instruction pipeline, since all previous instructions must complete execution before the nop begins. 5.4 processing states this section describes the processing states of the cpu32. it includes a functional description of the bits in the supervisor portion of the sr and an overview of actions taken by the processor in response to exception conditions. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 37 5.4.1 state transitions the processor is in normal, background, or exception state unless halted. when the processor fetches instructions and operands or executes instructions, it is in the normal processing state. the stopped condition, which the processor enters when a stop or lpstop instruction is executed, is a variation of the normal state in which no further bus cycles are generated. background state is an alternate operational mode used for system debugging. refer to 5.6 development support for more information. exception processing refers specifically to the transition from normal processing of a program to normal processing of system routines, interrupt routines, and other exception handlers. exception processing includes the stack operations, the exception vector fetch, and the filling of the instruction pipeline caused by an exception. exception processing ends when execution of an exception handler routine begins. refer to 5.5 exception processing for comprehensive information. a catastrophic system failure occurs if the processor detects a bus error or generates an address error while in the exception processing state. this type of failure halts the processor. for example, if a bus error occurs during exception processing caused by a bus error, the cpu32 assumes that the system is not operational and halts. the halted condition should not be confused with the stopped condition. after the processor executes a stop or lpstop instruction, execution of instructions can resume when a trace, interrupt, or reset exception occurs. 5.4.2 privilege levels to protect system resources, the processor can operate with either of two levels of access?ser or supervisor. supervisor level is more privileged than user level. all instructions are available at the supervisor level, but execution of some instructions is not permitted at the user level. there are separate sps for each level. the s-bit in the sr indicates privilege level and determines which sp is used for stack operations. the processor identifies each bus access (supervisor or user mode) via function codes to enforce supervisor and user access levels. in a typical system, most programs execute at the user level. user programs can access only their own code and data areas and are restricted from accessing other information. the operating system executes at the supervisor privilege level, has access to all resources, performs the overhead tasks for the user level programs, and coordinates their activities. 5.4.2.1 supervisor privilege level. if the s-bit in the sr is set, supervisor privilege level applies, and all instructions are executable. the bus cycles generated for instructions executed in supervisor level are normally classified as supervisor references, and the values of the function codes on fc2?c0 refer to supervisor address spaces. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 38 mc68340 user? manual motorola all exception processing is performed at the supervisor level. all bus cycles generated during exception processing are supervisor references, and all stack accesses use the ssp. instructions that have important system effects can only be executed at supervisor level. for instance, user programs are not permitted to execute stop, lpstop, or reset instructions. to prevent a user program from gaining privileged access, except in a controlled manner, instructions that can alter the s-bit in the sr are privileged. the trap #n instruction provides controlled user access to operating system services. 5.4.2.2 user privilege level. if the s-bit in the sr is cleared, the processor executes instructions at the user privilege level. the bus cycles for an instruction executed at the user privilege level are classified as user references, and the values of the function codes on fc2?c0 specify user address spaces. while the processor is at the user level, implicit references to the system sp and explicit references to address register seven (a7) refer to the usp. 5.4.2.3 changing privilege level. to change from user privilege level to supervisor privilege level, a condition that causes exception processing must occur. when exception processing begins, the current values in the sr, including the s-bit, are saved on the supervisor stack, and then the s-bit is set to enable supervisory access. execution continues at supervisor privilege level until exception processing is complete. to return to user access level, a system routine must execute one of the following instructions: move to sr, andi to sr, eori to sr, ori to sr, or rte. these instructions execute only at supervisor privilege level and can modify the s-bit of the sr. after these instructions execute, the instruction pipeline is flushed, then refilled from the appropriate address space. the rte instruction causes a return to a program that was executing when an exception occurred. when rte is executed, the exception stack frame saved on the supervisor stack can be restored in either of two ways. if the frame was generated by an interrupt, breakpoint, trap, or instruction exception, the sr and pc are restored to the values saved on the supervisor stack, and execution resumes at the restored pc address, with access level determined by the s-bit of the restored sr. if the frame was generated by a bus error or an address error exception, the entire processor state is restored from the stack. 5.5 exception processing an exception is a special condition that preempts normal processing. exception processing is the transition from normal mode program execution to execution of a routine that deals with an exception. the following paragraphs discuss system resources related to exception handling, exception processing sequence, and specific features of individual exception processing routines. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 39 5.5.1 exception vectors an exception vector is the address of a routine that handles an exception. the vbr contains the base address of a 1024-byte exception vector table, which consists of 256 exception vectors. sixty-four vectors are defined by the processor, and 192 vectors are reserved for user definition as interrupt vectors. except for the reset vector which is two long words, each vector in the table is one long word. refer to table 5-16 for information on vector assignment. table 5-16. exception vector assignments vector offset vector number dec hex space assignment 0 0 000 sp reset: initial stack pointer 1 4 004 sp reset: initial program counter 2 8 008 sd bus error 3 12 00c sd address error 4 16 010 sd illegal instruction 5 20 014 sd zero division 6 24 018 sd chk, chk2 instructions 7 28 01c sd trapcc, trapv instructions 8 32 020 sd privilege violation 9 36 024 sd trace 10 40 028 sd line 1010 emulator 11 44 02c sd line 1111 emulator 12 48 030 sd hardware breakpoint 13 52 034 sd (reserved for coprocessor protocol violation) 14 56 038 sd format error 15 60 03c sd uninitialized interrupt 16?3 64 92 040 05c sd (unassigned, reserved) 24 96 060 sd spurious interrupt 25 100 064 sd level 1 interrupt autovector 26 104 068 sd level 2 interrupt autovector 27 108 06c sd level 3 interrupt autovector 28 112 070 sd level 4 interrupt autovector 29 116 074 sd level 5 interrupt autovector 30 120 078 sd level 6 interrupt autovector 31 124 07c sd level 7 interrupt autovector 32?7 128 188 080 0bc sd trap instruction vectors (0?5) 48?8 192 232 0c0 0e8 sd (reserved for coprocessor) 59?3 236 252 0ec 0fc sd (unassigned, reserved) 64?55 256 1020 100 3fc sd user-defined vectors (192) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 40 mc68340 user? manual motorola caution because there is no protection on the 64 processor-defined vectors, external devices can access vectors reserved for internal purposes. this practice is strongly discouraged. all exception vectors, except the reset vector, are located in supervisor data space. the reset vector is located in supervisor program space. only the initial reset vector is fixed in the processor memory map. when initialization is complete, there are no fixed assignments. since the vbr stores the vector table base address, the table can be located anywhere in memory. it can also be dynamically relocated for each task executed by an operating system. each vector is assigned an 8-bit number. vector numbers for some exceptions are obtained from an external device; others are supplied by the processor. the processor multiplies the vector number by 4 to calculate vector offset, then adds the offset to the contents of the vbr. the sum is the memory address of the vector. 5.5.1.1 types of exceptions. an exception can be caused by internal or external events. an internal exception can be generated by an instruction or by an error. the trap, trapcc, trapv, bkpt, chk, chk2, rte, and div instructions can cause exceptions during normal execution. illegal instructions, instruction fetches from odd addresses, word or long-word operand accesses from odd addresses, and privilege violations also cause internal exceptions. sources of external exception include interrupts, breakpoints, bus errors, and reset requests. interrupts are peripheral device requests for processor action. breakpoints are used to support development equipment. bus error and reset are used for access control and processor restart. 5.5.1.2 exception processing sequence. for all exceptions other than a reset exception, exception processing occurs in the following sequence. refer to 5.5.2.1 reset for details of reset processing. as exception processing begins, the processor makes an internal copy of the sr. after the copy is made, the processor state bits in the sr are changed?he s-bit is set, establishing supervisor access level, and bits t1 and t0 are cleared, disabling tracing. for reset and interrupt exceptions, the interrupt priority mask is also updated. next, the exception number is obtained. for interrupts, the number is fetched from cpu space $f (the bus cycle is an interrupt acknowledge). for all other exceptions, internal logic provides a vector number. next, current processor status is saved. an exception stack frame is created and placed on the supervisor stack. all stack frames contain copies of the sr and the pc for use by rte. the type of exception and the context in which the exception occurs determine what other information is stored in the stack frame. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 41 finally, the processor prepares to resume normal execution of instructions. the exception vector offset is determined by multiplying the vector number by 4, and the offset is added to the contents of the vbr to determine displacement into the exception vector table. the exception vector is loaded into the pc. if no other exception is pending, the processor will resume normal execution at the new address in the pc. 5.5.1.3 exception stack frame. during exception processing, the most volatile portion of the current context is saved on the top of the supervisor stack. this context is organized in a format called the exception stack frame. the exception stack frame always includes the contents of sr and pc at the time the exception occurred. to support generic handlers, the processor also places the vector offset in the exception stack frame and marks the frame with a format code. the format field allows an rte instruction to identify stack information so that it can be properly restored. the general form of the exception stack frame is illustrated in figure 5-10. although some formats are peculiar to a particular m68000 family processor, format 0000 is always legal and always indicates that only the first four words of a frame are present. see 5.5.4 cpu32 stack frames for a complete discussion of exception stack frames. status register program counter low format vector offset other processor state information, depending on exception (0, 2, or 8 words) program counter high higher addresses sp stacking order 15 0 figure 5-10. exception stack frame 5.5.1.4 multiple exceptions. each exception has been assigned a priority based on its relative importance to system operation. priority assignments are shown in table 5-17. group 0 exceptions have the highest priorities; group 4 exceptions have the lowest priorities. exception processing for exceptions that occur simultaneously is done by priority, from highest to lowest. it is important to be aware of the difference between exception processing mode and execution of an exception handler. each exception has an assigned vector that points to an associated handler routine. exception processing includes steps described in 5.5.1.2 exception processing sequence , but does not include execution of handler routines, which is done in normal mode. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 42 mc68340 user? manual motorola when the cpu32 completes exception processing, it is ready to begin either exception processing for a pending exception or execution of a handler routine. priority assignment governs the order in which exception processing occurs, not the order in which exception handlers are executed. table 5-17. exception priority groups group/ priority exception and relative priority characteristics 0 reset aborts all processing (instruction or exception); does not save old context. 1.1 1.2 address error bus error suspends processing (instruction or exception); saves internal context. 2 bkpt#n, chk, chk2, division by zero, rte, trap#n, trapcc, trapv exception processing is a part of instruction execution. 3 illegal instruction, line a, unimplemented line f, privilege violation exception processing begins before instruction execution. 4.1 4.2 4.3 trace hardware breakpoint interrupt exception processing begins when current instruction or previous exception processing is complete. as a general rule, when simultaneous exceptions occur, the handler routines for lower priority exceptions are executed before the handler routines for higher priority exceptions. for example, consider the arrival of an interrupt during execution of a trap instruction, while tracing is enabled. trap exception processing (2) is done first, followed immediately by exception processing for the trace (4.1), and then by exception processing for the interrupt (4.3). each exception places a new context on the stack. when the processor resumes normal instruction execution, it is vectored to the interrupt handler, which returns to the trace handler that returns to the trap handler. there are special cases to which the general rule does not apply. the reset exception will always be the first exception handled since reset clears all other exceptions. it is also possible for high-priority exception processing to begin before low-priority exception processing is complete. for example, if a bus error occurs during trace exception processing, the bus error will be processed and handled before trace exception processing is completed. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 43 5.5.2 processing of specific exceptions the following paragraphs provide details concerning sources of specific exceptions, how each arises, and how each is processed. 5.5.2.1 reset. assertion of reset by external hardware or assertion of the internal reset signal by an internal module causes a reset exception. the reset exception has the highest priority of any exception. reset is used for system initialization and for recovery from catastrophic failure. the reset exception aborts any processing in progress when it is recognized, and that processing cannot be recovered. reset performs the following operations: 1. clears t0 and t1 in the sr to disable tracing 2. sets the s-bit in the sr to establish supervisor privilege 3. sets the interrupt priority mask to the highest priority level (%111) 4. initializes the vbr to zero ($00000000) 5. generates a vector number to reference the reset exception vector 6. loads the first long word of the vector into the interrupt sp 7. loads the second long word of the vector into the pc 8. fetches and initiates decode of the first instruction to be executed figure 5-11 is a flowchart of the reset exception after initial instruction prefetches, normal program execution begins at the address in the pc. the reset exception does not save the value of either the pc or the sr. if a bus error or address error occurs during reset exception processing sequence, a double bus fault occurs, the processor halts, and the halt signal is asserted to indicate the halted condition. execution of the reset instruction does not cause a reset exception nor does it affect any internal cpu register. the sim40 registers and the mcr in each internal peripheral module (dma, timers, and serial modules) are not affected. all other internal peripheral module registers are reset the same as for a hardware reset. the external devices connected to the reset signal are reset at the completion of the reset instruction. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 44 mc68340 user? manual motorola . . entry fetch vector # 0 1 s 0 t0,t1 $7 i2:i0 $0 vbr fetch vector # 1 bus error otherwise sp (vector # 0) bus error prefetch 3 words bus error/ address error otherwise begin instruction execution exit (double bus fault ) assert halt exit ? otherwise pc (vector # 1) ? ? ? ? ? figure 5-11. reset operation flowchart f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 45 5.5.2.2 bus error. a bus error exception occurs when an assertion of the berr signal is acknowledged. the berr signal can be asserted by one of three sources: 1. external logic by assertion of the berr input pin 2. direct assertion of the internal berr signal by an internal module 3. direct assertion of the internal berr signal by the on-chip hardware watchdog after detecting a no-response condition bus error exception processing begins when the processor attempts to use information from an aborted bus cycle. when the aborted bus cycle is an instruction prefetch, the processor will not initiate exception processing unless the prefetched information is used. for example, if a branch instruction flushes an aborted prefetch, that word is not accessed, and no exception occurs. when the aborted bus cycle is a data access, the processor initiates exception processing immediately, except in the case of released operand writes. released write bus errors are delayed until the next instruction boundary or until another operand access is attempted. exception processing for bus error exceptions follows the regular sequence, but context preservation is more involved than for other exceptions because a bus exception can be initiated while an instruction is executing. several bus error stack format organizations are utilized to provide additional information regarding the nature of the fault. first, any register altered by a faulted-instruction ea calculation is restored to its initial value. then a special status word (ssw) is placed on the stack. the ssw contains specific information about the aborted access?ize, type of access (read or write), bus cycle type, and function code. finally, fault address, bus error exception vector number, pc value, and a copy of the sr are saved. if a bus error occurs during exception processing for a bus error, an address error, a reset, or while the processor is loading stack information during rte execution, the processor halts. this simplifies isolation of catastrophic system failure by preventing processor interaction with stacks and memory. only assertion of reset can restart a halted processor. 5.5.2.3 address error. address error exceptions occur when the processor attempts to access an instruction, word operand, or long-word operand at an odd address. the effect is much the same as an internally generated bus error. the exception processing sequence is the same as that for bus error, except that the vector number refers to the address error exception vector. address error exception processing begins when the processor attempts to use information from the aborted bus cycle. if the aborted cycle is a data space access, exception processing begins when the processor attempts to use the data, except in the f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 46 mc68340 user? manual motorola case of a released operand write. released write exceptions are delayed until the next instruction boundary or attempted operand access. an address exception on a branch to an odd address is delayed until the pc is changed. no exception occurs if the branch is not taken. in this case, the fault address and return pc value placed in the exception stack frame are the odd address, and the current instruction pc points to the instruction that caused the exception. if an address error occurs during exception processing for a bus error, another address error, or a reset, the processor halts. 5.5.2.4 instruction traps. traps are exceptions caused by instructions. they arise from either processor recognition of abnormal conditions during instruction execution or from use of specific trapping instructions. traps are generally used to handle abnormal conditions that arise in control routines. the trap instruction, which always forces an exception, is useful for implementing system calls for user programs. the trapcc, trapv, chk, and chk2 instructions force exceptions when a program detects a run-time error. the divs and divu instructions force an exception if a division operation is attempted with a divisor of zero. exception processing for traps follows the regular sequence. if tracing is enabled when an instruction that causes a trap begins execution, a trace exception will be generated by the instruction, but the trap handler routine will not be traced (the trap exception will be processed first, then the trace exception). the vector number for the trap instruction is internally generated?art of the number comes from the instruction itself. the trap vector number, pc value, and a copy of the sr are saved on the supervisor stack. the saved pc value is the address of the instruction that follows the instruction that generated the trap. for all instruction traps other than trap, a pointer to the instruction causing the trap is also saved in the fifth and sixth words of the exception stack frame. 5.5.2.5 software breakpoints. to support hardware emulation, the cpu32 must provide a means of inserting breakpoints into target code and of announcing when a breakpoint is reached. the mc68000 and mc68008 can detect an illegal instruction inserted at a breakpoint when the processor fetches from the illegal instruction exception vector location. since the vbr on the cpu32 allows relocation of exception vectors, the exception vector address is not a reliable indication of a breakpoint. cpu32 breakpoint support is provided by extending the function of a set of illegal instructions ($4848?484f). when a breakpoint instruction is executed, the cpu32 performs a read from cpu space $0, at a location corresponding to the breakpoint number. if this bus cycle is terminated by berr , the processor performs illegal instruction exception processing. if the bus cycle is terminated by dsack ? , the processor uses the data returned to replace the breakpoint in the instruction pipeline and begins execution of that instruction. see section 3 bus operation for a description of cpu space operations. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 47 5.5.2.6 hardware breakpoints. the cpu32 recognizes hardware breakpoint requests. hardware breakpoint requests do not force immediate exception processing, but are left pending. an instruction breakpoint is not made pending until the instruction corresponding to the request is executed. a pending breakpoint can be acknowledged between instructions or at the end of exception processing. to acknowledge a breakpoint, the cpu performs a read from cpu space $0 at location $1e (see section 3 bus operation). if the bus cycle terminates normally, instruction execution continues with the next instruction, as if no breakpoint request occurred. if the bus cycle is terminated by berr , the cpu begins exception processing. data returned during this bus cycle is ignored. exception processing follows the regular sequence. vector number 12 (offset $30) is internally generated. the pc of the currently executing instruction, the pc of the next instruction to execute, and a copy of the sr are saved on the supervisor stack. 5.5.2.7 format error. the processor checks certain data values for control operations. the validity of the stack format code and, in the case of a bus cycle fault format, the version number of the processor that generated the frame are checked during execution of the rte instruction. this check ensures that the program does not make erroneous assumptions about information in the stack frame. if the format of the control data is improper, the processor generates a format error exception. this exception saves a four-word format exception frame and then vectors through vector table entry number 14. the stacked pc is the address of the rte instruction that discovered the format error. 5.5.2.8 illegal or unimplemented instructions. an instruction is illegal if it contains a word bit pattern that does not correspond to the bit pattern of the first word of a legal cpu32 instruction, if it is a movec instruction that contains an undefined register specification field in the first extension word, or if it contains an indexed addressing mode extension word with bits 5? = 00 or bits 3? 1 0000. if an illegal instruction is fetched during instruction execution, an illegal instruction exception occurs. this facility allows the operating system to detect program errors or to emulate instructions in software. word patterns with bits 15?2 = 1010 (referred to as a-line opcodes) are unimplemented instructions. a separate exception vector (vector 10, offset $28) is given to unimplemented instructions to permit efficient emulation. word patterns with bits 15?2 = 1111 (referred to as f-line opcodes) are used for m68000 family instruction set extensions. they can generate an unimplemented instruction exception caused by the first extension word of the instruction or by the addressing mode extension word. a separate f-line emulation vector (vector 11, offset $2c) is used for the exception vector. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 48 mc68340 user? manual motorola all unimplemented instructions are reserved for use by motorola for enhancements and extensions to the basic m68000 architecture. opcode pattern $4afc is defined to be illegal on all m68000 family members. those customers requiring the use of an unimplemented opcode for synthesis of "custom instructions," operating system calls, etc., should use this opcode. exception processing for illegal and unimplemented instructions is similar to that for traps. the instruction is fetched and decoding is attempted. when the processor determines that execution of an illegal instruction is being attempted, exception processing begins. no registers are altered. exception processing follows the regular sequence. the vector number is generated to refer to the illegal instruction vector or in the case of an unimplemented instruction, to the corresponding emulation vector. the illegal instruction vector number, current pc, and a copy of the sr are saved on the supervisor stack, with the saved value of the pc being the address of the illegal or unimplemented instruction. 5.5.2.9 privilege violations. to provide system security, certain instructions can be executed only at the supervisor access level. an attempt to execute one of these instructions at the user level will cause an exception. the privileged exceptions are as follows: and immediate to sr eor immediate to sr lpstop move from sr move to sr move usp movec moves or immediate to sr reset rte stop exception processing for privilege violations is nearly identical to that for illegal instructions. the instruction is fetched and decoded. if the processor determines that a privilege violation has occurred, exception processing begins before instruction execution. exception processing follows the regular sequence. the vector number (8) is generated to reference the privilege violation vector. privilege violation vector offset, current pc, and sr are saved on the supervisor stack. the saved pc value is the address of the first word of the instruction causing the privilege violation. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 49 5.5.2.10 tracing. to aid in program development, m68000 processors include a facility to allow tracing of instruction execution. cpu32 tracing also has the ability to trap on changes in program flow. in trace mode, a trace exception is generated after each instruction executes, allowing a debugging program to monitor the execution of a program under test. the t1 and t0 bits in the supervisor portion of the sr are used to control tracing. when t1?0 = 00, tracing is disabled, and instruction execution proceeds normally (see table 5-18). table 5-18. tracing control t1 t0 tracing function 0 0 no tracing 0 1 trace on change of flow 1 0 trace on instruction execution 1 1 undefined; reserved when t1?0 = 01 at the beginning of instruction execution, a trace exception will be generated if the pc changes sequence during execution. all branches, jumps, subroutine calls, returns, and sr manipulations can be traced in this way. no exception occurs if a branch is not taken. when t1?0 = 10 at the beginning of instruction execution, a trace exception will be generated when execution is complete. if the instruction is not executed, either because an interrupt is taken or because the instruction is illegal, unimplemented, or privileged, an exception is not generated. at the present time, t1?0 = 11 is an undefined condition. it is reserved by motorola for future use. exception processing for trace starts at the end of normal processing for the traced instruction and before the start of the next instruction. exception processing follows the regular sequence; tracing is disabled so that the trace exception itself is not traced. a vector number is generated to reference the trace exception vector. the address of the instruction that caused the trace exception, the trace exception vector offset, the current pc, and a copy of the sr are saved on the supervisor stack. the saved value of the pc is the address of the next instruction to be executed. a trace exception can be viewed as an extension to the function of any instruction. if a trace exception is generated by an instruction, the execution of that instruction is not complete until the trace exception processing associated with it is also complete. if an instruction is aborted by a bus error or address error exception, trace exception processing is deferred until the suspended instruction is restarted and completed normally. an rte from a bus error or address error will not be traced because of the possibility of continuing the instruction from the fault. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 50 mc68340 user? manual motorola if an instruction is executed and an interrupt is pending on completion, the trace exception is processed before the interrupt exception. if an instruction forces an exception, the forced exception is processed before the trace exception. if an instruction is executed and a breakpoint is pending upon completion of the instruction, the trace exception is processed before the breakpoint. if an attempt is made to execute an illegal, unimplemented, or privileged instruction while tracing is enabled, no trace exception will occur because the instruction is not executed. this is particularly important to an emulation routine that performs an instruction function, adjusts the stacked pc to beyond the unimplemented instruction, and then returns. the sr on the stack must be checked to determine if tracing is on before the return is executed. if tracing is on, trace exception processing must be emulated so that the trace exception handler can account for the emulated instruction. tracing also affects normal operation of the stop and lpstop instructions. if either instruction begins execution with t1 set, a trace exception will be taken after the instruction loads the sr. upon return from the trace handler routine, execution will continue with the instruction following stop (lpstop), and the processor will not enter the stopped condition. 5.5.2.11 interrupts. there are seven levels of interrupt priority and 192 assignable interrupt vectors within each exception vector table. careful use of multiple vector tables and hardware chaining will permit a virtually unlimited number of peripherals to interrupt the processor. interrupt recognition and subsequent processing are based on internal interrupt request signals ( irq7 irq1 ) and the current priority set in sr priority mask i2?0. interrupt request level zero ( irq7 irq1 negated) indicates that no service is requested. when an interrupt of level one through six is requested via irq6 irq1 , the processor compares the request level with the interrupt mask to determine whether the interrupt should be processed. interrupt requests are inhibited for all priority levels less than or equal to the current priority. level seven interrupts are nonmaskable. irq7 irq1 are synchronized and debounced by input circuitry on consecutive rising edges of the processor clock. to be valid, an interrupt request must be held constant for at least two consecutive clock periods. interrupt requests do not force immediate exception processing, but are left pending. a pending interrupt is detected between instructions or at the end of exception processing all interrupt requests must be held asserted until they are acknowledged by the cpu. if the priority of the interrupt is greater than the current priority level, exception processing begins. exception processing occurs as follows. first, the processor makes an internal copy of the sr. after the copy is made, the processor state bits in the sr are changed?he s-bit is set, establishing supervisor access level, and bits t1 and t0 are cleared, disabling f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 51 tracing. priority level is then set to the level of the interrupt, and the processor fetches a vector number from the interrupting device (cpu space $f). the fetch bus cycle is classified as an interrupt acknowledge, and the encoded level number of the interrupt is placed on the address bus. if an interrupting device requests automatic vectoring, the processor generates a vector number (25 to 31) determined by the interrupt level number. if the response to the interrupt acknowledge bus cycle is a bus error, the interrupt is taken to be spurious, and the spurious interrupt vector number (24) is generated. the exception vector number, pc, and sr are saved on the supervisor stack. the saved value of the pc is the address of the instruction that would have executed if the interrupt had not occurred. priority level 7 interrupt is a special case. level 7 interrupts are nonmaskable interrupts (nmi). level 7 requests are transition sensitive to eliminate redundant servicing and resultant stack overflow. transition sensitive means that the level 7 input must change state before the cpu will detect an interrupt. an nmi is generated each time the interrupt request level changes to level 7 (regardless of priority mask value), and each time the priority mask changes from 7 to a lower number while the request level remains at 7. many m68000 peripherals provide for programmable interrupt vector numbers to be used in the system interrupt request/acknowledge mechanism. if the vector number is not initialized after reset and if the peripheral must acknowledge an interrupt request, the peripheral should return the uninitialized interrupt vector number (15). see section 3 bus operation for detailed information on interrupt acknowledge cycles. 5.5.2.12 return from exception. when exception stacking operations for all pending exceptions are complete, the processor begins execution of the handler for the last exception processed. after the exception handler has executed, the processor must restore the system context in existence prior to the exception. the rte instruction is designed to accomplish this task. when rte is executed, the processor examines the stack frame on top of the supervisor stack to determine if it is valid and determines what type of context restoration must be performed. see 5.5.4 cpu32 stack frames for a description of stack frames. for a normal four-word frame, the processor updates the sr and pc with data pulled from the stack, increments the ssp by 8, and resumes normal instruction execution. for a six- word frame, the sr and pc are updated from the stack, the active ssp is incremented by 12, and normal instruction execution resumes. for a bus fault frame, the format value on the stack is first checked for validity. in addition, the version number on the stack must match the version number of the processor that is f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 52 mc68340 user? manual motorola attempting to read the stack frame. the version number is located in the most significant byte (bits 15?) of the internal register word at location sp + $14 in the stack frame. the validity check ensures that stack frame data will be properly interpreted in multiprocessor systems. if a frame is invalid, a format error exception is taken. if it is inaccessible, a bus error exception is taken. otherwise, the processor reads the entire frame into the proper internal registers, de-allocates the stack (12 words), and resumes normal processing. bus error frames for faults during exception processing require the rte instruction to rewrite the faulted stack frame. if an error occurs during any of the bus cycles required by rewrite, the processor halts. if a format error occurs during rte execution, the processor creates a normal four-word fault stack frame below the frame that it was attempting to use. if a bus error occurs, a bus-error stack frame will be created. the faulty stack frame remains intact, so that it may be examined and repaired by an exception handler or used by a different type of processor (e.g., mc68010, mc68020, or future m68000 processor) in a multiprocessor system. 5.5.3 fault recovery there are four phases of recovery from a fault: recognizing the fault, saving the processor state, repairing the fault (if possible), and restoring the processor state. saving and restoring the processor state are described in the following paragraphs. the stack contents are identified by the special status word (ssw). in addition to identifying the fault type represented by the stack frame, the ssw contains the internal processor state corresponding to the fault. 1514131211109876543210 tp mv 0 tr b1 b0 rr rm in rw lg siz func tp?err frame type mv?ovem in progress tr?race pending b1?reakpoint channel 1 pending b0?reakpoint channel 0 pending rr?erun write cycle after rte rm?aulted cycle was read-modify-write in?nstruction/other rw?ead/write of faulted bus cycle lg?riginal operand size was long word siz?emaining size of faulted bus cycle func?unction code of faulted bus cycle f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 53 the tp field defines the class of the faulted bus operation. two bus error exception frame types are defined. one is for faults on prefetch and operand accesses, and the other is for faults during exception frame stacking: 0 = operand or prefetch bus fault 1 = exception processing bus fault mv is set when the operand transfer portion of the movem instruction is in progress at the time of a bus fault. if a prefetch bus fault occurs while prefetching the movem opcode and extension word, both the mv and in bits will be set. 0 = movem was not in progress when fault occurred 1 = movem was in progress when fault occurred tr indicates that a trace exception was pending when a bus error exception was processed. the instruction that generated the trace will not be restarted upon return from the exception handler. this includes movem and released write bus errors indicated by the assertion of either mv or rr in the ssw. 0 = trace not pending 1 = trace pending b1 indicates that a breakpoint exception was pending on channel 1 (external breakpoint source) when a bus error exception was processed. pending breakpoint status is stacked, regardless of the type of bus error exception. 0 = breakpoint not pending 1 = breakpoint pending b0 indicates that a breakpoint exception was pending on channel 0 (internal breakpoint source) when the bus error exception was processed. pending breakpoint status is stacked, regardless of the type of bus error exception. 0 = breakpoint not pending 1 = breakpoint pending rr will be set if the faulted bus cycle was a released write. a released write is one that is overlapped. if the write is completed (rerun) in the exception handler, the rr bit should be cleared before executing rte. the bus cycle will be rerun if the rr bit is set upon return from the exception handler. 0 = faulted cycle was read, rmw, or unreleased write 1 = faulted cycle was a released write faulted rmw bus cycles set the rm bit. rm is ignored during unstacking. 0 = faulted cycle was non-rmw cycle 1 = faulted cycle was either the read or write of an rmw cycle instruction prefetch faults are distinguished from operand (both read and write) faults by the in bit. if in is cleared, the error was on an operand cycle; if in is set, the error was on an instruction prefetch. in is ignored during unstacking. 0 = operand 1 = prefetch f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 54 mc68340 user? manual motorola read and write bus cycles are distinguished by the rw bit. read bus cycles will set this bit, and write bus cycles will clear it. rw is reloaded into the bus controller if the rr bit is set during unstacking. 0 = faulted cycle was an operand write 1 = faulted cycle was a prefetch or operand read the lg bit indicates an original operand size of long word. lg is cleared if the original operand was a byte or word?iz will indicate original (and remaining) size. lg is set if the original was a long word?iz will indicate the remaining size at the time of fault. lg is ignored during unstacking. 0 = original operand size was byte or word 1 = original operand size was long word the ssw siz field shows operand size remaining when a fault was detected. this field does not indicate the initial size of the operand, nor does it necessarily indicate the proper status of a dynamically sized bus cycle. dynamic sizing occurs on the external bus and is transparent to the cpu. byte size is shown only when the original operand was a byte. the field is reloaded into the bus controller if the rr bit is set during unstacking. the siz field is encoded as follows: 00?ong word 01?yte 10?ord 11?nused, reserved the function code for the faulted cycle is stacked in the func field of the ssw, which is a copy of fc2?c0 for the faulted bus cycle. this field is reloaded into the bus controller if the rr bit is set during unstacking. all unused bits are stacked as zeros and are ignored during unstacking. further discussion of the ssw is included in 5.5.3.1 types of faults . 5.5.3.1 types of faults. an efficient implementation of instruction restart dictates that faults on some bus cycles be treated differently than faults on other bus cycles. the cpu32 defines four fault types: released write faults, faults during exception processing, faults during movem operand transfer, and faults on any other bus cycle. 5.5.3.1.1 type i?eleased write faults. cpu32 instruction pipelining can cause a final instruction write to overlap the execution of a following instruction. a write that is overlapped is called a released write. a released write fault occurs when a bus error or some other fault occurs on the released write. released write faults are taken at the next instruction boundary. the stacked pc is that of the next unexecuted instruction. if a subsequent instruction attempts an operand access while a released write fault is pending, the instruction is aborted and the write fault is acknowledged. this action prevents stale data from being used by the instruction. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 55 the ssw for a released write fault contains the following bit pattern: 15141312111098765432 0 000trb1b01000lg siz func tr, b1, and b0 are set if the corresponding exception is pending when the bus error exception is taken. status regarding the faulted bus cycle is reflected in the lg, siz, and func fields. the remainder of the stack contains the pc of the next unexecuted instruction, the current sr, the address of the faulted memory location, and the contents of the data buffer that was to be written to memory. this data is written on the stack in the format depicted in figure 5-15. when a released write fault exception handler executes, the machine will complete the faulted write and then continue executing instructions wherever the pc indicates. 5.5.3.1.2 type ii?refetch, operand, rmw, and movep faults. the majority of bus error exceptions are included in this category?ll instruction prefetches, all operand reads, all rmw cycles, and all operand accesses resulting from execution of movep (except the last write of a movep rn, ea ? or the last write of movem, which are type i faults). the tas, movep, and movem instructions account for all operand writes not considered released. all type ii faults cause an immediate exception that aborts the current instruction. any registers that were altered as the result of an ea calculation (i.e., postincrement or predecrement) are restored prior to processing the bus cycle fault. the ssw for faults in this category contains the following bit pattern: 15141312111098765432 0 0000b1b00rminrwlg siz func the trace pending bit is always cleared, since the instruction will be restarted upon return from the handler. saving a pending exception on the stack causes a trace exception to be taken prior to restarting the instruction. if the exception handler does not alter the stacked sr trace bits, the trace is requeued when the instruction is started. the breakpoint pending bits are stacked in the ssw, even though the instruction is restarted upon return from the handler. this avoids problems with bus state analyzer equipment that has been programmed to breakpoint only the first access to a specific location or to count accesses to that location. if this response is not desired, the exception handler can clear the bits before return. the rm, in, rw, lg, func, and siz fields all reflect the type of bus cycle that caused the fault. if the bus cycle was an rmw, the rm bit will be set, and the rw bit will show whether the fault was on a read or write. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 56 mc68340 user? manual motorola 5.5.3.1.3 type iii?aults during movem operand transfer. bus faults that occur as a result of movem operand transfer are classified as type iii faults. movem instruction prefetch faults are type ii faults. type iii faults cause an immediate exception that aborts the current instruction. none of the registers altered during execution of the faulted instruction are restored prior to execution of the fault handler. this includes any register predecremented as a result of the effective address calculation or any register overwritten during instruction execution. since postincremented registers are not updated until the end of an instruction, the register retains its pre-instruction value unless overwritten by operand movement. the ssw for faults in this category contains the following bit pattern: 15141312111098765432 0 0 1 0 tr b1 b0 rr 0 in rw lg siz func mv is set, indicating that movem should be continued from the point where the fault occurred upon return from the exception handler. tr, b1, and b0 are set if a corresponding exception is pending when the bus error exception is taken. in is set if a bus fault occurs while prefetching an opcode or an extension word during instruction restart. rw, lg, siz, and func all reflect the type of bus cycle that caused the fault. all write faults have the rr bit set to indicate that the write should be rerun upon return from the exception handler. the remainder of the stack frame contains sufficient information to continue movem with operand transfer following a faulted transfer. the address of the next operand to be transferred, incremented or decremented by operand size, is stored in the faulted address location ($08). the stacked transfer counter is set to 16 minus the number of transfers attempted (including the faulted cycle). refer to figure 5-12 for the stacking format. 5.5.3.1.4 type iv?aults during exception processing. the fourth type of fault occurs during exception processing. if this exception is a second address or bus error, the machine halts in the double bus fault condition. however, if the exception is one that causes a four- or six-word stack frame to be written, a bus cycle fault frame is written below the faulted exception stack frame. the ssw for a fault within an exception contains the following bit pattern: 15141312111098765432 0 100trb1b00001lg siz func tr, b1, and b0 are set if a corresponding exception is pending when the bus error exception is taken. the contents of the faulted exception stack frame are included in the bus fault stack frame. the pre-exception sr and the format/vector word of the faulted frame are stacked. the type of exception can be determined from the format/vector word. if the faulted exception stack frame contains six words, the pc of the instruction that caused the initial f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 57 exception is also stacked. this data is placed on the stack in the format shown in figure 5-13. the return address from the initial exception is stacked for rte . 5.5.3.2 correcting a fault. there are two ways to complete a faulted released write bus cycle. the first is to use a software handler. the second is to rerun the bus cycle via rte. type ii fault handlers must terminate with rte, but specific requirements must also be met before an instruction is restarted. there are three varieties of type iii operand fault recovery. the first is completion of an instruction in software. the second is conversion to type ii with restart via rte. the third is continuation from the fault via rte. 5.5.3.2.1 type i?ompleting released writes via software. to complete a bus cycle in software, a handler must first read the ssw function code field to determine the appropriate address space, access the fault address pointer on the stack, and then transfer data from the stacked image of the output buffer to the fault address. because the cpu32 has a 16-bit internal data bus, long operands require two bus accesses. a fault during the second access of a long operand causes the lg bit in the ssw to be set. the siz field indicates remaining operand size. if operand coherency is important, the complete operand must be rewritten. after a long operand is rewritten, the rr bit must be cleared. failure to clear the rr bit can cause the rte instruction to rerun the bus cycle. following rewrite, it is not necessary to adjust the pc (or other stack contents) before executing rte. 5.5.3.2.2 type i?ompleting released writes via rte. an exception handler can use the rte instruction to complete a faulted bus cycle. when rte executes, the fault address, data output buffer, pc, and sr are restored from the stack. any pending breakpoint or trace exceptions, as indicated by tr, b1, and b0 in the stacked ssw, are requeued during ssw restoration. the rr bit in the ssw is checked during the unstacking operation; if it is set, the rw, func, and siz fields are restored and the released write cycle is rerun. to maintain long-word operand coherence, stack contents must be adjusted prior to rte execution. the fault address must be decremented by 2 if lg is set and siz indicates a remaining byte or word. siz must be set to long. all other fields should be left unchanged. the bus controller uses the modified fault address and siz field to rerun the complete released write cycle. manipulating the stacked ssw can cause unpredictable results because rte checks only the rr bit to determine if a bus cycle must be rerun. inadvertent alteration of the control bits could cause the bus cycle to be a read instead of a write or could cause access to a different address space than the original bus cycle. if the rerun bus cycle is a read, returned data will be ignored. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 58 mc68340 user? manual motorola 5.5.3.2.3 type ii?orrecting faults via rte. instructions aborted because of a type ii fault are restarted upon return from the exception handler. a fault handler must establish safe restart conditions. if a fault is caused by a nonresident page in a demand-paged virtual memory configuration, the fault address must be read from the stack, and the appropriate page retrieved. an rte instruction terminates the exception handler. after unstacking the machine state, the instruction is refetched and restarted. 5.5.3.2.4 type iii?orrecting faults via software. sufficient information is contained in the stack frame to complete movem in software. after the cause of the fault is corrected, the faulted bus cycle must be rerun. perform the following procedures to complete an instruction through software: a. setup for rerun read the movem opcode and extension from locations pointed to by stackframe pc and pc + 2. the ea need not be recalculated since the next operand address is saved in the stack frame. however, the opcode ea field must be examined to determine how to update the address register and pc when the instruction is complete. adjust the mask to account for operands already transferred. subtract the stacked operand transfer count from 16 to obtain the number of operands transferred. scan the mask using this count value. each time a set bit is found, clear it and decrement the counter. when the count is zero, the mask is ready for use. adjust the operand address. if the predecrement addressing mode is in effect, subtract the operand size from the stacked value; otherwise, add the operand size to the stacked value. b. rerun instruction scan the mask for set bits. read/write the selected register from/to the operand address as each bit is found. as each operand is transferred, clear the mask bit and increment (decrement) the operand address. when all bits in the mask are cleared, all operands have been transferred. if the addressing mode is predecrement or postincrement, update the register to complete the execution of the instruction. if tr is set in the stacked ssw, create a six-word stack frame and execute the trace handler. if either b1 or b0 is set in the ssw, create another six-word stack frame and execute the hardware breakpoint handler. de-allocate the stack and return control to the faulted program. 5.5.3.2.5 type iii?orrecting faults by conversion and restart. in some situations it may be necessary to rerun all the operand transfers for a faulted instruction rather than continue from a faulted operand. clearing the mv bit in the stacked ssw converts a type iii fault into a type ii fault. consequently, movem, like all other type ii f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 59 exceptions, will be restarted upon return from the exception handler. when a fault occurs after an operand has transferred, that transfer is not "undone". however, these memory locations are accessed a second time when the instruction is restarted. if a register used in an ea calculation is overwritten before a fault occurs, an incorrect ea is calculated upon instruction restart. 5.5.3.2.6 type iii?orrecting faults via rte. the preferred method of movem bus fault recovery is to correct the cause of the fault and then execute an rte instruction without altering the stack contents. the rte recognizes that movem was in progress when a fault occurred, restores the appropriate machine state, refetches the instruction, repeats the faulted transfer, and continues the instruction. movem is the only instruction continued upon return from an exception handler. although the instruction is refetched, the ea is not recalculated, and the mask is rescanned the same number of times as before the fault; modifying the code prior to rte can cause unexpected results. 5.5.3.2.7 type iv?orrecting faults via software. bus error exceptions can occur during exception processing while the processor is fetching an exception vector or while it is stacking. the same stack frame and ssw are used in both cases, but each has a distinct fault address. the stacked faulted exception format/vector word identifies the type of faulted exception and the contents of the remainder of the frame. a fault address corresponding to the vector specified in the stacked format/vector word indicates that the processor could not obtain the address of the exception handler. a bus error exception handler should execute rte after correcting a fault. rte restores the internal machine state, fetches the address of the original exception handler, recreates the original exception stack frame, and resumes execution at the exception handler address. if the fault is intractable, the exception handler should rewrite the faulted exception stack frame at sp + $14 + $06 and then jump directly to the original exception handler. the stack frame can be generated from the information in the bus error frame: the pre- exception sr (sp + $0c), the format/vector word (sp + $0e), and, if the frame being written is a six-word frame, the pc of the instruction causing the exception (sp + $10). the return pc value is available at sp + $02. a stacked fault address equal to the current sp may indicate that, although the first exception received a bus error while stacking, the bus error exception stacking successfully completed. this occurrence is extremely improbable, but the cpu32 supports recovery from it. once the exception handler determines that the fault has been corrected, recovery can proceed as described previously. if the fault cannot be corrected, move the supervisor stack to another area of memory, copy all valid stack frames to the new stack, create a faulted exception frame on top of the stack, and resume execution at the exception handler address. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 60 mc68340 user? manual motorola 5.5.4 cpu32 stack frames the cpu32 generates three different stack frames: four-word frames, six-word frames, and twelve-word bus error frames. 5.5.4.1 four-word stack frame. this stack frame is created by interrupt, format error, trap #n, illegal instruction, a-line and f-line emulator trap, and privilege violation exceptions. depending on the exception type, the pc value is either the address of the next instruction to be executed or the address of the instruction that caused the exception (see figure 5-12). 15 0 sp t status register +$02 program counter high program counter low +$06 0000 vector offset figure 5-12. format $0?our-word stack frame 5.5.4.2 six-word stack frame. this stack frame (see figure 5-13) is created by instruction-related traps, which include chk, chk2, trapcc, trapv, and divide-by-zero, and by trace exceptions. the faulted instruction pc value is the address of the instruction that caused the exception. the next pc value (the address to which rte returns) is the address of the next instruction to be executed. 15 0 sp t status register +$02 next instruction program counter high next instruction program counter low +$06 0010 vector offset +$08 faulted instruction program counter high faulted instruction program counter low figure 5-13. format $2?ix-word stack frame hardware breakpoints also utilize this format. the faulted instruction pc value is the address of the instruction executing when the breakpoint was sensed. usually this is the address of the instruction that caused the breakpoint, but, because released writes can overlap following instructions, the faulted instruction pc may point to an instruction following the instruction that caused the breakpoint. the address to which rte returns is the address of the next instruction to be executed. 5.5.4.3 bus error stack frame. this stack frame is created when a bus cycle fault is detected. the cpu32 bus error stack frame differs significantly from the equivalent stack frames of other m68000 family members. the only internal machine state required in the cpu32 stack frame is the bus controller state at the time of the error and a single register. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 61 bus operation in progress at the time of a fault is conveyed by the ssw. 1514131211109876543210 tp mv 0 tr b1 b0 rr rm in rw lg siz func the bus error stack frame is 12 words in length. there are three variations of the frame, each distinguished by different values in the ssw tp and mv fields. an internal transfer count register appears at location sp + $14 in all bus error stack frames. the register contains an 8-bit microcode revision number, and, for type iii faults, an 8-bit transfer count. register format is shown in figure 5-14. 15 8 7 0 microcode revision number transfer count figure 5-14. internal transfer count register the microcode revision number is checked before a bus error stack frame is restored via rte. in a multiprocessor system, this check ensures that a processor using stacked information is at the same revision level as the processor that created it. the transfer count is ignored unless the mv bit in the stacked ssw is set. if the mv bit is set, the least significant byte of the internal register is reloaded into the movem transfer counter during rte execution. for faults occurring during normal instruction execution (both prefetches and non-movem operand accesses) ssw tp, mv = 00. stack frame format is shown in figure 5-15. faults that occur during the operand portion of the movem instruction are identified by ssw tp, mv = 01. stack frame format is shown in figure 5-16. when a bus error occurs during exception processing, ssw tp, mv = 10. the frame shown in figure 5-17 is written below the faulting frame. stacking begins at the address pointed to by sp ?6 (sp value is the value before initial stacking on the faulted frame). the frame can have either four or six words, depending on the type of error. four-word stack frames do not include the faulted instruction pc (the internal transfer count register is located at sp + $10 and the ssw is located at sp + $12). the fault address of a dynamically sized bus cycle is the address of the upper byte, regardless of the byte that caused the error. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 62 mc68340 user? manual motorola 15 0 sp t status register +$02 return program counter high return program counter low +$06 1100 vector offset +$08 faulted address high faulted address low +$0c dbuf high dbuf low +$10 current instruction program counter high current instruction program counter low +$14 internal transfer count register +$16 0 0 special status word figure 5-15. format $c?err stack for prefetches and operands 15 0 sp t status register +$02 return program counter high return program counter low +$06 1100 vector offset +$08 faulted address high faulted address low +$0c dbuf high dbuf low +$10 current instruction program counter high current instruction program counter low +$14 internal transfer count register +$16 0 1 special status word figure 5-16. format $c?err stack on movem operand f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 63 15 0 sp t status register +$02 next instruction program counter high next instruction program counter low +$06 1100 vector offset +$08 faulted address high faulted address low +$0c pre-exception status register faulted exception format/vector word +$10 faulted instruction program counter high (six word frame only) faulted instruction program counter low (six word frame only) +$14 internal transfer count register +$16 1 0 special status word figure 5-17. format $c?our- and six-word berr stack 5.6 development support all m68000 family members have the following special features that facilitate applications development. trace on instruction execution?ll m68000 processors include an instruction-by- instruction tracing facility to aid in program development. the mc68020, mc68030, and cpu32 can also trace those instructions that change program flow. in trace mode, an exception is generated after each instruction is executed, allowing a debugger program to monitor execution of a program under test. see 5.5.2.10 tracing for more information. breakpoint instruction?n emulator can insert software breakpoints into target code to indicate when a breakpoint occurs. on the mc68010, mc68020, mc68030, and cpu32, this function is provided via illegal instructions ($4848?484f) that serve as breakpoint instructions. see 5.5.2.5 software breakpoints for more information. unimplemented instruction emulation?hen an attempt is made to execute an illegal instruction, an illegal instruction exception occurs. unimplemented instructions (f-line, a- line) utilize separate exception vectors to permit efficient emulation of unimplemented instructions in software. see 5.5.2.8 illegal or unimplemented instructions for more information. 5.6.1 cpu32 integrated development support in addition to standard mc68000 family capabilities, the cpu32 has features to support advanced integrated system development. these features include background debug mode, deterministic opcode tracking, hardware breakpoints, and internal visibility in a single-chip environment. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 64 mc68340 user? manual motorola 5.6.1.1 background debug mode (bdm) overview . microprocessor systems generally provide a debugger, implemented in software, for system analysis at the lowest level. the bdm on the cpu32 is unique because the debugger is implemented in cpu microcode. bdm incorporates a full set of debug options?egisters can be viewed and/or altered, memory can be read or written, and test features can be invoked. a resident debugger simplifies implementation of an in-circuit emulator. in a common setup (see figure 5-18), emulator hardware replaces the target system processor. a complex, expensive pod-and-cable interface provides a communication path between target system and emulator. . .. in-circuit emulator target mcu target system figure 5-18. in-circuit emulator configuration by contrast, an integrated debugger supports use of a bus state analyzer (bsa) for in- circuit emulation. the processor remains in the target system (see figure 5-19), and the interface is simplified. the bsa monitors target processor operation and the on-chip debugger controls the operating environment. emulation is much closer to target hardware; thus, many interfacing problems (i.e., limitations on high-frequency operation, ac and dc parametric mismatches, and restrictions on cable length) are minimized. . target system target mcu bus state analyzer figure 5-19. bus state analyzer configuration 5.6.1.2 deterministic opcode tracking overview. cpu32 function code outputs are augmented by two supplementary signals that monitor the instruction pipeline. the ifetch output signal identifies bus cycles in which data is loaded into the pipeline and signals pipeline flushes. the ipipe output signal indicates when each mid-instruction pipeline advance occurs and when instruction execution begins. these signals allow a bsa to synchronize with instruction stream activity. refer to 5.6.3 deterministic opcode tracking for complete information. 5.6.1.3 on-chip hardware breakpoint overview. an external breakpoint input and an on-chip hardware breakpoint capability permit breakpoint trap on any f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 65 memory access. off-chip address comparators will not detect breakpoints on internal accesses unless show cycles are enabled. breakpoints on prefetched instructions, which are flushed from the pipeline before execution, are not acknowledged, but operand breakpoints are always acknowledged. acknowledged breakpoints can initiate either exception processing or bdm. see 5.5.2.6 hardware breakpoints for more information. 5.6.2 background debug mode bdm is an alternate cpu32 operating mode. during bdm, normal instruction execution is suspended, and special microcode performs debugging functions under external control. figure 5-20 is a bdm block diagram. bdm can be initiated in several ways?y externally generated breakpoints, by internal peripheral breakpoints, by the background instruction (bgnd), or by catastrophic exception conditions. while in bdm, the cpu32 ceases to fetch instructions via the parallel bus and communicates with the development system via a dedicated, high-speed, spi-type serial command interface. . . . . .. . sequencer microcode serial interface bus control irc berr bkpt execution unit ipipe/dso ifetch/dsi data bus berr bkpt/dsclk address bus irb berr bkpt ir berr bkpt freeze figure 5-20. bdm block diagram 5.6.2.1 enabling bdm. accidentally entering bdm in a nondevelopment environment could lock up the cpu32 since the serial command interface would probably not be available. for this reason, bdm is enabled during reset via the bkpt signal. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 66 mc68340 user? manual motorola bdm operation is enabled when bkpt is asserted (low) at the rising edge of reset . bdm remains enabled until the next system reset. a high bkpt on the trailing edge of reset disables bdm. bkpt is relatched on each rising transition of reset . bkpt is synchronized internally and must be held low for at least two clock cycles prior to negation of reset. bdm enable logic must be designed with special care. if hold time on bkpt (after the trailing edge of reset ) extends into the first bus cycle following reset, this bus cycle could be tagged with a breakpoint. refer to section 3 bus operation for timing information. 5.6.2.2 bdm sources. when bdm is enabled, any of several sources can cause the transition from normal mode to bdm. these sources include external bkpt hardware, the bgnd instruction, a double bus fault, and internal peripheral breakpoints. if bdm is not enabled when an exception condition occurs, the exception is processed normally. table 5-19 summarizes the processing of each source for both enabled and disabled cases. as depicted in the table, the bkpt instruction never causes a transition into bdm. table 5-19. bdm source summary source bdm enabled bdm disabled bkpt background breakpoint exception double bus fault background halted bgnd instruction background illegal instruction bkpt instruction opcode substitution/ illegal instruction opcode substitution/ illegal instruction 5.6.2.2.1 external bkpt signal. once enabled, bdm is initiated whenever assertion of bkpt is acknowledged. if bdm is disabled, a breakpoint exception (vector $0c) is acknowledged. the bkpt input has the same timing relationship to the data strobe trailing edge as does read cycle data. there is no breakpoint acknowledge bus cycle when bdm is entered. 5.6.2.2.2 bgnd instruction. an illegal instruction, $4afa, is reserved for use by development tools. the cpu32 defines $4afa (bgnd) to be a bdm entry point when bdm is enabled. if bdm is disabled, an illegal instruction trap is acknowledged. illegal instruction traps are discussed in 5.5.2.8 illegal or unimplemented instructions . 5.6.2.2.3 double bus fault. the cpu32 normally treats a double bus fault (two bus faults in succession) as a catastrophic system error and halts. when this condition occurs during initial system debug (a fault in the reset logic), further debugging is impossible until the problem is corrected. in bdm, the fault can be temporarily bypassed so that its origin can be isolated and eliminated. 5.6.2.3 entering bdm. when the processor detects a bkpt or a double bus fault or decodes a bgnd instruction, it suspends instruction execution and asserts the freeze output. freeze assertion is the first indication that the processor has entered bdm. once freeze has been asserted, the cpu enables the serial communication hardware and awaits a command. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 67 the cpu writes a unique value indicating the source of bdm transition into temporary register a (atemp) as part of the process of entering bdm. a user can poll atemp and determine the source (see table 5-20) by issuing a read system register command (rsreg). atemp is used in most debugger commands for temporary storage?t is imperative that the rsreg command be the first command issued after transition into bdm. table 5-20. polling the bdm entry source source atemp 31?6 atemp 15? double bus fault ssw* $ffff bgnd instruction $0000 $0001 hardware breakpoint $0000 $0000 *ssw is described in detail in 5.5.3 fault recovery. a double bus fault during initial sp/pc fetch sequence is distinguished by a value of $ffffffff in the current instruction pc. at no other time will the processor write an odd value into this register. 5.6.2.4 command execution. figure 5-21 summarizes bdm command execution. commands consist of one 16-bit operation word and can include one or more 16-bit extension words. each incoming word is read as it is assembled by the serial interface. the microcode routine corresponding to a command is executed as soon as the command is complete. result operands are loaded into the output shift register to be shifted out as the next command is read. this process is repeated for each command until the cpu returns to normal operating mode. 5.6.2.5 bdm registers. bdm processing uses three special-purpose registers to track program context during development. a description of each register follows. 5.6.2.5.1 fault address register (far). the far contains the address of the faulting bus cycle immediately following a bus or address error. this address remains available until overwritten by a subsequent bus cycle. following a double bus fault, the far contains the address of the last bus cycle. the address of the first fault (if one occurred) is not visible to the user. 5.6.2.5.2 return program counter (rpc). the rpc points to the location where fetching will commence after transition from bdm to normal mode. this register should be accessed to change the flow of a program under development. changing the rpc to an odd value will cause an address error when normal mode prefetching begins. 5.6.2.5.3 current instruction program counter (pcc). the pcc holds a pointer to the first word of the last instruction executed prior to transition into bdm. due to instruction pipelining, the instruction pointed to may not be the instruction which caused the transition. an example is a breakpoint on a released write. the bus cycle may overlap as many as two subsequent instructions before stalling the instruction sequencer. a bkpt asserted during this cycle will not be acknowledged until the end of the instruction f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 68 mc68340 user? manual motorola executing at completion of the bus cycle. pcc will contain $00000001 if bdm is entered via a double bus fault immediately out of reset. . . yes no continue enter (bdm) ?assert freeze signal ?wait for command send initial command ?load command register ?enable shift clock ?shift out 17 bits ?disable shift clock execute command ?load: not ready/ response ?perform command ?store results read results/new command ?load command register ?enable shift clock ?shift in/out 17 bits ?disable shift clock ?read result register if results = "not ready" cpu32 activity development system activity figure 5-21. bdm command execution flowchart 5.6.2.6 returning from bdm. bdm is terminated when a resume execution (go) or call user code (call) command is received. both go and call flush the instruction pipeline and prefetch instructions from the location pointed to by the rpc. the return pc and the memory space referred to by the sr supv bit reflect any changes made during bdm. freeze is negated prior to initiating the first prefetch. upon negation of freeze, the serial subsystem is disabled, and the signals revert to ipipe and ifetch functionality. 5.6.2.7 serial interface. communication with the cpu32 during bdm occurs via a dedicated serial interface, which shares pins with other development features. the bkpt signal becomes the dsclk; dsi is received on ifetch , and dso is transmitted on ipipe . f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 69 the serial interface uses a full-duplex synchronous protocol similar to the serial peripheral interface (spi) protocol. the development system serves as the master of the serial link since it is responsible for the generation of dsclk. if dsclk is derived from the cpu32 system clock, development system serial logic is unhindered by the operating frequency of the target processor. operable frequency range of the serial clock is from dc to one-half the processor system clock frequency. the serial interface operates in full-duplex mode?.e., data is transmitted and received simultaneously by both master and slave devices. in general, data transitions occur on the falling edge of dsclk and are stable by the following rising edge of dsclk. data is transmitted msb first and is latched on the rising edge of dsclk. the serial data word is 17 bits wide?6 data bits and a status/control (s/c) bit. 16 15 0 s/c data field bit 16 indicates the status of cpu-generated messages as shown in table 5-21. table 5-21. cpu generated message encoding encoding data message type 0 xxxx valid data transfer 0 ffff command complete; status ok 1 0000 not ready with response; come again 1 0001 berr terminated bus cycle; data invalid 1 ffff illegal command command and data transfers initiated by the development system should clear bit 16. the current implementation ignores this bit; however, motorola reserves the right to use this bit for future enhancements. 5.6.2.7.1 cpu serial logic. cpu serial logic, shown in the left-hand portion of figure 5- 22, consists of transmit and receive shift registers and of control logic that includes synchronization, serial clock generation circuitry, and a received bit counter. both dsclk and dsi are synchronized to on-chip clocks, thereby minimizing the chance of propagating metastable states into the serial state machine. data is sampled during the high phase of clkout. at the falling edge of clkout, the sampled value is made available to internal logic. if there is no synchronization between cpu32 and development system hardware, the minimum hold time on dsi with respect to dsclk is one full period of clkout. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 70 mc68340 user? manual motorola . . control logic serial in parallel out parallel in serial out execution unit status synchronize microsequencer parallel in serial out serial in parallel out result latch control logic status data dsi dso dsclk serial clock 16 16 rcv data latch cpu instruction register bus 16 command latch data 16 development system 0 figure 5-22. debug serial i/o block diagram the serial state machine begins a sequence of events based on the rising edge of the synchronized dsclk (see figure 5-23). synchronized serial data is transferred to the input shift register, and the received bit counter is decremented. one-half clock period later, the output shift register is updated, bringing the next output bit to the dso signal. dso changes relative to the rising edge of dsclk and does not necessarily remain stable until the falling edge of dsclk. one clock period after the synchronized dsclk has been seen internally, the updated counter value is checked. if the counter has reached zero, the receive data latch is updated from the input shift register. at this same time, the output shift register is reloaded with the ?ot ready/come again?response. once the receive data latch has been loaded, the cpu is released to act on the new data. response data overwrites the ?ot ready response when the cpu has completed the current operation. data written into the output shift register appears immediately on the dso signal. in general, this action changes the state of the signal from a high (?ot ready?response status bit) to a low (valid data status bit) logic level. however, this level change only occurs if the command completes successfully. error conditions overwrite the ?ot ready response with the appropriate response that also has the status bit set. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 71 . clkout freeze dsclk dsi sample window internal synchronized dsclk internal synchronized dsi clkout dso figure 5-23. serial interface timing diagram a user can use the state change on dso to signal hardware that the next serial transfer may begin. a timeout of sufficient length to trap error conditions that do not change the state of dso should also be incorporated into the design. hardware interlocks in the cpu prevent result data from corrupting serial transfers in progress. 5.6.2.7.2 development system serial logic. the development system, as the master of the serial data link, must supply the serial clock. however, normal and bdm operations could interact if the clock generator is not properly designed. breakpoint requests are made by asserting bkpt to the low state in either of two ways. the primary method is to assert bkpt during a single bus cycle for which an exception is desired. another method is to assert bkpt , then continue to assert it until the cpu32 responds by asserting freeze. this method is useful for forcing a transition into bdm when the bus is not being monitored. each method requires a slightly different serial logic design to avoid spurious serial clocks. figure 5-24 represents the timing required for asserting bkpt during a single bus cycle. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 72 mc68340 user? manual motorola . . . . .. . .. .. . . . . . . . .. . . . . . . . . . shift_clk f orce_bgnd bkpt_tag freeze bkpt figure 5-24. bkpt timing for single bus cycle figure 5-25 depicts the timing of the bkpt /freeze method. in both cases, the serial clock is left high after the final shift of each transfer. this technique eliminates the possibility of accidentally tagging the prefetch initiated at the conclusion of a bdm session. as mentioned previously, all timing within the cpu is derived from the rising edge of the clock; the falling edge is effectively ignored. . . . . .. . .. .. . . . . . . . .. . . . . . . . . . .. bkpt_tag freeze shift_clk f orce_bgnd bkpt figure 5-25. bkpt timing for forcing bdm figure 5-26 represents a sample circuit providing for both bkpt assertion methods. as the name implies, force_bgnd is used to force a transition into bdm by the assertion of bkpt . force_bgnd can be a short pulse or can remain asserted until freeze is asserted. once asserted, the set-reset latch holds bkpt low until the first shift_clk is applied. . . . . . bkpt/dsclk s1 s2 r q q reset force_bgnd bkpt_tag shift_clk figure 5-26. bkpt /dsclk logic diagram bkpt_tag should be timed to the bus cycles since it is not latched. if extended past the assertion of freeze, the negation of bkpt_tag appears to the cpu32 as the first dsclk. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 73 dsclk, the gated serial clock, is normally high, but it pulses low for each bit to be transferred. at the end of the seventeenth clock period, it remains high until the start of the next transmission. clock frequency is implementation dependent and may range from dc to the maximum specified frequency. although performance considerations might dictate a hardware implementation, software solutions can be used provided serial bus timing is maintained. 5.6.2.8 command set. the following paragraphs describe the command set available in bdm. 5.6.2.8.1 command format. the following standard bit format is utilized by all bdm commands. 15 1098765432 0 operation 0 r/w op size 0 0 a/d register extension word(s) bits 15??peration field the operation field specifies the commands. this 6-bit field provides for a maximum of 64 unique commands. r/w field the r/w field specifies the direction of operand transfer. when the bit is set, the transfer is from cpu to development system. when the bit is cleared, data is written to the cpu or to memory from the development system. operand size for sized operations, this field specifies the operand data size. all addresses are expressed as 32-bit absolute values. the size field is encoded as listed in table 5-22. table 5-22. size field encoding encoding operand size 00 byte 01 word 10 long 11 reserved address/data (a/d) field the a/d field is used by commands that operate on address and data registers. it determines whether the register field specifies a data or address register. one indicates an address register; zero indicates a data register. for other commands, this field may be interpreted differently. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 74 mc68340 user? manual motorola register field: in most commands, this field specifies the register number for operations performed on an address or data register. extension word(s) (as required): at this time, no command requires an extension word to specify fully the operation to be performed, but some commands require extension words for addresses or immediate data. addresses require two extension words because only absolute long addressing is permitted. immediate data can be either one or two words in length?yte and word data each require a single extension word, long-word data requires two words. both operands and addresses are transferred most significant word first. 5.6.2.8.2 command sequence diagram. a command sequence diagram (see figure 5- 27) illustrates the serial bus traffic for each command. each bubble in the diagram represents a single 17-bit transfer across the bus. the top half in each diagram corresponds to the data transmitted by the development system to the cpu; the bottom half corresponds to the data returned by the cpu in response to the development system commands. command and result transactions are overlapped to minimize latency. the cycle in which the command is issued contains the development system command mnemonic (in this example, read memory location). during the same cycle, the cpu responds with either the lowest order results of the previous command or with a command complete status (if no results were required). during the second cycle, the development system supplies the high-order 16 bits of the memory address. the cpu returns a "not ready" response unless the received command was decoded as unimplemented, in which case the response data is the illegal command encoding. if an illegal command response occurs, the development system should retransmit the command. note the ?ot ready?response can be ignored unless a memory bus cycle is in progress. otherwise, the cpu can accept a new serial transfer with eight system clock periods. in the third cycle, the development system supplies the low-order 16 bits of a memory address. the cpu always returns the ?ot ready?response in this cycle. at the completion of the third cycle, the cpu initiates a memory read operation. any serial transfers that begin while the memory access is in progress return the ?ot ready?response. results are returned in the two serial transfer cycles following the completion of memory access. the data transmitted to the cpu during the final transfer is the opcode for the following command. should a memory access generate either a bus or address error, an error status is returned in place of the result data. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 75 . . . . .. . .. .. . . . . . . . .. . . . . . . . . . .. .. .. commands transmitted to the cpu32 command code transmitted during this cycle high-order 16 bits of memory address low-order 16 bits of memory address sequence taken if operation has not completed data unused from this transfer sequence taken if illegal command is received by cpu32 results from previous command responses from the cpu nonserial-related activity ms addr "not ready" xxx "illegal" ls addr "not ready" next cmd "not ready" read (long) ??? next cmd "not ready" xxx "not ready" xxx xxx berr/aerr xxx ms result next cmd ls result read memory location next command code sequence taken if bus error or address error occurs on memory access high- and low-order 16 bits of result figure 5-27. command-sequence diagram 5.6.2.8.3 command set summary. the bdm command set is summarized in table 5-23. subsequent paragraphs contain detailed descriptions of each command. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 76 mc68340 user? manual motorola table 5-23. bdm command summary command mnemonic description read a/d register rareg/rdreg read the selected address or data register and return the results via the serial interface. write a/d register wareg/wdreg the data operand is written to the specified address or data register. read system register rsreg the specified system control register is read. all registers that can be read in supervisor mode can be read in bdm. write system register wsreg the operand data is written into the specified system control register. read memory location read read the sized data at the memory location specified by the long- word address. the sfc register determines the address space accessed. write memory location write write the operand data to the memory location specified by the long-word address. the dfc register determines the address space accessed. dump memory block dump used in conjunction with the read command to dump large blocks of memory. an initial read is executed to set up the starting address of the block and to retrieve the first result. subsequent operands are retrieved with the dump command. fill memory block fill used in conjunction with the write command to fill large blocks of memory. an initial write is executed to set up the starting address of the block and to supply the first operand. subsequent operands are written with the fill command. resume execution go the pipeline is flushed and refilled before resuming instruction execution at the return pc. call user code call current pc is stacked at the location of the current sp. instruction execution begins at user patch code. reset peripherals rst asserts reset for 512 clock cycles. the cpu is not reset by this command. synonymous with the cpu reset instruction. no operation nop nop performs no operation and may be used as a null command. 5.6.2.8.4 read a/d register (rareg/rdreg). read the selected address or data register and return the results via the serial interface. command format: 1514131211109876543210 001000011000a/d register command sequence: rdreg/rareg ??? xxx ms result xxx "illegal" next cmd ls result next cmd "not ready" operand data: none f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 77 result data: the contents of the selected register are returned as a long-word value. the data is returned most significant word first. 5.6.2.8.5 write a/d register (wareg/wdreg). the operand (long-word) data is written to the specified address or data register. all 32 bits of the register are altered by the write. command format: 15141312111098765432 0 001000001000a/d register command sequence: wdreg/wareg ??? ms data xxx "illegal" ls data "not ready" next cmd "not ready" "cmd complete" next cmd "not ready" operand data: long-word data is written into the specified address or data register. the data is supplied most significant word first. result data: command complete status ($0ffff) is returned when register write is complete. 5.6.2.8.6 read system register (rsreg). the specified system control register is read. all registers that can be read in supervisor mode can be read in bdm. several internal temporary registers are also accessible. command format: 1514131211109876543 0 001001001000 register command sequence: rsreg ??? xxx ms result xxx "illegal" next cmd ls result next cmd "not ready" operand data: none f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 78 mc68340 user? manual motorola result data: always returns 32 bits of data, regardless of the size of the register being read. if the register is less than 32 bits, the result is returned zero extended. register field: the system control register is specified by the register field (see table 5-24). table 5-24. register field for rsreg and wsreg system register select code return program counter (rpc) 0000 current instruction program counter (pcc) 0001 status register (sr) 1011 user stack pointer (usp) 1100 supervisor stack pointer (ssp) 1101 source function code register (sfc) 1110 destination function code register (dfc) 1111 temporary register a (atemp) 1000 fault address register (far) 1001 vector base register (vbr) 1010 5.6.2.8.7 write system register (wsreg). operand data is written into the specified system control register. all registers that can be written in supervisor mode can be written in bdm. several internal temporary registers are also accessible. command format: 1514131211109876543 0 001001001000 register command sequence: ms data xxx "illegal" ls data "not ready" next cmd "not ready" "cmd complete" next cmd wsreg ??? "not ready" operand data: the data to be written into the register is always supplied as a 32-bit long word. if the register is less than 32 bits, the least significant word is used. result data: ?ommand complete?status is returned when register write is complete. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 79 register field: the system control register is specified by the register field (see table 5-24). the far is a read-only register?ny write to it is ignored. 5.6.2.8.8 read memory location (read). read the sized data at the memory location specified by the long-word address. only absolute addressing is supported. the sfc register determines the address space accessed. valid data sizes include byte, word, or long word. command format: 1514131211109876543210 00011001 op size 000000 command sequence: ms addr "not ready" xxx "illegal" ls addr "not ready" next cmd "not ready" read (b/w) ??? next cmd "not ready" xxx "not ready" next cmd result xxx berr/aerr read memory location ms addr "not ready" xxx "illegal" ls addr "not ready" next cmd "not ready" read (long) ??? next cmd xxx "not ready" ms result xxx berr/aerr read memory location xxx next cmd ls result "not ready" operand data: the single operand is the long-word address of the requested memory location. result data: the requested data is returned as either a word or long word. byte data is returned in the least significant byte of a word result, with the upper byte cleared. word results return 16 bits of significant data; long-word results return 32 bits. a successful read operation returns data bit 16 cleared. if a bus or address error is encountered, the returned data is $10001. 5.6.2.8.9 write memory location (write). write the operand data to the memory location specified by the long-word address. the dfc register determines the address f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 80 mc68340 user? manual motorola space accessed. only absolute addressing is supported. valid data sizes include byte, word, and long word. command format: 1514131211109876543210 00011000 op size 000000 command sequence: ms addr "not ready" xxx "illegal" ls addr "not ready" next cmd "not ready" write (b/w) ??? next cmd "not ready" xxx "not ready" xxx xxx berr/aerr next cmd "cmd complete" data "not ready" write memory location ms addr "not ready" xxx "illegal" ls addr "not ready" next cmd "not ready" write (long) ??? ms data "not ready" ls data "not ready" write memory location next cmd "not ready" xxx "not ready" xxx xxx berr/aerr next cmd "cmd complete" operand data: two operands are required for this instruction. the first operand is a long-word absolute address that specifies a location to which the operand data is to be written. the second operand is the data. byte data is transmitted as a 16-bit word, justified in the least significant byte; 16- and 32-bit operands are transmitted as 16 and 32 bits, respectively. result data: successful write operations return a status of $0ffff. bus or address errors on the write cycle are indicated by the assertion of bit 16 in the status message and by a data pattern of $0001. 5.6.2.8.10 dump memory block (dump). dump is used in conjunction with the read command to dump large blocks of memory. an initial read is executed to set up the f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 81 starting address of the block and to retrieve the first result. subsequent operands are retrieved with the dump command. the initial address is incremented by the operand size (1, 2, or 4) and saved in a temporary register. subsequent dump commands use this address, increment it by the current operand size, and store the updated address back in the temporary register. note the dump command does not check for a valid address in the temporary register?ump is a valid command only when preceded by another dump or by a read command. otherwise, the results are undefined. the nop command can be used for intercommand padding without corrupting the address pointer. the size field is examined each time a dump command is given, allowing the operand size to be altered dynamically. command format: 1514131211109876543210 00011101 op size 000000 command sequence: dump (long) ??? xxx "not ready" next cmd result xxx berr/aerr xxx "illegal" next cmd "not ready" next cmd "not ready" read memory location xxx "not ready" next cmd ms result xxx berr/aerr xxx "illegal" next cmd "not ready" next cmd "not ready" read memory location next cmr ls result dump (long) ??? f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 82 mc68340 user? manual motorola operand data: none result data: requested data is returned as either a word or long word. byte data is returned in the least significant byte of a word result. word results return 16 bits of significant data; long-word results return 32 bits. status of the read operation is returned as in the read command: $0xxxx for success, $10001 for bus or address errors. 5.6.2.8.11 fill memory block (fill). fill is used in conjunction with the write command to fill large blocks of memory. an initial write is executed to set up the starting address of the block and to supply the first operand. subsequent operands are written with the fill command. the initial address is incremented by the operand size (1, 2, or 4) and is saved in a temporary register. subsequent fill commands use this address, increment it by the current operand size, and store the updated address back in the temporary register. note the fill command does not check for a valid address in the temporary register?ill is a valid command only when preceded by another fill or by a write command. otherwise, the results are undefined. the nop command can be used for intercommand padding without corrupting the address pointer. the size field is examined each time a fill command is given, allowing the operand size to be altered dynamically. command format: 1514131211109876543210 00011100 op size 000000 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 83 command sequence: next cmd "not ready" "not ready" xxx berr/aerr "cmd complete" data "not ready" xxx next cmd xxx "illegal" next cmd "not ready" fill (long) ??? write memory location next cmd "not ready" xxx "not ready" xxx berr/aerr "cmd complete" ms data "not ready" next cmd xxx "illegal" next cmd "not ready" ls data "not ready" write memory location fill (b/w) ??? operand data: a single operand is data to be written to the memory location. byte data is transmitted as a 16-bit word, justified in the least significant byte; 16- and 32-bit operands are transmitted as 16 and 32 bits, respectively. result data: status is returned as in the write command: $0ffff for a successful operation and $10001 for a bus or address error during write. 5.6.2.8.12 resume execution (go). the pipeline is flushed and refilled before normal instruction execution is resumed. prefetching begins at the return pc and current privilege level. if either the pc or sr is altered during bdm, the updated value of these registers is used when prefetching commences. note the processor exits bdm when a bus error or address error occurs on the first instruction prefetch from the new pc?he error is trapped as a normal mode exception. the stacked value of the current pc may not be valid in this case, depending on the state of the machine prior to entering bdm. for address error, the pc does not reflect the true return pc. instead, the stacked fault address is the (odd) return pc. command format: 1514131211109876543210 0000110000000000 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 84 mc68340 user? manual motorola command sequence: go ??? normal mode xxx "illegal" next cmd "not ready" operand data: none result data: none 5.6.2.8.13 call user code (call). this instruction provides a convenient way to patch user code. the return pc is stacked at the location pointed to by the current sp. the stacked pc serves as a return address to be restored by the rts command that terminates the patch routine. after stacking is complete, the 32-bit operand data is loaded into the pc. the pipeline is flushed and refilled from the location pointed to by the new pc, bdm is exited, and normal mode instruction execution begins. note if a bus error or address error occurs during return address stacking, the cpu returns an error status via the serial interface and remains in bdm. if a bus error or address error occurs on the first instruction prefetch from the new pc, the processor exits bdm and the error is trapped as a normal mode exception. the stacked value of the current pc may not be valid in this case, depending on the state of the machine prior to entering bdm. for address error, the pc does not reflect the true return pc. instead, the stacked fault address is the (odd) return pc. command format: 1514131211109876543210 0000100000000000 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 85 command sequence: ls addr "not ready" stack return pc ms addr "not ready" xxx "illegal" next cmd "not ready" call ??? normal mode xxx berr/aerr next cmd "not ready" freeze negated prefetch started operand data: the 32-bit operand data is the starting location of the patch routine, which is the initial pc upon exiting bdm. result data: none as an example, consider the following code segment. it outputs a character from the mc68340 serial module channel a. chkstat: move.b sra,d0 move serial status to d0 bne.b chkstat loop until condition true move.b tba,output transmit character missing: andi.b #3,d0 check for txemp flag rts bdm and the call command can be used to patch the code as follows: 1. breakpoint user program at chkstat 2. enter bdm 3. execute call command to missing 4. exit bdm 5. execute missing code 6. return to user program 5.6.2.8.14 reset peripherals (rst). rst asserts reset for 512 clock cycles. the cpu is not reset by this command. this command is synonymous with the cpu reset instruction. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 86 mc68340 user? manual motorola command format: 1514131211109876543210 0000010000000000 command sequence: reset ??? assert reset xxx "not ready" xxx "illegal" next cmd "not ready" next cmd "cmd complete" operand data: none result data: the ?ommand complete?response ($0ffff) is loaded into the serial shifter after negation of reset. 5.6.2.8.15 no operation (nop). nop performs no operation and may be used as a null command where required. command format: 1514131211109876543210 0000000000000000 command sequence: xxx "illegal" "not ready" nop ??? next cmd "cmd complete" next cmd operand data: none result data: the ?ommand complete?response ($0ffff) is returned during the next shift operation. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 87 5.6.2.8.16 future commands. unassigned command opcodes are reserved by motorola for future expansion. all unused formats within any revision level will perform a nop and return the illegal command response. 5.6.3 deterministic opcode tracking the cpu32 utilizes deterministic opcode tracking to trace program execution. two signals, ipipe and ifetch , provide all information required to analyze instruction pipeline operation. 5.6.3.1 instruction fetch ( ifetch ). ifetch indicates which bus cycles are accessing data to fill the instruction pipeline. ifetch is pulse-width modulated to multiplex two indications on a single pin. asserted for a single clock cycle, ifetch indicates that the data from the current bus cycle is to be routed to the instruction pipeline. ifetch held low for two clock cycles indicates that the instruction pipeline has been flushed. the data from the bus cycle is used to begin filling the empty pipeline. both user and supervisor mode fetches are signaled by ifetch . proper tracking of bus cycles via ifetch on a fast bus requires a simple state machine. on a two-clock bus, ifetch may signal a pipeline flush with associated prefetch followed immediately by a second prefetch. that is, ifetch remains asserted for three clocks, two clocks indicating the flush/fetch and a third clock signaling the second fetch. these two operations are easily discerned if the tracking logic samples ifetch on the two rising edges of clkout, which follow the as ( ds during show cycles) falling edge. three-clock and slower bus cycles allow time for negation of the signal between consecutive indications and do not experience this operation. 5.6.3.2 instruction pipe ( ipipe ). the internal instruction pipeline can be modeled as a three-stage fifo (see figure 5-28). stage a is an input buffer?ata can be used out of stages b and c. ipipe signals advances of instructions in the pipeline. instruction register a (ira) holds incoming words as they are prefetched. no decoding takes place in the buffer. instruction register b (irb) provides initial decoding of the opcode and decoding of extension words; it is a source of immediate data. instruction register c (irc) supplies residual opcode decoding during instruction execution. . i r c data bus extension words opcode s residua l i r b i r a figure 5-28. functional model of instruction pipeline f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 88 mc68340 user? manual motorola assertion of ipipe for a single clock cycle indicates the use of data from irb. regardless of the presence of valid data in ira, the contents of irb are invalidated when ipipe is asserted. if ira contains valid data, the data is copied into irb (ira t irb), and the irb stage is revalidated. assertion of ipipe for two clock cycles indicates the start of a new instruction and subsequent replacement of data in irc. this action causes a full advance of the pipeline (irb t irc and ira t irb). ira is refilled during the next instruction fetch bus cycle. data loaded into ira propagates automatically through subsequent empty pipeline stages. signals that show the progress of instructions through irb and irc are necessary to accurately monitor pipeline operation. these signals are provided by ira and irb validity bits. when a pipeline advance occurs, the validity bit of the stage being loaded is set, and the validity bit of the stage supplying the data is negated. because instruction execution is not timed to bus activity, ipipe is synchronized with the system clock, not the bus. figure 5-29 illustrates the timing in relation to the system clock. . .. ipipe extension word used instruction start extension word used instruction start ir ir ir ir irb irc ir ir irb irc clkout ir ir figure 5-29. instruction pipeline timing diagram ipipe should be sampled on the falling edge of the clock. the assertion of ipipe for a single cycle after one or more cycles of negation indicates use of the data in irb (advance of ira into irb). assertion for two clock cycles indicates that a new instruction has started (irb t irc and ira t irb transfers have occurred). loading irc always indicates that an instruction is beginning execution?he opcode is loaded into irc by the transfer. in some cases, instructions using immediate addressing begin executing and initiate a second pipeline advance simultaneously at the same time. ipipe will not be negated between the two indications, which implies the need for a state machine to track the state of ipipe . the state machine can be resynchronized during periods of inactivity on the signal. 5.6.3.3 opcode tracking during loop mode. ipipe and ifetch continue to work normally during loop mode. ifetch indicates all instruction fetches up through the point that data begins recirculating within the instruction pipeline. ipipe continues to signal the start of instructions and the use of extension words even though data is being recirculated internally. ifetch returns to normal operation with the first fetch after exiting loop mode. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 89 5.7 instruction execution timing this section describes the instruction execution timing of the cpu32. external clock cycles are used to provide accurate execution and operation timing guidelines, but not exact timing for every possible circumstance. this approach is used because exact execution time for an instruction or operation depends on concurrence of independently scheduled resources, on memory speeds, and on other variables. an assembly language programmer or compiler writer can use the information in this section to predict the performance of the cpu32. additionally, timing for exception processing is included so that designers of multitasking or real-time systems can predict task-switch overhead, maximum interrupt latency, and similar timing parameters. instruction timing is given in clock cycles to eliminate clock frequency dependency. 5.7.1 resource scheduling the cpu32 contains several independently scheduled resources. the organization of these resources within the cpu32 is shown in figure 5-30. some variation in instruction execution timing results from concurrent resource utilization. because resource scheduling is not directly related to instruction boundaries, it is impossible to make an accurate prediction of the time required to complete an instruction without knowing the entire context within which the instruction is executing. 5.7.1.1 microsequencer. the microsequencer either executes microinstructions or awaits completion of accesses necessary to continue microcode execution. the microsequencer supervises the bus controller, instruction execution, and internal processor operations such as calculation of ea and setting of condition codes. it also initiates instruction word prefetches after a change of flow and controls validation of instruction words in the instruction pipeline. 5.7.1.2 instruction pipeline. the cpu32 contains a two-word instruction pipeline where instruction opcodes are decoded. each stage of the pipeline is initially filled under microsequencer control and subsequently refilled by the prefetch controller as it empties. stage a of the instruction pipeline is a buffer. prefetches completed on the bus before stage b empties are temporarily stored in this buffer. instruction words (instruction operation words and all extension words) are decoded at stage b. residual decoding and execution occur in stage c. each pipeline stage has an associated status bit that shows whether the word in that stage was loaded with data from a bus cycle that terminated abnormally. 5.7.1.3 bus controller resources. the bus controller consists of the instruction prefetch controller, the write pending buffer, and the microbus controller. these three resources transact all reads, writes, and instruction prefetches required for instruction execution. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 90 mc68340 user? manual motorola the bus controller and microsequencer operate concurrently. the bus controller can perform a read or write or schedule a prefetch while the microsequencer controls ea calculation or sets condition codes. the microsequencer can also request a bus cycle that the bus controller cannot perform immediately. when this happens, the bus cycle is queued, and the bus controller runs the cycle when the current cycle is complete. microsequencer and control control store control logic instruction pipeline stage stage c b execution unit program counter section data s ectio n write-pending buffer prefetch c ontrolle r microbus c ontrolle r address bu s data b us bus control signals figure 5-30. block diagram of independent resources 5.7.1.3.1 prefetch controller. the instruction prefetch controller receives an initial request from the microsequencer to initiate prefetching at a given address. subsequent prefetches are initiated by the prefetch controller whenever a pipeline stage is invalidated, either through instruction completion or through use of extension words. prefetch occurs as soon as the bus is free of operand accesses previously requested by the microsequencer. additional state information permits the controller to inhibit prefetch requests when a change in instruction flow (e.g., a jump or branch instruction) is anticipated. in a typical program, 10 to 25 percent of the instructions cause a change of flow. each time a change occurs, the instruction pipeline must be flushed and refilled from the new instruction stream. if instruction prefetches, rather than operand accesses, were given f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 91 priority, many instruction words would be flushed unused, and necessary operand cycles would be delayed. to maximize available bus bandwidth, the cpu32 will schedule a prefetch only when the next instruction is not a change-of-flow instruction and when there is room in the pipeline for the prefetch. 5.7.1.3.2 write pending buffer. the cpu32 incorporates a single-operand write pending buffer. the buffer permits the microsequencer to continue execution after a request for a write cycle is queued in the bus controller. the time needed for a write at the end of an instruction can overlap the head cycle time for the following instruction, thus reducing overall execution time. interlocks prevent the microsequencer from overwriting the buffer. 5.7.1.3.3 microbus controller. the microbus controller performs bus cycles issued by the microsequencer. operand accesses always have priority over instruction prefetches. word and byte operands are accessed in a single cpu-initiated bus cycle, although the external bus interface may be required to initiate a second cycle when a word operand is sent to a byte-sized external port. long operands are accessed in two bus cycles, most significant word first. the instruction pipeline is capable of recognizing instructions that cause a change of flow. it informs the bus controller when a change of flow is imminent, and the bus controller refrains from starting prefetches that would be discarded due to the change of flow. 5.7.1.4 instruction execution overlap. overlap is the time, measured in clock cycles, that an instruction executes concurrently with the previous instruction. as shown in figure 5-31, portions of instructions a and b execute simultaneously, reducing total execution time. because portions of instructions b and c also overlap, overall execution time for all three instructions is also reduced. each instruction contributes to the total overlap time. the portion of execution time at the end of instruction a that can overlap the beginning of instruction b is called the tail of instruction a. the portion of execution time at the beginning of instruction b that can overlap the end of instruction a is called the head of instruction b. the total overlap time between instructions a and b is the smaller tail of a and the head of b. overlap overlap instruction a instruction b instruction c figure 5-31. simultaneous instruction execution f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 92 mc68340 user? manual motorola the execution time attributed to instructions a, b, and c after considering the overlap is illustrated in figure 5-32. the overlap time is attributed to the execution time of the completing instruction. the following equation shows the method for calculating the overlap time: overlap = min (tail n , head n+1 ) overlap period (absorbed by instruction a) overlap period (absorbed by instruction b) instruction a instruction b instruction c figure 5-32. attributed instruction times 5.7.1.5 effects of wait states. the cpu32 access time for on-chip peripherals is two clocks. while two-clock external accesses are possible when the bus is operated in a synchronous mode, a typical external memory speed is three or more clocks. all instruction times listed in this section are for word access only (unless an explicit exception is given), and are based on the assumption that both instruction fetches and operand cycles are to a two-clock memory. any time a long access is made, time for the additional bus cycle(s) must be added to the overall execution time. wait states due to slow external memory must be added to the access time for each bus cycle. a typical application has a mixture of bus speeds?rogram execution from an off-chip rom, accesses to on-chip peripherals, storage of variables in slow off-chip ram, and accesses to external peripherals with speeds ranging from moderate to very slow. to arrive at an accurate instruction time calculation, each bus access must be individually considered. many instructions have a head cycle count, which can overlap the cycles of an operand fetch to slower memory started by a previous instruction. in these cases, an increase in access time has no effect on the total execution time of the pair of instructions. to trace instruction execution time by monitoring the external bus, note that the order of operand accesses for a particular instruction sequence is always the same provided bus speed is unchanged and the interleaving of instruction prefetches with operands within each sequence is identical. 5.7.1.6 instruction execution time calculation. the overall execution time for an instruction depends on the amount of overlap with previous and subsequent instructions. to calculate an instruction time estimate, the entire code sequence must be f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 93 analyzed. to derive the actual instruction execution times for an instruction sequence, the instruction times listed in the tables must be adjusted to account for overlap. the formula for this calculation is as follows: c 1 - min (t 1 , h 2 ) + c 2 - min (t 2 , h 3 ) + c 3 - min (t 3 , h 4 ) + .. .. . where: c n is the number of cycles listed for instruction n t n is the tail time for instruction n h n is the head time for instruction n min (t n , h m ) is the minimum of parameters t n and h m the number of cycles for the instruction (c n ) can include one or two ea calculations in addition to the raw number in the cycles column. in these cases, calculate overall instruction time as if it were for multiple instructions, using the following equation: cea ? - min (t ea , h op ) + c op where: cea ? is the instruction? ea time c op is the instruction? operation time t ea is the ea? tail time h op is the instruction operation? head time min (t n , h m ) is the minimum of parameters t n and h m the overall head for the instruction is the head for the ea, and the overall tail for the instruction is the tail for the operation. therefore, the actual equation for execution time becomes: c op1 - min (t op1 , h ea2 ) + cea ? 2 - min (t ea2 , h op2 ) + c op2 - min (t op2 , h ea3 ) + . . . every instruction must prefetch to replace itself in the instruction pipe. usually, these prefetches occur during or after an instruction. a prefetch is permitted to begin in the first clock of any indexed ea mode operation. additionally, a prefetch for an instruction is permitted to begin two clocks before the end of an instruction provided the bus is not being used. if the bus is being used, then the prefetch occurs at the next available time when the bus would otherwise be idle. 5.7.1.7 effects of negative tails. when the cpu32 changes instruction flow, the instruction decode pipeline must begin refilling before instruction execution can resume. refilling forces a two-clock idle period at the end of the change-of-flow instruction. this idle period can be used to prefetch an additional word on the new instruction path. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 94 mc68340 user? manual motorola because of the stipulation that each instruction must prefetch to replace itself, the concept of negative tails has been introduced to account for these free clocks on the bus. on a two-clock bus, it is not necessary to adjust instruction timing to account for the potential extra prefetch. the cycle times of the microsequencer and bus are matched, and no additional benefit or penalty is obtained. in the instruction execution time equations, a zero should be used instead of a negative number. negative tails are used to adjust for slower fetches on slower buses. normally, increasing the length of prefetch bus cycles directly affects the cycle count and tail values found in the tables. in the following equations, negative tail values are used to negate the effects of a slower bus. the equations are generalized, however, so that they may be used on any speed bus with any tail value. new_tail = old_tail + (new_clock ?2) if ((new_clock ?4) >0) then new_cycle = old_cycle + (new_clock -2) + (new_clock ?4) else new_cycle = old_cycle + (new _clock ?2) where: new_tail/new_cycle is the adjusted tail/cycle at the slower speed old_tail/old_cycle is the value listed in the instruction timing tables new_clock is the number of clocks per cycle at the slower speed note that many instructions listed as having negative tails are change-of-flow instructions and that the bus speed used in the calculation is that of the new instruction stream. 5.7.2 instruction stream timing examples the following programming examples provide a detailed examination of timing effects. in all examples, the memory access is from external synchronous memory, the bus is idle, and the instruction pipeline is full at the start. 5.7.2.1 timing example 1?xecution overlap. figure 5-33 illustrates execution overlap caused by the bus controller's completion of bus cycles while the sequencer is calculating the next ea. one clock is saved between instructions since that is the minimum time of the individual head and tail numbers. instructions move.w a1, (a0) + addq.w #1, (a0) clr.w $30 (a1) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 95 clock 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 bus controlle r instruction controlle r execution tim e write for 1 1 pre- f etc h read f or 2 write for 2 2 pre- f etc h addq t o 5- 96 mc68340 user? manual motorola clock 1 2 3 4 5 6 7 8 9 0 1 2 3 4 bus controlle r instruction controlle r execution tim e 1 pre- f etc h cmp d 1,d 0 moveq moveq #7,d1 ble.b not taken offset calc write for 4 3 pre- f etc h 4 pre- fetch not taken write for 4 move to (a0) move.l d1,(ao) cmp 2 pre- f etc h figure 5-35. example 2?ranch not taken 5.7.2.3 timing example 3?egative tails. this example (see figure 5-36) shows how to use negative tail figures for branches and other change-of-flow instructions. in this example, bus speed is assumed to be four clocks per access. instruction three is at the branch destination. although the cpu32 has a two-word instruction pipeline, internal delay causes minimum branch instruction time to be three bus cycles. the negative tail is a reminder that an extra two clocks are available for prefetching a third word on a fast bus; on a slower bus, there is no extra time for the third word. instructions moveq #7, d1 bra.w faraway move.l d1, d0 clock 1 2 3 4 5 6 7 8 9 0 1 2 3 4 bus controlle r instruction c ontrolle r execution tim e moveq offset calc 5 6 7 8 9 branch offset bra.w faraway taken taken fetch move.l fetch next i nstructio n prefetch move t o d 0 move.l d1,d0 moveq #7,d1 figure 5-36. example 3?ranch negative tail f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 97 example 3 illustrates three different aspects of instruction time calculation: 1. the branch instruction does not attempt to prefetch beyond the minimum number of words needed for itself. 2. the negative tail allows execution to begin sooner than a three-word pipeline would allow. 3. there is a one-clock delay due to late arrival of the displacement at the cpu. only changes of flow require negative tail calculation, but the concept can be generalized to any instruction?nly two words are required to be in the pipeline, but up to three words may be present. when there is an opportunity for an extra prefetch, it is made. a prefetch to replace an instruction can begin ahead of the instruction, resulting in a faster processor. 5.7.3 instruction timing tables the following assumptions apply to the times shown in the subsequent tables. ? 16-bit data bus is used for all memory accesses. ?emory access times are based on two clock bus cycles with no wait states. ?he instruction pipeline is full at the beginning of the instruction and is refilled by the end of the instruction. three values are listed for each instruction and addressing mode: head: the number of cycles available at the beginning of an instruction to complete a previous instruction write or to perform a prefetch. tail: the nu mber of cycles an instruction uses to complete a write. cycles: four numbers per entry, three contained in parentheses. the outer number is the minimum number of cycles required for the instruction to complete. numbers within the parentheses represent the number of bus accesses performed by the instruction. the first number is the number of operand read accesses performed by the instruction. the second number is the number of instruction fetches performed by the instruction, including all prefetches that keep the instruction and the instruction pipeline filled. the third number is the number of write accesses performed by the instruction. as an example, consider an add.l (12, a3, d7.w * 4), d2 instruction. paragraph 5.7.3.5 arithmetic/logic instructions shows that the instruction has a head = 0, a tail = 0, and cycles = 2 (0/1/0). however, in indexed, address register indirect addressing mode, additional time is required to fetch the ea. paragraph 5.7.3.1 fetch effective address gives addressing mode data. for (d 8 , an, xn.sz * scale), head = 4, tail = 2, cycles = 8 (2/1/0). because this example is for a long access and the fetch ea table lists data for word accesses, add two clocks to the tail and to the number of cycles (??in table notation) to obtain head = 4, tail = 4, cycles = 10 (2/1/0). assuming that no trailing write exists from the previous instruction, ea calculation requires six clocks. replacement fetch for the ea occurs during these six clocks, leaving a head of f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 98 mc68340 user? manual motorola four. if there is no time in the head to perform a prefetch due to a previous trailing write, then additional time to perform the prefetches must be allotted in the middle of the instruction or after the tail. total number of clocks number of read cycles number of instruction access cycles number of write cycles 8(2 /1/0) the total number of clocks for bus activity is as follows: (2 reads 2 clocks/read) + (1 instruction access 2 clocks/access) + (0 writes 2 clocks/write) = 6 clocks of bus activity the number of internal clocks (not overlapped by bus activity) is as follows: 10 clocks total - 6 clocks bus activity = 4 internal clocks memory read requires two bus cycles at two clocks each. this read time, implied in the tail figure for the ea, cannot be overlapped with the instruction because the instruction has a head of zero. an additional two clocks are required for the add instruction itself. the total is 6 + 4 + 2 = 12 clocks. if bus cycles take more time (i.e., the memory is off-chip), add an appropriate number of clocks to each memory access. the instruction sequence move.l d0, (a0) followed by lsl.l #7, d2 provides an example of overlapped execution. the move instruction has a head of zero and a tail of four because it is a long write. the lsl instruction has a head of four. the trailing write from the move overlaps the lsl head completely. thus, the two-instruction sequence has a head of zero and a tail of zero, and a total execution of 8 rather than 12 clocks. general observations regarding calculation of execution time are as follows: any time the number of bus cycles is listed as "x", substitute a value of one for byte and word cycles and a value of two for long cycles. for long bus cycles, usually add a value of two to the tail. the time calculated for an instruction on a three-clock (or longer) bus is usually longer than the actual execution time. all times shown are for two-clock bus cycles. if the previous instruction has a negative tail, then a prefetch for the current instruction can begin during the execution of that previous instruction. certain instructions requiring an immediate extension word (immediate word ea, absolute word ea, address register indirect with displacement ea, conditional branches with word offsets, bit operations, lpstop, tbl, movem, movec, moves, movep, mul.l, div.l, chk2, cmp2, and dbcc) are not permitted to begin until the extension word has been in the instruction pipeline for at least one cycle. this does not apply to long offsets or displacements. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 99 5.7.3.1 fetch effective address. the fetch ea table indicates the number of clock periods needed for the processor to calculate and fetch the specified ea. the total number of clock cycles is outside the parentheses. the numbers inside parentheses (r/p/w) are included in the total clock cycle number. all timing data assumes two-clock reads and writes. instruction head tail cycles notes dn 0(0/0/0) an 0(0/0/0) (an) 1 1 3(x/0/0) 1 (an) + 1 1 3(x/0/0) 1 - (an) 2 2 4(x/0/0) 1 (d 16 ,an) or (d 16 ,pc) 1 3 5(x/1/0) 1,3 (xxx).w 1 3 5(x/1/0) 1 (xxx).l 1 5 7(x/2/0) 1 # data ? .b 1 1 3(0/1/0) 1 # data ? .w 1 1 3(0/1/0) 1 # data ? .l 1 3 5(0/2/0) 1 (d 8 ,an,xn.sz sc) or (d 8 ,pc,xn.sz sc) 4 2 8(x/1/0) 1,2,3,4 (0) (all suppressed) 2 2 6(x/1/0) 1,4 (d 16 ) 1 3 7(x/2/0) 1,4 (d 32 ) 1 5 9(x/3/0) 1,4 (an) 1 1 5(x/1/0) 1,2,4 (xm.sz sc) 4 2 8(x/1/0) 1,2,4 (an,xm.sz sc) 4 2 8(x/1/0) 1,2,3,4 (d 16 ,an) or (d 16 ,pc) 1 3 7(x/2/0) 1,3,4 (d 32 ,an) or (d 32 ,pc) 1 5 9(x/3/0) 1,3,4 (d 16 ,an,xm) or (d 16 ,pc,xm) 2 2 8(x/2/0) 1,3,4 (d 32 ,an,xm) or (d 32 ,pc,xm) 1 3 9(x/3/0) 1,3,4 (d 16 ,an,xm.sz sc) or (d 16 ,pc,xm.sz sc) 2 2 8(x/2/0) 1,2,3,4 (d 32 ,an,xm.sz sc) or (d 32 ,pc,xm.sz sc) 1 3 9(x/3/0) 1,2,3,4 x = there is one bus cycle for byte and word operands and two bus cycles for long-word operands. for long-word bus cycles, add two clocks to the tail and to the number of cycles. notes: 1. the read of the ea and replacement fetches overlap the head of the operation by the amount specified in the tail. 2. size and scale of the index register do not affect execution time. 3. the pc may be substituted for the base address register an. 4. when adjusting the prefetch time for slower buses, extra clocks may be subtracted from the head until the head reaches zero, at which time additional clocks must be added to both the tail and cycle counts. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 100 mc68340 user? manual motorola 5.7.3.2 calculate effective address. the calculate ea table indicates the number of clock periods needed for the processor to calculate a specified ea. the timing is equivalent to fetch ea except there is no read cycle. the tail and cycle time are reduced by the amount of time the read would occupy. the total number of clock cycles is outside the parentheses. the numbers inside parentheses (r/p/w) are included in the total clock cycle number. all timing data assumes two-clock reads and writes. instruction head tail cycles notes dn 0(0/0/0) an 0(0/0/0) (an) 1 0 2(0/0/0) (an) + 1 0 2(0/0/0) - (an) 2 0 2(0/0/0) (d 16 ,an) or (d 16 ,pc) 1 1 3(0/1/0) 1,3 (xxx).w 1 1 3(0/1/0) 1 (xxx).l 1 3 5(0/2/0) 1 (d 8 ,an,xn.sz sc) or (d 8 ,pc,xn.sz sc) 4 0 6(0/1/0) 2,3,4 (0) (all suppressed) 2 0 4(0/1/0) 4 (d 16 ) 1 1 5(0/2/0) 1,4 (d 32 ) 1 3 7(0/3/0) 1,4 (an) 1 0 4(0/1/0) 4 (xm.sz sc) 4 0 6(0/1/0) 2,4 (an,xm.sz sc) 4 0 6(0/1/0) 2,4 (d 16 ,an) or (d 16 ,pc) 1 1 5(0/2/0) 1,3,4 (d 32 ,an) or (d 32 ,pc) 1 3 7(0/3/0) 1,3,4 (d 16 ,an,xm) or (d 16 ,pc,xm) 2 0 6(0/2/0) 3,4 (d 32 ,an,xm) or (d 32 ,pc,xm) 1 1 7(0/3/0) 1,3,4 (d 16 ,an,xm.sz sc) or (d 16 ,pc,xm.sz sc) 2 0 6(0/2/0) 2,3,4 (d 32 ,an,xm.sz sc) or (d 32 ,pc,xm.sz sc) 1 1 7(0/3/0) 1,2,3,4 x = there is one bus cycle for byte and word operands and two bus cycles for long operands. for long bus cycles, add two clocks to the tail and to the number of cycles. notes: 1. replacement fetches overlap the head of the operation by the amount specified in the tail. 2. size and scale of the index register do not affect execution time. 3. the pc may be substituted for the base address register an. 4. when adjusting the prefetch time for slower buses, extra clocks may be subtracted from the head until the head reaches zero, at which time additional clocks must be added to both the tail and cycle counts. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 101 5.7.3.3 move instruction. the move instruction table indicates the number of clock periods needed for the processor to calculate the destination ea and to perform a move or movea instruction. for entries with cea or fea, refer to the appropriate table to calculate that portion of the instruction time. destination eas are divided by their formats (see 5.3.4.4 effective address encoding summary ). the total number of clock cycles is outside the parentheses. the numbers inside parentheses (r/p/w) are included in the total clock cycle number. all timing data assumes two-clock reads and writes. when using this table, begin at the top and move downward. use the first entry that matches both source and destination addressing modes. instruction head tail cycles move rn, rn 0 0 2(0/1/0) move fea ? , rn 0 0 2(0/1/0) move rn, (am) 0 2 4(0/1/x) move rn, (am) + 1 1 5(0/1/x) move rn, - (am) 2 2 6(0/1/x) move rn, cea ? 1 3 5(0/1/x) move fea ? , (an) 2 2 6(0/1/x) move fea ? , (an) + 2 2 6(0/1/x) move fea ? , - (an) 2 2 6(0/1/x) move #, cea ? 2 2 6(0/1/x) * move cea ? , fea ? 2 2 6(0/1/x) x = there is one bus cycle for byte and word operands and two bus cycles for long-word operands. for long-word bus cycles, add two clocks to the tail and to the number of cycles. * = an # fetch ea time must be added for this instruction: fea ? + cea ? + oper ? note: for instructions not explicitly listed, use the move cea ? , fea ? entry. the source ea is calculated by the calculate ea table, and the destination ea is calculated by the fetch ea table, even though the bus cycle is for the source ea. 5.7.3.4 special-purpose move instruction. the special-purpose move instruction table indicates the number of clock periods needed for the processor to fetch, calculate, and perform the special-purpose move operation on control registers or a specified ea. footnotes indicate when to account for the appropriate ea times. the total number of clock cycles is outside the parentheses. the numbers inside parentheses (r/p/w) are included in the total clock cycle number. all timing data assumes two-clock reads and writes. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 102 mc68340 user? manual motorola instruction head tail cycles exg rn, rm 2 0 4(0/1/0) movec cr, rn 10 0 14(0/2/0) movec rn, cr 12 0 14-16(0/1/0) move ccr, dn 2 0 4(0/1/0) move ccr, cea ? 0 2 4(0/1/1) move dn, ccr 2 0 4(0/1/0) move fea ? , ccr 0 0 4(0/1/0) move sr, dn 2 0 4(0/1/0) move sr, cea ? 0 2 4(0/1/1) move dn, sr 4 - 2 10(0/3/0) move fea ? , sr 0 - 2 10(0/3/0) movem.w cea ? , rl 108 + n 4 (n + 1, 2, 0) * movem.w rl, cea ? 108 + n 4 (0, 2, n) * movem.l cea ? , rl 1 0 12 + n 4(2n + 2, 2, 0) movem.l rl, cea ? 1210 + n 4 (0, 2, 2n) movep.w dn, (d 16 , an) 2 0 10(0/2/2) movep.w (d 16 , an), dn 1 2 11(2/2/0) movep.l dn, (d 16 , an) 2 0 14(0/2/4) movep.l (d 16 , an), dn 1 2 19(4/2/0) moves (save) cea ? , rn 1 1 3(0/1/0) moves (op) cea ? , rn 7 1 11(x/1/0) moves (save) rn, cea ? 1 1 3(0/1/0) moves (op) rn, cea ? 9 2 12(0/1/x) move usp, an 0 0 2(0/1/0) move an, usp 0 0 2(0/1/0) swap dn 4 0 6(0/1/0) x = there is one bus cycle for byte and word operands and two bus cycles for long operands. for long bus cycles, add two clocks to the tail and to the number of cycles. *= each bus cycle may take up to four clocks without increasing total execution time. cr = control registers usp, vbr, sfc, and dfc n = number of registers to transfer rl = register list <= maximum time (certain data or mode combinations may execute faster). note: the moves instruction has an additional save step which other instructions do not have. to calculate the total instruction time, calculate the save, the ea, and the operation execution times, and combine in the order listed, using the equations given in 5.7.1.6 instruction execution time calculation . 5.7.3.5 arithmetic/logic instructions. the arithmetic/logic instruction table indicates the number of clock periods needed to perform the specified arithmetic/logical instruction using the specified addressing mode. footnotes indicate when to account for the appropriate ea times. the total number of clock cycles is outside the parentheses. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 103 the numbers inside parentheses (r/p/w) are included in the total clock cycle number. all timing data assumes two-clock reads and writes. instruction head tail cycles add(a) rn, rm 0 0 2(0/1/0) add(a) fea ? , rn 0 0 2(0/1/0) add dn, fea ? 0 3 5(0/1/x) and dn, dm 0 0 2(0/1/0) and fea ? , dn 0 0 2(0/1/0) and dn, fea ? 0 3 5(0/1/x) eor dn, dm 0 0 2(0/1/0) eor dn, fea ? 0 3 5(0/1/x) or dn, dm 0 0 2(0/1/0) or fea ? , dn 0 0 2(0/1/0) or dn, fea ? 0 3 5(0/1/x) sub(a) rn, rm 0 0 2(0/1/0) sub(a) fea ? , rn 0 0 2(0/1/0) sub dn, fea ? 0 3 5(0/1/x) cmp(a) rn, rm 0 0 2(0/1/0) cmp(a) fea ? , rn 0 0 2(0/1/0) cmp2 (save) * fea ? , rn 1 1 3(0/1/0) cmp2 (op) fea ? , rn 2 0 16-18(x/1/0) mul(su).w fea ? , dn 0 0 26(0/1/0) mul(su).l (save) * fea ? , dn 1 1 3(0/1/0) mul(su).l (op) fea ? , dl 2 0 46-52(0/1/0) mul(su).l (op) fea ? , dn:dl 2 0 46(0/1/0) divu.w fea ? , dn 0 0 32(0/1/0) divs.w fea ? , dn 0 0 42(0/1/0) divu.l (save) * fea ? , dn 1 1 3(0/1/0) divu.l (op) fea ? , dn 2 0 <46(0/1/0) divs.l (save) * fea ? , dn 1 1 3(0/1/0) divs.l (op) fea ? , dn 2 0 <62(0/1/0) tbl(su) dn:dm, dp 26 0 28-30(0/2/0) tbl(su) (save) * cea ? , dn 1 1 3(0/1/0) tbl(su) (op) cea ? , dn 6 0 33-35(2x/1/0) tblsn dn:dm, dp 30 0 30-34(0/2/0) tblsn (save) * cea ? , dn 1 1 3(0/1/0) tblsn (op) cea ? , dn 6 0 35-39(2x/1/0) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 104 mc68340 user? manual motorola instruction head tail cycles tblun dn:dm, dp 30 0 34-40(0/2/0) tblun (save) * cea ? , dn 1 1 3(0/1/0) tblun (op) cea ? , dn 6 0 39-45(2x/1/0) x = there is one bus cycle for byte and word operands and two bus cycles for long operands. for long bus cycles, add two clocks to the tail and to the number of cycles. <= maximum time (certain data or mode combinations may execute faster). su = the execution time is identical for signed or unsigned operands. * these instructions have an additional save operation that other instructions do not have. to calculate total instruction time, calculate save, ea ? , and operation execution times, then combine in the order shown, using equations in 5.7.1.6 instruction execution time calculations . a save operation is not run for long-word divide and multiply instructions when fea ? = dn, f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 105 5.7.3.6 immediate arithmetic/logic instructions. the immediate arithmetic/logic instruction table indicates the number of clock periods needed for the processor to fetch the source immediate data value and to perform the specified arithmetic/logic instruction using the specified addressing mode. footnotes indicate when to account for the appropriate fetch effective or fetch immediate ea times. the total number of clock cycles is outside the parentheses. the numbers inside parentheses (r/p/w) are included in the total clock cycle number. all timing data assumes two-clock reads and writes. instruction head tail cycles moveq #, dn 0 0 2(0/1/0) addq #, rn 0 0 2(0/1/0) addq #, fea ? 0 3 5(0/1/x) subq #, rn 0 0 2(0/1/0) subq #, fea ? 0 3 5(0/1/x) addi #, rn 0 0 2(0/1/0) * addi #, fea ? 0 3 5(0/1/x) * andi #, rn 0 0 2(0/1/0) * andi #, fea ? 0 3 5(0/1/x) * eori #, rn 0 0 2(0/1/0) * eori #, fea ? 0 3 5(0/1/x) * ori #, rn 0 0 2(0/1/0) * ori #, fea ? 0 3 5(0/1/x) * subi #, rn 0 0 2(0/1/0) * subi #, fea ? 0 3 5(0/1/x) * cmpi #, rn 0 0 2(0/1/0) * cmpi #, fea ? 0 3 5(0/1/x) * x = there is one bus cycle for byte and word operands and two bus cycles for long- word operands. for long-word bus cycles, add two clocks to the tail and to the number of cycles. *= an # fetch ea time must be added for this instruction: fea ? + fea ? + oper ? f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 106 mc68340 user? manual motorola 5.7.3.7 binary-coded decimal and extended instructions. the bcd and extended instruction table indicates the number of clock periods needed for the processor to perform the specified operation using the specified addressing mode. no additional tables are needed to calculate total effective execution time for these instructions. the total number of clock cycles is outside the parentheses. the numbers inside parentheses (r/p/w) are included in the total clock cycle number. all timing data assumes two-clock reads and writes. instruction head tail cycles abcd dn, dm 2 0 4(0/1/0) abcd - (an), - (am) 2 2 12(2/1/1) sbcd dn, dm 2 0 4(0/1/0) sbcd - (an), - (am) 2 2 12(2/1/1) addx dn, dm 0 0 2(0/1/0) addx - (an), - (am) 2 2 10(2/1/1) subx dn, dm 0 0 2(0/1/0) subx - (an), - (am) 2 2 10(2/1/1) cmpm (an)+, (am)+ 1 0 8(2/1/0) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 107 5.7.3.8 single operand instructions. the single operand instruction table indicates the number of clock periods needed for the processor to perform the specified operation using the specified addressing mode. the total number of clock cycles is outside the parentheses. the numbers inside parentheses (r/p/w) are included in the total clock cycle number. all timing data assumes two-clock reads and writes. instruction head tail cycles clr dn 0 0 2(0/1/0) clr cea ? 0 2 4(0/1/x) neg dn 0 0 2(0/1/0) neg fea ? 0 3 5(0/1/x) negx dn 0 0 2(0/1/0) negx fea ? 0 3 5(0/1/x) not dn 0 0 2(0/1/0) not fea ? 0 3 5(0/1/x) ext dn 0 0 2(0/1/0) nbcd dn 2 0 4(0/1/0) nbcd fea ? 0 2 6(0/1/1) scc dn 2 0 4(0/1/0) scc cea ? 2 2 6(0/1/1) tas dn 4 0 6(0/1/0) tas cea ? 1 0 10(0/1/1) tst fea ? 0 0 2(0/1/0) x = there is one bus cycle for byte and word operands and two bus cycles for long-word operands. for long-word bus cycles, add two clocks to the tail and to the number of cycles. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 108 mc68340 user? manual motorola 5.7.3.9 shift/rotate instructions. the shift/rotate instruction table indicates the number of clock periods needed for the processor to perform the specified operation on the given addressing mode. footnotes indicate when to account for the appropriate ea times. the number of bits shifted does not affect the execution time, unless noted. the total number of clock cycles is outside the parentheses. the numbers inside parentheses (r/p/w) are included in the total clock cycle number. all timing data assumes two-clock reads and writes. instruction head tail cycles note lsd dn, dm - 2 0 (0/1/0) 1 lsd #, dm 4 0 6(0/1/0) lsd fea ? 0 2 6(0/1/1) asd dn, dm - 2 0 (0/1/0) 1 asd #, dm 4 0 6(0/1/0) asd fea ? 0 2 6(0/1/1) rod dn, dm - 2 0 (0/1/0) 1 rod #, dm 4 0 6(0/1/0) rod fea ? 0 2 6(0/1/1) roxd dn, dm - 2 0 (0/1/0) 2 roxd #, dm - 2 0 (0/1/0) 3 roxd fea ? 0 2 6(0/1/1) d = direction (left or right) notes: 1. head and cycle times can be derived from the following table or calculated as follows: max (3 + (n/4) + mod(n,4) + mod (((n/4) + mod (n,4) + 1,2), 6) 2. head and cycle times are calculated as follows: (count 63): max (3 + n + mod (n + 1,2), 6). 3. head and cycle times are calculated as follows: (count 8): max (2 + n + mod (n,2), 6). clocks shift counts 6 01234568912 8 7 10 11 13 14 16 17 20 10 15 18 19 21 22 24 25 28 12 23 26 27 29 30 32 33 36 14 31 34 35 37 38 40 41 44 16 39 42 43 45 46 48 49 52 18 47 50 51 53 54 56 57 60 20 55 58 59 61 62 22 63 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 109 5.7.3.10 bit manipulation instructions. the bit manipulation instruction table indicates the number of clock periods needed for the processor to perform the specified operation on the given addressing mode. the total number of clock cycles is outside the parentheses. the numbers inside parentheses (r/p/w) are included in the total clock cycle number. all timing data assumes two-clock reads and writes. instruction head tail cycles bchg #, dn 2 0 6(0/2/0) * bchg dn, dm 4 0 6(0/1/0) bchg #, fea ? 1 2 8(0/2/1) * bchg dn, fea ? 2 2 8(0/1/1) bclr #, dn 2 0 6(0/2/0) * bclr dn, dm 4 0 6(0/1/0) bclr #, fea ? 1 2 8(0/2/1) * bclr dn, fea ? 2 2 8(0/1/1) bset #, dn 2 0 6(0/2/0) * bset dn, dm 4 0 6(0/1/0) bset #, fea ? 1 2 8(0/2/1) * bset dn, fea ? 2 2 8(0/1/1) btst #, dn 2 0 4(0/2/0) * btst dn, dm 2 0 4(0/1/0) btst #, fea ? 1 0 4(0/2/0) * btst dn, fea ? 2 0 8(0/1/0) * = an # fetch ea time must be added for this instruction: fea ? + fea ? + oper ? f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 110 mc68340 user? manual motorola 5.7.3.11 conditional branch instructions. the conditional branch instruction table indicates the number of clock periods needed for the processor to perform the specified branch on the given branch size, with complete execution times given. no additional tables are needed to calculate total effective execution time for these instructions. the total number of clock cycles is outside the parentheses. the numbers inside parentheses (r/p/w) are included in the total clock cycle number. all timing data assumes two-clock reads and writes. instruction head tail cycles bcc (taken) 2 - 2 8(0/2/0) bcc.b (not taken) 2 0 4(0/1/0) bcc.w (not taken) 0 0 4(0/2/0) bcc.l (not taken) 0 0 6(0/3/1) dbcc (t, not taken) 1 1 4(0/2/0) dbcc (f, - 1, not taken) 2 0 6(0/2/0) dbcc (f, not - 1, taken) 6 - 2 10(0/2/0) dbcc (t, not taken) 4 0 6(0/1/0) * dbcc (f, - 1, not taken) 6 0 8(0/1/0) * dbcc (f, not - 1, taken) 6 0 10(0/0/0) * * = in loop mode f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 111 5.7.3.12 control instructions. the control instruction table indicates the number of clock periods needed for the processor to perform the specified operation on the given addressing mode. footnotes indicate when to account for the appropriate ea times. the total number of clock cycles is outside the parentheses. the numbers inside parentheses (r/p/w) are included in the total clock cycle number. all timing data assumes two-clock reads and writes. instruction head tail cycles andi #, sr 0 - 2 12(0/2/0) eori #, sr 0 - 2 12(0/2/0) ori #, sr 0 - 2 12(0/2/0) andi #, ccr 2 0 6(0/2/0) eori #, ccr 2 0 6(0/2/0) ori #, ccr 2 0 6(0/2/0) bsr.b 3 - 2 13(0/2/2) bsr.w 3 - 2 13(0/2/2) bsr.l 1 - 2 13(0/2/2) chk fea ? , dn (no ex) 2 0 8(0/1/0) chk fea ? , dn (ex) 2 - 2 42(2/2/6) chk2 (save) fea ? , dn (no ex) 1 1 3(0/1/0) chk2 (op) fea ? , dn (no ex) 2 0 18(x/0/0) chk2 (save) fea ? , dn (ex) 1 1 3(0/1/0) chk2 (op) fea ? , dn (ex) 2 - 2 52(x + 2/1/6) jmp cea ? 0 - 2 6(0/2/0) jsr cea ? 3 - 2 13(0/2/2) lea cea ? , an 0 0 2(0/1/0) link.w an, # 2 0 10(0/2/2) link.l an, # 0 0 10(0/3/2) nop 0 0 2(0/1/0) pea cea ? 0 0 8(0/1/2) rtd # 1 - 2 12(2/2/0) rtr 1 - 2 14(3/2/0) rts 1 - 2 12(2/2/0) unlk an 1 0 9(2/1/0) x = there is one bus cycle for byte and word operands and two bus cycles for long-word operands. for long-word bus cycles, add two clocks to the tail and to the number of cycles. note: the chk2 instruction involves a save step which other instructions do not have. to calculate the total instruction time, calculate the save, the ea, and the operation execution times, and combine in the order listed using the equations given in 5.7.1.6 instruction execution time calculation . f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 5- 112 mc68340 user? manual motorola 5.7.3.13 exception-related instructions and operations. the exception- related instructions and operations table indicates the number of clock periods needed for the processor to perform the specified exception-related actions. no additional tables are needed to calculate total effective execution time for these instructions. the total number of clock cycles is outside the parentheses. the numbers inside parentheses (r/p/w) are included in the total clock cycle number. all timing data assumes two-clock reads and writes. instruction head tail cycles bkpt (acknowledged) 0 0 14(1/0/0) bkpt (bus error) 0 - 2 35(3/2/4) breakpoint (acknowledged) 0 0 10(1/0/0) breakpoint (bus error) 0 - 2 42(3/2/6) interrupt 0 - 2 30(3/2/4) * reset 0 0 518(0/1/0) stop 2 0 12(0/1/0) lpstop 3 - 2 25(0/3/1) divide-by-zero 0 - 2 36(2/2/6) trace 0 - 2 36(2/2/6) trap # 4 - 2 29(2/2/4) illegal 0 - 2 25(2/2/4) a-line 0 - 2 25(2/2/4) f-line (first word illegal) 0 - 2 25(2/2/4) f-line (second word illegal) ea = rn 1 - 2 31(2/3/4) f-line (second word illegal) ea 1 rn (save) 1 1 3(0/1/0) f-line (second word illegal) ea 1 rn (op) 4 - 2 29(2/2/4) privileged 0 - 2 25(2/2/4) trapcc (trap) 2 - 2 38(2/2/6) trapcc (no trap) 2 0 4(0/1/0) trapcc.w (trap) 2 - 2 38(2/2/6) trapcc.w (no trap) 0 0 4(0/2/0) trapcc.l (trap) 0 - 2 38(2/2/6) trapcc.l (no trap) 0 0 6(0/3/0) trapv (trap) 2 - 2 38(2/2/6) trapv (no trap) 2 0 4(0/1/0) * = minimum interrupt acknowledge cycle time is assumed to be three clocks. note: the f-line (second word illegal) operation involves a save step which other operations do not have. to calculate the total operation time, calculate the save, the calculate ea, and the operation execution times, and combine in the order listed, using the equations given in 5.7.1.6 instruction execution time calculation . f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 5- 113 5.7.3.14 save and restore operations. the save and restore operations table indicates the number of clock periods needed for the processor to perform the specified state save or return from exception. complete execution times and stack length are given. no additional tables are needed to calculate total effective execution time for these instructions. the total number of clock cycles is outside the parentheses. the numbers inside parentheses (r/p/w) are included in the total clock cycle number. all timing data assumes two-clock reads and writes. instruction head tail cycles berr on instruction 0 - 2 < 58(2/2/12) berr on exception 0 - 2 48(2/2/12) rte (four-word frame) 1 - 2 24(4/2/0) rte (six-word frame) 1 - 2 26(4/2/0) rte (berr on instruction) 1 - 2 50(12/12/y) rte (berr on four-word frame) 1 - 2 66(10/2/4) rte (berr on six-word frame) 1 - 2 70(12/2/6) < = maximum time is indicated (certain data or mode combinations execute faster). y = if a bus error occurred during a write cycle, the cycle is rerun by the rte. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 6- 1 section 6 dma controller module the direct memory access (dma) controller module provides for high-speed transfer capability to/from an external peripheral or for memory-to-memory data transfer. the dma module, shown in figure 6-1, provides two channels that allow byte, word, or long-word operand transfers. these transfers can be either single or dual address and to either on- or off-chip devices. the dma contains the following features: two, independent, fully programmable dma channels single-address transfers with 32-bit address and 32-bit data capability dual-address transfers with 32-bit address and 16-bit data capability two 32-bit transfer counters four 32-bit address pointers that can increment or remain constant operand packing and unpacking for dual-address transfers supports all bus-termination modes provides two-clock-cycle internal module access provides two-clock-cycle external access using mc68340 chip selects provides full dma handshake for burst transfers and cycle steal . interrupt arbitration slave biu master biu bus arbitration i m b dma channel 2 dma channel 1 dma handshak e signals dma handshak e signals figure 6-1. dma block diagram f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 6- 2 mc68340 user? manual motorola 6.1 dma module overview the main purpose of the dma controller module is to transfer data at very high rates, usually much faster than the cpu32 under software control can handle. the term dma is used to refer to the ability of a peripheral device to access memory in a system in the same manner as a microprocessor does. dma operations can greatly increase overall system performance. the mc68340 dma module consists of two, independent, programmable channels. the term dma is used throughout this section to reference either channel 1 or channel 2 since the two are functionally equivalent. each channel has independent request, acknowledge, and done signals. however, both channels cannot own the bus at the same time. therefore, it is impossible to implicitly address both dma channels at the same time. the mc68340 on-chip peripherals do not support the single-address transfer mode. dma requests may be internally generated by the channel or externally generated by a device. for an internal request, the amount of bus bandwidth allocated for the dma can be programmed. the dma channels support two external request modes: burst mode and cycle steal mode. the dma controller supports single- and dual-address transfers. in single-address mode, a channel supports 32 bits of address and 32 bits of data. only an external request can be used to start a transfer in the single-address mode. the dma provides address and control signals during a single-address transfer. the requesting device either sends or receives data to or from the specified address (see figure 6-2). in dual-address mode, a channel supports 32 bits of address and 16 bits of data. the dual-address transfers can be started by either the internal request mode or by an external device using the request signal. in this mode, two bus transfers occur, one from a source device and the other to a destination device (see figure 6-3). in dual-address mode, operands are packed or unpacked according to port sizes and addresses. any operation involving the dma will follow the same basic steps: channel initialization, data transfer, and channel termination. in the channel initialization step, the dma channel registers are loaded with control information, address pointers, and a byte transfer count. the channel is then started. during the data transfer step, the dma accepts requests for operand transfers and provides addressing and bus control for the transfers. the channel termination step occurs after operation is complete. the channel indicates the status of the operation in the channel status register. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 6- 3 . dma dma peripheral memory memory dma peripheral peripheral figure 6-2. single-address transfers .. . memory dma memory figure 6-3. dual-address transfer f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 6- 4 mc68340 user? manual motorola 6.2 dma module signal definitions this section contains a brief description of the dma module signals used to provide handshake control for either a source or destination external device. note the terms assertion and negation are used throughout this section to avoid confusion when dealing with a mixture of active-low and active-high signals. the term assert or assertion indicates that a signal is active or true, independent of the level represented by a high or low voltage. the term negate or negation indicates that a signal is inactive or false. 6.2.1 dma request ( dreq ? ) this active-low input is asserted by a peripheral device to request an operand transfer between that peripheral and memory. the assertion of dreq ? starts the dma process. the assertion level in external burst mode is level sensitive; in external cycle steal mode, it is falling-edge sensitive. 6.2.2 dma acknowledge ( dack ? ) this active-low output is asserted by the dma to signal to a peripheral that an operand is being transferred in response to a previous transfer request. 6.2.3 dma done ( done ? ) this active-low bidirectional signal is asserted by the dma or a peripheral device during any dma bus cycle to indicate that the last data transfer is being performed. done ? is an active input in any mode. as an output, done ? is only active in external request mode. an external pullup resistor is required even if operating only in the internal request mode. 6.3 transfer request generation the dma channel supports two types of request generation methods: internal and external. internally generated requests can be programmed to limit the amount of bus utilization. externally generated requests can be either burst mode or cycle steal mode. the request generation method used for the channel is programmed by the channel control register (ccr) in the req field. 6.3.1 internal request generation internal requests are accessed in two clocks by the intermodule bus (imb). the channel is started as soon as the str bit in the ccr is set. the channel immediately requests the bus and begins transferring data. only internal requests can limit the amount of bus utilization. the percentage of the bandwidth that the dma channel can use during a transfer can be selected by the ccr bb field. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 6- 5 6.3.1.1 internal request, maximum rate. internal generation using 100% of the internal bus always has a transfer request pending for the channel until the transfer is complete. as soon as the channel is started, the dma will arbitrate for the internal bus and begin to transfer data when it becomes bus master. if no exceptions occur, all operands in the data block will be transferred in one burst so that the dma will use 100% of the available bus bandwidth. 6.3.1.2 internal request, limited rate. to guarantee that the dma will not use all of the available bus bandwidth during a transfer, internal requests can be generated according to the amount of bus bandwidth allocated to the dma. there are three programmed constants in the ccr used to monitor the bus activity and allow the dma to use a percentage of the bus bandwidth. options are 25%, 50%, and 75% of 1024 clock periods. see table 6-5 for more information. 6.3.2 external request generation to control the transfer of operands to or from memory in an orderly manner, a peripheral device uses the dreq ? input signal to request service. if the channel is programmed for external request and the ccr str bit is set, an external request ( dreq ? ) signal must be asserted before the channel requests the bus and begins a transfer. the dma supports external burst mode and external cycle steal mode. the generation of the request from the source or destination is specified by the eco bit of the ccr. the external requests can be for either single- or dual-address transfers. 6.3.2.1 external burst mode. for external devices that require very high data transfer rates, the burst request mode allows the dma channel to use all of the bus bandwidth under control of the external device. in burst mode, the dreq ? input to the dma is level sensitive and is sampled at certain points to determine when a valid request is asserted by the device. the device requests service by asserting dreq ? and leaving it asserted. in response, the dma arbitrates for the bus and performs an operand transfer. during each operand transfer, the dma asserts dma acknowledge ( dack ? ) to indicate to the device that a request is being serviced. dack ? is asserted on the cycle of either the source or destination device, depending on which one generated the request as programmed by the ccr eco bit. to allow more than one transfer to be recognized, dreq ? must meet the asynchronous setup and hold times while dack ? is asserted in the dma bus cycle. upon completion of a request, dreq ? should be held asserted (bursting) into the following dma bus cycle to allow another transfer to occur. the recognized request will immediately be serviced. if dreq ? is negated before dack ? is asserted, a new request is not recognized, and the dma channel releases ownership of the bus. 6.3.2.2 external cycle steal mode. for external devices that generate a pulsed signal for each operand to be transferred, the cycle steal request mode uses the dreq ? signal as a falling-edge-sensitive input. the dreq ? pulse generated by the device must be asserted during two consecutive falling edges of the clock to be recognized as valid. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 6- 6 mc68340 user? manual motorola therefore, if a peripheral generates it asynchronously, it must be at least two clock periods long. the dma channel responds to cycle steal requests the same as all other requests. however, if subsequent dreq ? pulses are generated before dack ? is asserted in response to each request, they are ignored. if dreq ? is asserted after the dma channel asserts dack ? for the previous request but before dack ? is negated, then the new request is serviced before bus ownership is released. if a new request is not generated by the time dack ? is negated, the bus is released. 6.3.2.3 external request with other modules. the dma controller can be externally connected to the serial module and used in conjunction with the serial module to send or receive data. the dma takes the place of a separate service routine for accessing or storing data that is sent or received by the serial module. using the dma also lowers the cpu32 overhead required to handle the data transferred by the serial module. figure 6-4 shows the external connections required for using the dma with the serial module. . .. dma module dreq1 dreq2 txrdya rxrdya serial module figure 6-4. dma external connections to serial module for serial receive, the dma reads data from the serial receive buffer (rb) register (when the serial module has filled the buffer on input) and writes data to memory. for serial transmit, the dma reads data from memory and writes data to the serial transmit buffer (tb) register. only dual-address mode can be used with the serial module. the mc68340 on-chip peripherals do not support single-address transfers. the timer modules can be used with the dma in a similar manner. by connecting toutx to dreq ? , the timer can request a dma transfer. 6.4 data transfer modes the dma channel supports single- and dual-address transfers. the single-address transfer mode consists of one dma bus cycle, which allows either a read or a write cycle to occur. the dual-address transfer mode consists of a source operand read and a destination operand write. two dma bus cycles are executed for the dual-address mode: a dma read cycle and a dma write cycle. 6.4.1 single-address mode the single-address dma bus cycle allows data to be transferred directly between a device and memory without going through the dma. in this mode, the operand transfer takes f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 6- 7 place in one bus cycle, where only the memory is explicitly addressed. the dma bus cycle may be either a read or a write cycle. the dma provides the address and control signals required for the operation. the requesting device either sends or receives data to or from the specified address. only external requests can be used to start a transfer when the single-address mode is selected. an external device uses dreq ? to request a transfer. each dma channel can be independently programmed to provide single-address transfers. the ccr eco bit controls whether a source read or a destination write cycle occurs on the data bus. if the eco bit is set, the external handshake signals are used with the source operand and a single-address source read occurs. if the eco bit is cleared, the external handshake signals are used with the destination operand, and a single- address destination write occurs. the channel can be programmed to operate in either burst transfer mode or cycle steal mode. see 6.7 register description for more information. if external 32-bit devices and a 32-bit bus are used with the mc68340, the dma can control 32-bit transfers between devices that use the 32-bit bus in single-address mode only. external logic is required to complete a 32-bit (long-word) transfer. if both byte and word devices are used on an external bus, then an external multiplexer must be used to correctly transfer data. the sizx and a0 signals can be used to control this external multiplexer. 6.4.1.1 single-address read. during the single-address source (read) cycle, the dma controls the transfer of data from memory to a device. the memory selected by the address specified in the source address register (sar), the source function codes in the function code register (fcr), and the source size in the ccr provides the data and control signals on the data bus. this bus cycle operates like a normal read bus cycle. the dma control signals ( dack ? and done ? ) are asserted in the source (read) cycle. see figures 6-5 and 6-6 for timing diagrams single-address read for external burst and cycle steal modes. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 6- 8 mc68340 user? manual motorola .. .. . a31?0 fc3?c0 siz1?iz0 r/w as ds dsackx s0 s2 s4 s0 s2 s4 s0 s2 s4 s0 d15?0 dreqx dackx donex (output) cpu cycle dma read cpu cycle note: 1. timing to generate more than one dma request. 2. dackx and donex (dma control signals) are asserted in the source (read) dma cycle. 3. dreqx must be asserted while dackx is asserted and meet the setup and hold times for more than one dma transfer to be recognized. dma read clkout donex (input) figure 6-5. single-address read timing (external burst) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user?s manual 6- 9 note: 1. dreqx must be active for two consecutive clocks for a dma request to be recognized. 2. to cause another dma transfer, dreqx is asserted after dackx is asserted and before dackx is negated. 3. dackx and donex (dma control signals) are asserted in the source (read) dma cycle. a31ea0 r/w as ds s0 s2 s4 s0 s2 s4 s0 s2 s4 s0 s2 s4 s0 s2 s4 d15ed0 dreqx dackx dma read cpu cycle cpu cycle cpu cycle dma read donex (input) figure 6-6. single-address read timing (cycle steal) fc3efc0 siz1esiz0 dsackx donex (output) clkout f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 6- 10 mc68340 user? manual motorola 6.4.1.2 single-address write. during the single-address destination (write) cycle, the dma controls the transfer of data from a device to memory. the data is written to memory selected by the address specified in the destination address register (dar), the destination function codes in the fcr, and the size in the ccr. the destination (write) dma bus cycle has timing identical to a write bus cycle. the dma control signals ( dack ? and done ? ) are asserted in the destination (write) cycle. see figures 6-7 and 6-8 for timing diagrams of single-address write for external burst and cycle steal modes. . a31ea0 fc3efc0 siz1-siz0 r/w as ds dsackx s0 s2 s4 s0 s2 s4 s0 s2 s4 s0 d15ed0 dreqx dackx donex (output) cpu cycle dma write cpu cycle note: 1. timing to generate more than one dma request. 2. dackx and donex (dma control signals) are asserted in the source (read) dma cycle. 2. dreqx must be asserted while dackx is asserted, and meet the setup and hold times for more than one dma transfer to be recognized. dma write clkout donex (input) figure 6-7. single-address write timing (external burst) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user?s manual 6- 11 a31ea0 fc3efc0 siz1-siz0 r/w as ds dsackx s0 s2 s4 s0 s2 s4 s0 s2 s4 s0 s2 s4 s0 s2 s4 d15ed0 dreqx dackx dma write cpu cycle note: 1. dreqx must be active for two consecutive clocks for a dma request to be recognized. 2. to cause another dma transfer, dreqx is asserted after dackx is asserted and before dackx is negated. 3. dackx and donex (dma control signals) are asserted in the destination (write) dma cycle. clkout cpu cycle dma write donex (input) figure 6-8. single-address write timing (cycle steal) cpu cycle donex (output) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 6- 12 mc68340 user? manual motorola 6.4.2 dual-address mode the dual-address dma bus cycle transfers data between a device or memory and the dma internal holding register (dhr). in this mode, any operand transfer takes place in two dma bus cycles, one where a device is addressed and one where memory is addressed. the data transferred during a dual-address operation is either read from the data bus into the dhr or written from the dhr to the data bus. each dma channel can each be programmed to operate in the dual-address transfer mode. in this mode, the operand is read from the source address specified in the sar and placed in the dhr. the operand read may take up to four bus cycles to complete because of differences in operand sizes of the source and destination. the operand is then written to the address specified in the dar. this transfer may also be up to four bus cycles long. in this manner, various combinations of peripheral, memory, and operand sizes may be used. see 6.7 register description for more information. the dual-address transfers can be started by either the internal request mode or by an external device using the dreq ? input signal. when the external device uses dreq ? , the channel can be programmed to operate in either burst transfer mode or cycle steal mode. 6.4.2.1 dual-address read. during the dual-address read cycle, the dma reads data from a device or memory into the internal dhr. the device or memory is selected by the address specified in the sar, the source function codes in the fcr, and the source size in the ccr. data is read from the memory or peripheral and placed in the dhr when the bus cycle is terminated. when the complete operand has been read, the sar is incremented by 0, 1, 2, or 4, according to the size and increment information specified by the ssize and sapi bits of the ccr. the dma control signals ( dack ? and done ? ) are asserted in the source (read) cycle when the source device makes a request. see figures 6-9 and 6-10 for timing diagrams of dual-address read for external burst and cycle steal modes. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user?s manual 6- 13 note: 1. timing to generate more than one dma transfer. 2. dackx and donex (dma control signals) are asserted in the source (read) dma cycle. 3. dreqx must be asserted while dackx is asserted and meet the setup and hold times for more than one dma transfer to be recognized. 4. donex (input) can be asserted in either the read or write dma bus cycle to indicate that the next dma transfer will be the last one. clkout a31ea0 fc3efc0 siz1esiz0 r/w as ds dsackx s0 s2 s4 s0 s2 s4 s0 s2 s4 s0 s2 s4 s0 s2 s4 s0 s2 s4 d15ed0 dreqx dackx donex (output) cpu cycle dma write dma read dma write dma read cpu cycle donex (input) figure 6-9. dual-address read timing (external burstesource requesting) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 6- 14 mc68340 user?s manual motorola note 1. dreqx must be active for two consecutive clocks for a dma request to be recognized. 2. to cause another dma transfer, the dreqx is asserted after dackx is asserted and before dackx is negated. 3. dackx and donex (dma control signals) are asserted in the source (read) dma cycle. 4. donex (input) can be asserted in either the read or write dma bus cycle to indicate that the next dma transfer will be the last one. a31ea0 fc3efc0 siz1esiz0 r/w as ds dsackx s0 s2 s4 s0 s2 s4 s0 s2 s4 s0 s2 s4 s0 s2 s4 d15ed0 dreqx dackx donex (output) dma read cpu cycle clkout cpu cycle cpu cycle dma write dma read dma write s0 s2 s4 s0 s2 s4 donex (input) figure 6-10. dual-address read timing (cycle stealesource requesting) 6.4.2.2 dual-address write. during the dual-address write cycle, the dma writes data to a device or memory from the internal dhr. the data in the dhr is written to the device or memory selected by the address in the dar, the destination function codes in f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 6- 15 the fcr, and the size in the ccr. when the complete operand is written, the dar is incremented by 0, 1, 2, or 4, according to the increment and size information specified by the dapi and dsize bits of the ccr, and the byte transfer count register (btc) is decremented by the number of bytes transferred. if the btc is equal to zero and there were no errors, the csr done bit is set, and the done ? signal for the dma handshake is asserted. the dma control signals ( dack ? and done ? ) are asserted in the destination (write) cycle when the destination device makes a request. see figures 6-11 and 6-12 for timing diagrams of dual-address write for external burst and cycle steal modes. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 6- 16 mc68340 user?s manual motorola note: 1. timing to generate more than one dma transfer. 2. dackx and donex (dma control signals) are asserted in the destination (write) dma cycle. 3. dreqx must be asserted while dackx is asserted and meet the setup and hold times for more than one dma transfer to be recognized. 4. donex (input) can be asserted in either the read or write dma bus cycle to indicate that the next dma transfer will be the last one. clkout a31ea0 fc3efc0 siz1esiz0 r/w as ds dsackx s0 s2 s4 s0 s2 s4 s0 s2 s4 s0 s2 s4 s0 s2 s4 s0 s2 s4 d15ed0 dreqx dackx donex (output) cpu cycle dma write dma read dma write dma read cpu cycle donex (input) figure 6-11. dual-address write timing (external burstedestination requesting) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user?s manual 6- 17 a31ea0 fc3efc0 siz1esiz0 r/w as ds dsackx s0 s2 s4 s0 s2 s4 s0 s2 s4 s0 s2 s4 s0 s2 s4 d15ed0 dreqx dackx donex (output) dma read cpu cycle note: 1. dreqx must be active for two consecutive clocks for a dma request to be recognized. 2. to cause another dma transfer, dreqx is asserted after dackx is asserted and before dackx is negated. 3. dackx and donex (dma control signals) are asserted in the destination (write) dma cycle. 4. donex (input) can be asserted in either the read or write dma bus cycle to indicate that the next dma transfer will be the last one. clkout cpu cycle cpu cycle dma write dma read dma write s0 s2 s4 s0 s2 s4 donex (input) figure 6-12. dual-address write timing (cycle stealedestination requesting) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 6- 18 mc68340 user? manual motorola 6.5 bus arbitration the dma controller module uses the m68000 bus arbitration protocol to request bus mastership for dma transfers. each channel arbitrates for the bus independently. the source (read) dma bus cycle has timing identical to a read bus cycle. the destination (write) dma bus cycle has timing identical to a write bus cycle. however, the dma channel transfers are unique in one respect?c3 can be asserted during the source operand bus cycle and remain asserted until the end of the destination operand bus cycle. for internal request generation as soon as the ccr str bit is set, the dma channel arbitrates for the bus and begins to transfer data when it becomes bus master. for external request generation, the str bit must be set and a dreq ? signal must be asserted before the channel arbitrates for the bus and begins a transfer. 6.6 dma channel operation the following paragraphs describe the programmable channel functions available for the dma channel, the data transfer operations, and behavior during cycle termination. this description applies to both channels. any dma channel operation adheres to the following basic sequence: 1. channel initialization and startup?he channel registers are initialized. the channel is then started by setting the ccr str bit. the first operand transfer request (either internally or externally generated) is recognized. 2. data transfer?fter a channel is started, it transfers one operand in response to each request until an entire data block is transferred. 3. channel termination?he channel can terminate by normal completion or from an error. the channel status register (csr) indicates the status of the operation. 6.6.1 channel initialization and startup before starting a block transfer operation, the channel registers must be initialized with information describing the channel configuration, request generation method, and data block. this initialization is accomplished by programming the appropriate information into the channel registers. the sar is loaded with the source (read) address. if the transfer is from a peripheral device to memory, the source address is the location of the peripheral data register. if the transfer is from memory to a peripheral device or memory to memory, the source address is the starting address of the data block. this address may be any byte address. in the single-address mode with the destination (write) device requesting mode of operation, this register is not used. the dar should contain the destination (write) address. if the transfer is from a peripheral device to memory or memory to memory, the dar is loaded with the starting address of the data block to be written. if the transfer is from memory to a peripheral device, the dar is loaded with the address of the peripheral data register. this address may be any byte f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 6- 19 address. in the single-address mode with the source (read) device requesting mode of operation, this register is not used. the manner in which the sar and dar change after each cycle depends upon the values in the ccr ssize and dsize fields and sapi and dapi bits, and the starting address in the sar and dar. if programmed to increment, the increment value is 1, 2, or 4 for byte, word, or long-word operands, respectively. if the address register is programmed to remain unchanged (no count), the register is not incremented after the operand transfer. the sar and dar are incremented if a bus error terminates the transfer. therefore, either the sar or the dar contain the next address after the one that caused the bus error. the btc must be loaded with the number of byte transfers that are to occur. this register is decremented by 1, 2, or 4 at the end of each transfer. the fcr must be loaded with the source and destination function codes. although these function codes may not be used in the address decode for the memory or peripheral, they are provided if needed. the csr must be cleared for channel startup. once the channel has been initialized, it is started by writing a one to the str bit in the ccr. programming the channel for internal request causes the channel to request the bus and start transferring data immediately. if the channel is programmed for external request, dreq ? must be asserted before the channel requests the bus. the dreq ? input is ignored until the channel is started, since the channel does not recognize transfer requests until it is active. if any fields in the ccr are modified while the channel is active, that change is effective immediately. to avoid any problems with changing the setup for the dma channel, a zero should be written to the str bit in the ccr to halt the dma channel at the end of the current bus cycle. 6.6.2 data transfers each operand transfer requires from one to five bus cycles to complete. once a bus request is recognized and the operand transfer begins, both the source (read) cycle and/or the destination (write) cycle occur before a new bus request may be honored, even if the new bus request is of higher priority. 6.6.2.1 internal request transfers. internally generated request transfers are accessed as two-clock bus cycles. (the imb can access on-chip peripherals in two clocks.) the percentage of bus bandwidth utilization can be limited for internal request transfers. 6.6.2.2 external request transfers. in single-address mode, only one bus cycle is run for each request. since the operand size must be equal to the device port size in single-address mode, the number of normally terminated bus cycles executed during a transfer operation is always equal to the value programmed into the corresponding size field of the ccr. the sequencing of the address bus follows the programming of the ccr and address register (sar or dar) for the channel. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 6- 20 mc68340 user? manual motorola each operand transfer in dual-address mode requires from two to five bus cycles in response to each operand transfer request. if the source and destination operands are the same size, two cycles will transfer the complete operand. if the source and destination operands are different sizes, the number of cycles will vary. if the source is a long-word and the destination is a byte, there would be one bus cycle for the read and four bus cycles for the write. once the dma channel has started a dual-address operand transfer, it must complete that transfer before releasing ownership of the bus or servicing a request for another channel of equal or higher priority, unless one of the bus cycles is terminated with a bus error during the transfer. 6.6.3 channel termination the channel can terminate by normal completion or from an error. the status of a dma operation can be determined by reading the csr. the dma channel can also interrupt the processor to inform it of errors, normal transfer completion, or breakpoints. the fast termination option can also be used to provide a two-clock access for external requests. 6.6.3.1 channel termination. the channel operation can be terminated for several reasons: the btc is decremented to zero, a peripheral device asserts done ? during an operand transfer, the str bit is cleared in the ccr, a bus cycle is terminated with a bus error, or a reset occurs. 6.6.3.2 interrupt operation. interrupts can be generated by error termination of a bus cycle or by normal channel completion. specifically, if the ccr interrupt error (inte) bit is set and a bus error on source (ccr bes) bit, bus error on destination (ccr bed) bit, or configuration error (ccr conf) bit is set, the ccr irq bit is set. in this case, clearing the inte, bes, bed, or conf bits causes the irq bit to be cleared. if the interrupt normal (ccr intn) bit is set and the ccr done bit is set, the irq bit is set. in this case, clearing the intn or the done bit causes the irq bit to be cleared. if the interrupt breakpoint (ccr intb) and the csr brkp bits are set, the irq bit is set. clearing intb or brkp clears irq. 6.6.3.3 fast termination option. using the system integration module (sim40) chip select logic, the fast termination option (figure 6-13) can be employed to give a fast bus access of two clock cycles rather than the standard three-cycle access time for external requests. the fast termination option is described in section 3 bus operation and section 4 system integration module . f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 6- 21 . .. .. .. . . . . .. .. .. note: 1. to cause another dma transfer, dreqx is asserted after dackx is asserted and before dackx is negated. 2. dackx and donex (dma control signals) are asserted in the source (read) dma cycle. a31?0 fc3?c0 siz1?iz0 r/w as ds dsackx s0 s2 s4 s0 s4 s0 s2 s4 s0 s2 d15?0 dreqx dackx donex (output) dma read cpu cycle clkout cpu cycle dma read figure 6-13. fast termination option (cycle steal) if the fast termination option is used with external burst request mode (figure 6-14), an extra dma cycle may result on every burst transfer. normally, dreq ? is negated when dack ? is returned. in the burst mode with fast termination selected, a new cycle starts even if dreq ? is negated simultaneously with dack ? assertion. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 6- 22 mc68340 user? manual motorola .. .. . note 1. to cause another dma transfer, the dreqx is asserted after dackx is asserted and before dackx is negated. 2. dackx and donex (dma control signals) are asserted in the source (read) dma cycle. a31?0 fc3?c0 siz1?iz0 r/w as ds dsackx s0 s2 s4 s0 s0 s0 s4 d15?0 dreqx dackx donex (output) dma read cpu cycle clkout cpu cycle dma write dma read dma write s0 s4 s4 s0 s0 s4 s4 s2 figure 6-14. fast termination option (external burst?ource requesting) 6.7 register description the following paragraphs contain a detailed description of each register and its specific function. figure 6-15 is a programmer's model (register map) of all registers in the dma module. each channel has an independent set of registers. for more information about a particular register, refer to the individual register description. the address column indicates the offset of the register from the base address of the dma channel. the fc column designation of s indicates that register access is restricted to supervisor only. a designation of s/u indicates that access is governed by the supv bit in the module configuration register (mcr). unimplemented memory locations return logic zero when accessed. all registers support both byte and word transfers. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 6- 23 address fc ch1 ch2 15 8 7 0 780 7a0 s module configuration register (mcr) 782 7a2 s reserved 784 7a4 s interrupt register 786 7a6 s/u reserved 788 7a8 s/u channel control register 78a 7aa s/u channel status register function code register 78c 7ac s/u source address register msbs 78e 7ae s/u source address register lsbs 790 7b0 s/u destination address register msbs 792 7b2 s/u destination address register lsbs 794 7b4 s/u byte transfer counter msbs 796 7b6 s/u byte transfer counter lsbs 798 7b8 s/u reserved 79a 7ba s/u reserved 79c 7bc s/u reserved 79e 7be s/u reserved figure 6-15. dma module programming model in the registers discussed in the following paragraphs, the numbers in the upper right- hand corner indicate the offset of the register from the base address specified by the module base address register (mbar) in the sim40. the first number is the offset for channel 1; the second number is the offset for channel 2. the numbers above the register represent the bit position in the register. the register contains the mnemonic for the bit. the value of these bits after a hardware reset is shown below the register. the access privilege is shown in the lower right-hand corner. note a cpu32 reset instruction will not affect the mcr but will reset all other registers in the dma module as though a hardware reset occurred. the term dma is used to reference either channel 1 or channel 2, since the two are functionally equivalent. 6.7.1 module configuration register (mcr) the mcr controls the dma channel configuration. each dma channel has an mcr. this register can be either read or written when the channel is enabled and is in the supervisor state. the mcr is not affected by a cpu32 reset instruction. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 6- 24 mc68340 user? manual motorola mcr1, mcr2 $780, $7a0 1514131211109876543210 stp frz1 frz0 se 0 ism supv maid iarb reset: 0000000010000000 supervisor only stp?top bit 1 = setting the stp bit stops all clocks within the dma module except for the clock from the imb. the clock from the imb remains active to allow the cpu32 access to the mcr. the clock stops on the low phase of the clock and remains stopped until the stp bit is cleared by the cpu32 or a hardware reset. accesses to dma module registers while in stop mode produce a bus error. the dma module should be disabled in a known state before setting the stp bit. the stp bit should be set prior to executing the lpstop instruction to reduce overall power consumption. 0 = the channel operates in normal mode. note the dma module uses only one stp bit for both channels. a read or write to either mcr accesses the same stp control bit. frz1, frz0?reeze these bits determine the action taken when the freeze signal is asserted on the imb when the cpu32 has entered background debug mode. the dma module negates br and keeps it negated until freeze is negated or reset. table 6-1 lists the action taken for each bit combination. table 6-1. frzx control bits frz1 frz0 action 0 0 ignore freeze 0 1 reserved 1 0 freeze on boundary* 1 1 reserved *the boundary is defined as any bus cycle by the dma module. note the dma module uses only one set of frzx bits for both channels. a read or write to either mcr accesses the same frzx control bits. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 6- 25 se?ingle-address enable this bit is implemented for future mc683xx family compatibility. 1 = in single-address mode, the external data bus is driven during a dma transfer. 0 = in single-address mode, the external data bus remains in a high-impedance state during a dma transfer (used for intermodule dma). in dual-address mode, the se bit has no effect. bit 11?eserved ism2?sm0?nterrupt service mask these bits contain the interrupt service mask level for the channel. when the interrupt service level on the imb is greater than the interrupt service mask level, the dma vacates the bus and negates br until the interrupt service level is less than or equal to the interrupt service mask level. note when the cpu32 status register (sr) interrupt priority mask bits i2?0 are at a higher level than the dma ism bits, the dma channel will not start. the channel will begin operation when the level of the sr i2?0 bits is less than or equal to the level of the dma ism bits. supv?upervisor/user the value of this bit has no effect on registers permanently defined as supervisor-only access. 1 = the dma channel registers defined as supervisor/user reside in supervisor data space and are only accessible from supervisor programs. 0 = the dma channel registers defined as supervisor/user reside in user data space and are accessible from either supervisor or user programs. maid?aster arbitration id these bits establish bus arbitration priority level among modules that have the capability of becoming bus master. for the mc68340, the maid bits are used to arbitrate between dma channel 1 and channel 2. if both channels are programmed with the same maid level, channel 1 will have priority. these bits are implemented for future mc683xx family compatibility. in the mc68340, only the sim and the dma can be bus masters. however, future versions of the mc683xx family may incorporate other modules that may also be bus masters. for these devices, the maid bits will be required. for the maid bits, zero is the lowest priority and seven is the highest priority. iarb ?interrupt arbitration id each module that generates interrupts has an iarb field. these bits are used to arbitrate for the bus in the case that two or more modules simultaneously generate an interrupt at the same priority level. no two modules can share the same iarb value. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 6- 26 mc68340 user? manual motorola the reset value of the iarb field is $0, which prevents the dma module from arbitrating during the interrupt acknowledge cycle. the system software should initialize the iarb field to a value from $f (highest priority) to $1 (lowest priority). note the dma module uses only one set of iarb bits for both channels. a read or write to either mcr accesses the same iarb control bits. 6.7.2 interrupt register (intr) the intr contains the priority level for the channel interrupt request and the 8-bit vector number of the interrupt. the register can be read or written to at any time while in supervisor mode and while the dma module is enabled (i.e., the stp bit in the mcr is cleared). intr1, intr2 $784, $7a4 1514131211109876543210 00000 intl intv reset: 0000000000001111 supervisor only bits 15?1?eserved intl?nterrupt level bits each module that can generate interrupts has an interrupt level field. the interrupt level field contains the priority level of the interrupt for its associated channel. the priority level encoded in these bits is sent to the cpu32 on the appropriate irq ? signal. the cpu32 uses this value to determine servicing priority. see section 5 cpu32 for more information. intv?nterrupt vector bits each module that can generate interrupts has an interrupt vector field. the interrupt vector field contains the vector number of the interrupt for its associated channel. this 8-bit number indicates the offset from the base of the vector table where the address of the exception handler for the specified interrupt is located. the intv field is reset to $0f, which indicates an uninitialized interrupt condition. see section 5 cpu32 for more information. 6.7.3 channel control register (ccr) the ccr controls the configuration of the dma channel. this register is accessible in either supervisor or user space. the ccr can always be read or written to when the dma module is enabled (i.e., the stp bit in the mcr is cleared). f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 6- 27 ccr1, ccr2 $788, $7a8 1514131211109876543210 intb intn inte eco sapi dapi ssize dsize req bb s/d str reset: uuuuuuuuuuuuuuu0 u = unaffected by reset supervisor/user intb?nterrupt breakpoint setting the interrupt breakpoint bit sets the brkp bit in the csr. the logic and of intb and brkp generates an interrupt request. 1 = enables an irq ? when a breakpoint is recognized and the channel is the bus master. 0 = does not enable an irq ? when a breakpoint is recognized and the channel is the bus master. intn?nterrupt normal 1 = enables an irq ? when the channel finishes a transfer without an error condition (csr done bit is set). 0 = does not enable an irq ? when the channel finishes a transfer without an error condition. inte?nterrupt error 1 = enables an irq ? when the channel encounters an error on source read (csr bes bit is set), destination write (csr bed bit is set), or configuration for channel setup (csr conf bit is set). 0 = does not enable an irq ? when the channel encounters an error on source read, destination write, or configuration for channel setup. eco?xternal control option if request generation is programmed to be internal (req bits = 00), this bit has no effect. single-address mode?his bit defines the direction of transfer. 1 = if request generation is programmed to be external (req = 1x), the requesting device receives the data (read from memory), and the control signals ( dreq ? , dack ? , and done ? ) are used by the requesting device to write data during the source (read) portion of the transfer. 0 = if request generation is programmed to be external (req = 1x), the requesting device provides the data (write to memory), and the control signals ( dreq ? , dack ? , and done ? ) are used by the requesting device to provide data during the destination (write) portion of the transfer. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 6- 28 mc68340 user? manual motorola dual-address mode?his bit defines which device generates requests. 1 = if request generation is programmed to be external (req = 1x), the source device generates the request, and the control signals ( dreq ? , dack ? , and done ? ) are part of the source (read) portion of the transfer. 0 = if request generation is programmed to be external (req = 1x), the destination device generates the request, and the control signals ( dreq ? , dack ? , and done ? ) are part of the destination (write) portion of the transfer. sapi?ource address pointer increment 1 = the sar is incremented by 1, 2, or 4 after each transfer, according to the source size. the address that is written into the sar points to a memory block and is incremented to complete the data transfer. 0 = the sar is not incremented during operand transfer. the address that is written into the sar points to a peripheral device and is used for the complete data transfer. dapi?estination address pointer increment 1 = the dar is incremented by 1, 2, or 4 after each transfer, according to the source size. the address that is written into the dar points to a memory block and is incremented to complete the data transfer. 0 = the dar is not incremented during operand transfer. the address that is written into the dar points to a peripheral device and is used for the complete data transfer. ssize?ource size control field this field controls the size of the source (read) bus cycle that the dma channel is running. table 6-2 defines these bits. table 6-2. ssizex encoding bit 9 bit 8 definition 0 0 long word* 0 1 byte 1 0 word 1 1 not used *external logic is required to complete a long- word transfer. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 6- 29 dsize?estination size control field this field controls the size of the destination (write) bus cycle that the dma channel is running. table 6-3 defines these bits. table 6-3. dsizex encoding bit 7 bit 6 definition 0 0 long word* 0 1 byte 1 0 word 1 1 not used *external logic is required to complete a long- word transfer. req?equest generation field this field controls the mode of operation the dma channel uses to make an operand transfer request. table 6-4 defines these bits. table 6-4. reqx encoding bit 5 bit 4 definition 0 0 internal request at programmable rate 0 1 reserved 1 0 external request burst transfer mode 1 1 external request cycle steal bb?us bandwidth field this field controls the percentage of 1024 clock periods of the imb that the dma channel can use during internal requests only. table 6-5 defines these bits. table 6-5. bbx encoding and bus bandwidth req field bb field bus bandwidth bit 5 bit 4 bit 3 bit 2 definition (clock periods) 0 0 0 0 25% 256 0 0 0 1 50% 512 0 0 1 0 75% 768 0 0 1 1 100% 1024 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 6- 30 mc68340 user? manual motorola s/d?ingle-/dual-address transfer 1 = the dma channel runs single-address transfers from a peripheral to memory or from memory to a peripheral. the destination holding register is not used for these transfers because the data is transferred directly into the destination location. the mc68340 on-chip peripherals do not support single-address transfers. 0 = the dma channel runs dual-address transfers. str?tart this bit is cleared by a hardware/software reset, writing a logic zero, or setting one of the following csr bits: done, bes, bed, conf, or brkp. the str bit cannot be set when the csr irq bit is set. the dma channel cannot be started until the csr done, bes, bed, conf, and brkp bits are cleared. internal request mode: 1 = the dma transfer starts as soon as this bit is set. 0 = the dma transfer can be stopped by clearing this bit. external request mode: 1 = setting this bit allows the dma to start the transfer when a dreq ? input is received from an external device. 0 = the dma transfer can be stopped by clearing this bit. note if any fields in the ccr are modified while the channel is active, that change is effective immediately. to avoid any problems with changing the setup for the dma channel, a zero should be written to the str bit in the ccr to halt the dma channel at the end of the current bus cycle. 6.7.4 channel status register (csr) the csr contains the channel status information. this register is accessible in either supervisor or user space. the csr can always be read or written to when the dma module is enabled (i.e., the stp bit in the mcr is cleared). csr1, csr2 $78a, $7aa 76543210 irq done bes bed conf brkp 0 0 reset 00000000 supervisor/user f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 6- 31 irq?nterrupt request this bit is the logical or of the done, bes, bed, conf, and brkp bits and is cleared when they are all cleared. irq is positioned to allow conditional testing as a signed binary integer. the state of this bit is not affected by the interrupt enable bits in the ccr. the str bit in the ccr cannot be set when this bit is set; all error status bits, except the brkp bit, must be cleared before the str bit can be set. 1 = an interrupt condition has occurred. 0 = an interrupt condition has not occurred. done?ma done 1 = the dma channel has terminated normally. 0 = the dma channel has not terminated normally. this bit is cleared by writing a logic one or by a hardware reset. writing a zero has no effect. bes?us error on source 1 = the dma channel has terminated with a bus error during the read bus cycle. 0 = the dma channel has not terminated with a bus error during the read bus cycle. this bit is cleared by writing a logic one or by a hardware reset. writing a zero has no effect. bed?us error on destination 1 = the dma channel has terminated with a bus error during the write bus cycle. 0 = the dma channel has not terminated with a bus error during the write bus cycle. this bit is cleared by writing a logic one or by a hardware reset. writing a zero has no effect. conf?onfiguration error a configuration error results when either the sar or the dar contains an address that does not match the port size specified in the ccr and the btc register does not match the larger port size or is zero. 1 = the ccr str bit is set, and a configuration error is present. 0 = the ccr str bit is set, and no configuration error exists. this bit is cleared by writing a logic one or by a hardware reset. writing a zero has no effect. brkp?reakpoint 1 = the breakpoint signal was set during a dma transfer. 0 = the breakpoint signal was not set during a dma transfer. this bit is cleared by writing a logic one or by a hardware reset. writing a zero has no effect. bits 1, 0?eserved note the csr is cleared by writing $7c to its location. the dma channel cannot be started until the csr done, bes, bed, conf and brkp bits are cleared. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 6- 32 mc68340 user? manual motorola 6.7.5 function code register (fcr) the fcr contains the source and destination function codes for the channel. this register is accessible in either supervisor or user space. the fcr can always be read or written to when the dma module is enabled (i.e., the stp bit in the mcr is cleared). fcr1, fcr2 $78b, $7ab 76543210 sfc dfc reset: uuuuuuuu u = unaffected by reset. supervisor/user sfc?ource function code field this field can be used to specify the source access to a certain address space type. the source function code bits are defined in table 6-6. dfc?estination function code field this field can be used to specify the destination access to a certain address space type. the destination function code bits are defined in table 6-6. table 6-6. address space encoding function code bits 3 2 1 0 address spaces 0 0 0 0 reserved (motorola) 0 0 0 1 user data space 0 0 1 0 user program space 0 0 1 1 reserved (user) 0 1 0 0 reserved (motorola) 0 1 0 1 supervisor data space 0 1 1 0 supervisor program space 0 1 1 1 cpu space 1 x x x dma space note although fc3 can be set for dma transfers to distinguish the source or destination space from other data or program spaces, it is not required to be set. since the cpu32 currently has only 3-bit sfc and dfc capability, it cannot emulate fc3?? at this time. however, it is recommended that fc3 be set to one to distinguish dma or cpu access during debug. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 6- 33 6.7.6 source address register (sar) the sar is a 32-bit register that contains the address of the source operand used by the dma to access memory or peripheral registers. this register is accessible in either supervisor or user space. the sar can always be read or written to when the dma module is enabled (i.e., the stp bit in the mcr is cleared). sar1, sar2 $78c, $7ac 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 a31 a30 a29 a28 a27 a26 a25 a24 a23 a22 a21 a20 a19 a18 a17 a16 reset: uuuuuuuuuuuuuuuu 1514131211109876543210 a15 a14 a13 a12 a11 a10 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 reset: uuuuuuuuuuuuuuuu u = unaffected by reset supervisor/user during the dma read cycle, the sar drives the address on the address bus. this register can be programmed to increment (ccr sapi bit set) or remain constant (ccr sapi bit cleared) after each operand transfer. the register is incremented using unsigned arithmetic and will roll over if overflow occurs. for example, if the register contains $ffffffff and is incremented by 1, it will roll over to $00000000. this register is incremented by 1, 2, or 4, depending on the size of the operand and the memory starting address. if the operand size is byte, then the register is always incremented by 1. if the operand size is word and the starting address is even- word aligned, then the register is incremented by 2. if the operand size is long word and the address is even-word aligned, then the register is incremented by 4. the sar value must be aligned to an even-word boundary if the transfer size is word or long word; otherwise, the csr conf bit is set, and the transfer does not occur. when read, this register always contains the next source address. if a bus error terminates the transfer, this register contains the next source address that would have been run had the error not occurred. 6.7.7 destination address register (dar) the dar is a 32-bit register that contains the address of the destination operand used by the dma to write to memory or peripheral registers. this register is accessible in either supervisor or user space. the dar can always be read or written to when the dma module is enabled (i.e., the stp bit in the mcr is cleared). f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 6- 34 mc68340 user? manual motorola dar1, dar2 $790, $7b0 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 a31 a30 a29 a28 a27 a26 a25 a24 a23 a22 a21 a20 a19 a18 a17 a16 reset: uuuuuuuuuuuuuuuu 1514131211109876543210 a15 a14 a13 a12 a11 a10 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 reset: uuuuuuuuuuuuuuuu u = unaffected by reset supervisor/user during the dma write cycle, this register drives the address on the address bus. this register can be programmed to increment (ccr dapi bit set) or remain constant (ccr dapi bit cleared) after each operand transfer. the register is incremented using unsigned arithmetic and will roll over if overflow occurs. for example, if a register contains $ffffffff and is incremented by 1, it will roll over to $00000000. this register can be incremented by 1, 2, or 4, depending on the size of the operand and the starting address. if the operand size is byte, the register is always incremented by 1. if the operand size is word and the starting address is even-word aligned, the register is incremented by 2. if the operand size is long word and the address is even-word aligned, the register is incremented by 4. the dar value must be aligned to an even-word boundary if the transfer size is word or long word; otherwise, the csr conf bit is set, and the transfer does not occur. when read, this register always contains the next destination address. if a bus error terminates the transfer, this register contains the next destination address that would have been run had the error not occurred. 6.7.8 byte transfer counter register (btc) the btc is a 32-bit register that contains the number of bytes left to transfer in a given block. this register is accessible in either supervisor or user space. the btc can always be read or written to when the dma module is enabled (i.e., the stp bit in the mcr is cleared). btc1, btc2 $794, $7b4 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 a31 a30 a29 a28 a27 a26 a25 a24 a23 a22 a21 a20 a19 a18 a17 a16 reset: uuuuuuuuuuuuuuuu 1514131211109876543210 a15 a14 a13 a12 a11 a10 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 reset: uuuuuuuuuuuuuuuu u = unaffected by reset supervisor/user f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 6- 35 this register is decremented by 1, 2, or 4 for each successful operand transfer from source to destination locations. when the btc decrements to zero and no error has occurred, the csr done bit is set. in the external request mode, the done ? handshake line is also asserted when the btc is decremented to zero. if the operand size is byte, then the register is always decremented by 1. if the operand size is word and the starting count is even word, the register is decremented by 2. if the operand size is word and the byte count is not a multiple of 2, the csr conf bit is set, and a transfer does not occur. if the operand size is long word and the count is even long word, then the register is decremented by 4. if the operand size is long word and the byte count is not a multiple of 4, the csr conf bit is set, and a transfer does not occur. if the str bit is set with a zero count in the btc, the conf bit is set, and the str bit is cleared. when read, this register always contains the count for the next access. if a bus error terminates the transfer, this register contains the count for the next access that would have been run had the error not occurred. 6.8 data packing the internal dhr is a 32-bit register that can serve as a buffer register for the data being transferred during dual-address dma cycles. no address is specified since this register can not be addressed by the programmer. the dhr allows the data to be packed and unpacked by the dma during the dual-address transfer. for example, if the source operand size is byte and the destination operand size is word, then two-byte read cycles occur, followed by a one-word write cycle (see figure 6-16). the two bytes of data are buffered in the dhr until the destination (write) word cycle occurs. the dhr allows for packing and unpacking of operands for the following sizes: bytes to words, bytes to long words, words to long words, words to bytes, long words to bytes, and long words to words. . . .. .. ... .. ... .. ... . . byte0 byte1 byte0 byte1 byte2 byte3 byte0 byte2 byte1 byte3 byte0 byte1 byte2 byte3 byte0 byte1 byte2 byte3 byte0 byte1 source/destination destination/source figure 6-16. packing and unpacking of operands f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 6- 36 mc68340 user? manual motorola for normal transfers aligned with the size and address, only two bus cycles are required for each transfer: a read from the source and a write to the destination. 6.9 dma channel initialization sequence the following paragraphs describe dma channel initialization and operation. if the dma capability of the mc68340 is being used, the initialization steps should be performed during the part initialization sequence. the mode operation steps should be performed to start a dma transfer. the done ? pin requires an external pullup resistor even if operating only in the internal request mode. 6.9.1 dma channel configuration the following steps can be accomplished in any order when initializing the dma channel. these steps need to be performed for each channel used. module configuration register (mcr) clear the stop bit (stp) for normal operation. (only one stp bit exists for both channels.) select whether to respond to or ignore freeze (frzx bits). (only one set of frzx bits exits for both channels.) if desired, enable the external data bus operation in single-address mode (se bit). program the interrupt service mask to set the level below which interrupts are ignored during a dma transfer (ism bits). the channel will begin operation when the level of the cpu32 sr i2-i0 bits is less than or equal to the level of the dma ism bits. select the access privilege for the supervisor/user registers (supv bit). program the master arbitration id (maid) to establish priority on the imb between both dma channels. note that the two dma channels should have distinct maids if both channels are being used. (if they are programmed the same, channel 1 has priority.) select the interrupt arbitration level for the dma channel (iarb bits). (only one set of iarb bits exits for both channels.) interrupt register (intr) program the interrupt priority level for the channel interrupt (intl bits). program the vector number for the channel interrupt (intv bits). channel control register (ccr) if desired, enable the interrupt when breakpoint is recognized and the channel is the bus master (intb bit). if desired, enable the interrupt when done without an error condition (intn bit). if desired, enable the interrupt when the channel encounters an error (inte bit). f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 6- 37 select the direction of transfer if in single-address mode (eco bit), or select which device generates requests if in dual-address mode. 6.9.1.1 dma channel operation in single-address mode. the following steps are required to begin a dma transfer in single-address mode. channel control register (ccr) write a zero to the start bit (str) to prevent the channel from starting the transfer prematurely. select the amount by which to increment the source address for a read cycle (sapi bit) or the destination address for a write cycle (dapi bit). define the transfer size by selecting the source size for a read cycle (ssize field) or by selecting the destination size for a write cycle (dsize field). select external burst request mode or external cycle steal request mode (req field). set the s/d bit for signal-address transfer. channel status register (csr) ?clear the csr by writing $7c into it. the dma cannot be started until the done, bes, bed, conf, and brkp bits are cleared. function code register (fcr) ?encode the source function code for a read cycle or the destination function code for a write cycle. address register (sar or dar) ?write the source address for a read cycle or the destination address for a write cycle. byte transfer counter (btc) ?encode the number of bytes to be transferred. channel control register (ccr) ?write a one to the start bit (str) to allow the transfer to begin. 6.9.1.2 dma channel operation in dual-address mode. the following steps are required to begin a dma transfer in dual-address mode. channel control register (ccr) write a zero to the start bit (str) to prevent the channel from starting the transfer prematurely. select the amount by which to increment the source and destination addresses (sapi and dapi bits). select the source and destination sizes (ssize and dsize fields). select internal request, external burst request mode, or external cycle steal request mode (req field). f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 6- 38 mc68340 user? manual motorola if using internal request, select the amount of bus bandwidth to be used by the dma (bb field). clear the s/d bit for dual-address transfer. channel status register (csr) clear the csr by writing $7c into it. the dma cannot be started until the done, bes, bed, conf, and brkp bits are cleared. function code register (fcr) encode the source and destination function codes. address registers (sar and dar) write the source and destination addresses. byte transfer counter (btc) encode the number of bytes to be transferred. channel control register (ccr) write a one to the start bit (str) to allow the transfer to begin. 6.9.2 dma channel example configuration code the following are examples of configuration sequences for a dma channel in single- and dual-addressing modes. *************************************************************************** * mc68340 basic dma channel register initialization example code. * this code is used to initialize the 68340's internal dma channel * registers, providing basic functions for operation. * the code sets up channel 1 for external burst request generation, * single-address mode, long word size transfers. * control signals are asserted on the dma read cycle. *************************************************************************** example 1: external burst request generation, single-address transfers. *************************************************************************** * sim40 equates *************************************************************************** mbar equ $0003ff00 address of sim40 module base address reg. modbase equ $fffff000 sim40 mbar address value *************************************************************************** * dma channel 1 equates dmach1 equ $780 offset from mbar for channel 1 regs dmamcr1 equ $0 mcr for channel 1 * channel 1 register offsets from channel 1 base address f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 6- 39 dmaint1 equ $4 interrupt register channel 1 dmaccr1 equ $8 control register channel 1 dmacsr1 equ $a status register channel 1 dmafcr1 equ $b function code register channel 1 dmasar1 equ $c source address register channel 1 dmadar1 equ $10 destination address register channel 1 dmabtc1 equ $14 byte transfer count register channel 1 saradd equ $10000 source address numbyte equ $c number of bytes to transfer *************************************************************************** *************************************************************************** * initialize dma channel 1 *************************************************************************** lea modbase+dmach1,a0 pointer to channel 1 * initialize dma channel 1 mcr * normal operation, ignore freeze, single-address mode. ism field at 2. make * sure cpu32 sr i2-i0 bits are less than or equal to ism bits for channel startup. * supervisor/user reg. unrestricted, maid field at 7. iarb priority at 1. move.w #$1271,(a0) * clear channel control reg. * clear str (start) bit to prevent the channel from starting a transfer early. clr.w dmaccr1(a0) * initialize interrupt reg. * interrupt priority at 7, interrupt vector at $42. move.w #$0742,dmaint1(a0) * initialize channel status reg. * clear the done, bes, bed, conf and brkp bits to allow channel to startup. move.b #$7c,dmacsr1(a0) * initialize function code reg. * dma space, user data space for source. move.b #$99,dmafcr1(a0) * initialize source operand address * source address is equal to $10000. move.l saradd,dmasar1(a0) * initialize the byte transfer count reg. * the number of bytes to be transferred is $c or 3 long words move.l numbyte,dmabtc1(a0) * channel control reg. init. and start dma transfers f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 6- 40 mc68340 user? manual motorola * no interrupts are enabled, source (read) cycle. increment source * address, source size is long word, req is external burst request. * single-address mode, start the dma transfers. move.w #$1823,dmaccr1(a0) *************************************************************************** end *************************************************************************** example 2: internal request generation, memory to memory transfers. *************************************************************************** * mc68340 basic dma channel register initialization example code. * this code is used to initialize the 68340's internal dma channel * registers, providing basic functions for operation. * the code sets up channel 1 for internal request generation * memory to memory transfers. *************************************************************************** *************************************************************************** * sim40 equates *************************************************************************** mbar equ $0003ff00 address of sim40 module base address reg. modbase equ $fffff000 sim40 mbar address value *************************************************************************** * dma channel 1 equates dmach1 equ $780 offset from mbar for channel 1 regs dmamcr1 equ $0 mcr for channel 1 * channel 1 register offsets from channel 1 base address dmaint1 equ $4 interrupt register channel 1 dmaccr1 equ $8 control register channel 1 dmacsr1 equ $a status register channel 1 dmafcr1 equ $b function code register channel 1 dmasar1 equ $c source address register channel 1 dmadar1 equ $10 destination address register channel 1 dmabtc1 equ $14 byte transfer count register channel 1 saradd equ $6000 source address daradd equ $8000 destination address numbyte equ $e number of bytes to transfer *************************************************************************** *************************************************************************** * initialize dma channel 1 *************************************************************************** lea modbase+dmach1,a0 pointer to channel 1 * initialize dma channel 1 mcr f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 6- 41 * normal operation, ignore freeze, dual-address mode. ism field at 3. make * sure cpu32 sr i2-i0 bits are less than or equal to ism bits for channel startup. * supervisor/user reg. unrestricted, maid field at 3. iarb priority at 4. move.w #$0334,(a0) * clear channel control reg. * clear str (start) bit to prevent the channel from starting a transfer early. clr.w dmaccr1(a0) * initialize interrupt reg. * interrupt priority at 7, interrupt vector at $42. move.w #$0742,dmaint1(a0) * initialize channel status reg. * clear the done, bes, bed, conf and brkp bits to allow channel to startup. move.b #$7c,dmacsr1(a0) * initialize function code reg. * dma space, supervisor data space for source and destination. move.b #$dd,dmafcr1(a0) * initialize source operand address * source address is equal to $6000. move.l saradd,dmasar1(a0) * initialize destination operand address * destination address is equal to $8000. move.l daradd,dmadar1(a0) * initialize the byte transfer count reg. * the number of bytes to be transferred is $e or 7 words move.l numbyte,dmabtc1(a0) * channel control reg. init. and start dma transfers * no interrupts are enabled, destination (write) cycle. increment source and * destination addresses,source size is word, destination size is word. * req is internal. 100% of bus bandwidth, dual-address transfers, * start the dma transfers. move.w #$0e8d,dmaccr1(a0) *************************************************************************** end *************************************************************************** example 3: internal request generation, memory block initialization. *************************************************************************** * mc68340 basic dma channel register initialization example code. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 6- 42 mc68340 user? manual motorola * this code is used to initialize the 68340's internal dma channel * registers, providing basic functions for operation. * the code sets up channel 1 for internal request generation * to perform a memory block initialization for 100 bytes. *************************************************************************** *************************************************************************** * sim40 equates *************************************************************************** mbar equ $0003ff00 address of sim40 module base address reg. modbase equ $fffff000 sim40 mbar address value *************************************************************************** * dma channel 1 equates dmach1 equ $780 offset from mbar for channel 1 regs dmamcr1 equ $0 mcr for channel 1 * channel 1 register offsets from channel 1 base address dmaint1 equ $4 interrupt register channel 1 dmaccr1 equ $8 control register channel 1 dmacsr1 equ $a status register channel 1 dmafcr1 equ $b function code register channel 1 dmasar1 equ $c source address register channel 1 dmadar1 equ $10 destination address register channel 1 dmabtc1 equ $14 byte transfer count register channel 1 saradd equ $6000 source address daradd equ $8000 destination address numbyte equ $64 number of bytes to transfer *************************************************************************** *************************************************************************** * initialize dma channel 1 *************************************************************************** lea modbase+dmach1,a0 pointer to channel 1 * initialize dma channel 1 mcr * normal operation, ignore freeze, dual-address mode. ism field at 3. make * sure cpu32 sr i2-i0 bits are less than or equal to ism bits for channel * startup.supervisor/user reg. unrestricted, maid field at 3. * iarb priority at 4. move.w #$0334,(a0) * clear channel control reg. * clear str (start) bit to prevent the channel from starting a transfer early. clr.w dmaccr1(a0) * initialize interrupt reg. * interrupt priority at 7, interrupt vector at $42. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 6- 43 move.w #$0742,dmaint1(a0) * initialize channel status reg. * clear the done, bes, bed, conf and brkp bits to allow channel to startup. move.b #$7c,dmacsr1(a0) * initialize function code reg. * dma space, supervisor data space for source and destination. move.b #$dd,dmafcr1(a0) * initialize source operand address * source address is equal to $6000. move.l saradd,dmasar1(a0) * initialize destination operand address * destination address is equal to $8000. move.l daradd,dmadar1(a0) * initialize the byte transfer count register * the number of bytes to be transferred is $64 or 50 words move.l numbyte,dmabtc1(a0) * channel control reg. init. and start dma transfers * no interrupts are enabled, destination (write) cycle. * source address is not incremented. increment the destination address. * source size is word, destination size is word. req is internal. * 100% of bus bandwidth, dual-address transfers, start the dma transfers. move.w #$068d,dmaccr1(a0) *************************************************************************** end *************************************************************************** example 4: cycle steal request generation, dual-address transfers. *************************************************************************** * mc68340 basic dma channel register initialization example code. * this code is used to initialize the 68340's internal dma channel * registers, providing basic functions for operation. * the code sets up channel 1 for external cycle steal request generation, * dual-address transfers. dma 16-bit wide data from an odd address to an * even address. control signals are asserted on the dma read cycle. *************************************************************************** *************************************************************************** * sim40 equates *************************************************************************** mbar equ $0003ff00 address of sim40 module base address reg. modbase equ $fffff000 sim40 mbar address value f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 6- 44 mc68340 user? manual motorola *************************************************************************** * dma channel 1 equates dmach1 equ $780 offset from mbar for channel 1 regs dmamcr1 equ $0 mcr for channel 1 * channel 1 register offsets from channel 1 base address dmaint1 equ $4 interrupt register channel 1 dmaccr1 equ $8 control register channel 1 dmacsr1 equ $a status register channel 1 dmafcr1 equ $b function code register channel 1 dmasar1 equ $c source address register channel 1 dmadar1 equ $10 destination address register channel 1 dmabtc1 equ $14 byte transfer count register channel 1 saradd equ $6001 source address is an odd address daradd equ $10000 destination address is and even address numbyte equ $14 number of bytes to transfer *************************************************************************** *************************************************************************** * initialize dma channel 1 *************************************************************************** lea modbase+dmach1,a0 pointer to channel 1 * initialize dma channel 1 mcr * normal operation, ignore freeze, dual-address mode. ism field at 0. make * cpu32 sr i2-i0 bits are less than or equal to ism bits for channel startup. * supervisor/user reg. unrestricted, maid field at 4. iarb priority at 8. move.w #$00c8,(a0) * clear channel control reg. * clear str (start) bit to prevent the channel from starting a transfer early. clr.w dmaccr1(a0) * initialize interrupt reg. * interrupt priority at 7, interrupt vector at $42. move.w #$0742,dmaint1(a0) * initialize channel status reg. * clear the done, bes, bed, conf and brkp bits to allow channel to startup. move.b #$7c,dmacsr1(a0) * initialize function code reg. * dma space, supervisor data space for source and destination. move.b #$dd,dmafcr1(a0) * initialize source operand address f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 6- 45 * source address is equal to $6001, and odd address. move.l saradd,dmasar1(a0) * initialize destination operand address * destination address is equal to $10000, and even address. move.l daradd,dmadar1(a0) * initialize the byte transfer count register * the number of bytes to be transferred is $14 or 20 bytes move.l numbyte,dmabtc1(a0) * channel control reg. init. and start dma transfers * no interrupts are enabled, source (read) cycle. * increment the source and destination addresses. * source size is byte, destination size is word. req is external cycle steal. * dual-address transfers, start the dma transfers. move.w #$1db1,dmaccr1(a0) *************************************************************************** end *************************************************************************** f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 7- 1 section 7 serial module the mc68340 serial module is a dual universal asynchronous/synchronous receiver/transmitter that interfaces directly to the cpu32 processor via the intermodule bus (imb). the serial module, shown in figure 7-1, consists of the following major functional areas: two independent serial communication channels (a and b) baud rate generator logic internal channel control logic interrupt control logic .. .. ... .. . . serial communications channels a and b baud rate generator logic internal channel control logic x1 x2 sclk interrupt control logic rxdb rxda txdb txda ctsb ctsa rtsb rtsa txrdy a rxrdy a figure 7-1. simplified block diagram f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 7- 2 mc68340 user? manual motorola 7.1 module overview features of the serial module are as follows: two, independent, full-duplex asynchronous/synchronous receiver/transmitter channels maximum data transfer rate: ? mode: 3 mbps @ 8.39 mhz clkout, 9.8 mbps @25 mhz clkout ?6 mode: 188 kbps @ 8.39 mhz clkout, 612 kbps @25 mhz clkout quadruple-buffered receiver double-buffered transmitter independently programmable baud rate for each receiver and transmitter selectable from: ?9 fixed rates: 50 to 76.8k baud ?xternal 1 clock or 16 clock programmable data format: ?ive to eight data bits plus parity ?dd, even, no parity, or force parity ?ine-sixteenths to two stop bits programmable in one-sixteenth bit increments programmable channel modes: ?ormal (full duplex) ?utomatic echo ?ocal loopback ?emote loopback automatic wakeup mode for multidrop applications seven maskable interrupt conditions parity, framing, and overrun error detection false-start bit detection line-break detection and generation detection of breaks originating in the middle of a character start/end break interrupt/status on-chip crystal oscillator f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 7- 3 7.1.1 serial communication channels a and b each communication channel provides a full-duplex asynchronous/synchronous receiver and transmitter using an operating frequency independently selected from a baud rate generator or an external clock input. the transmitter accepts parallel data from the imb, converts it to a serial bit stream, inserts the appropriate start, stop, and optional parity bits, then outputs a composite serial data stream on the channel transmitter serial data output (txdx). refer to 7.3.2.1 transmitter for additional information. the receiver accepts serial data on the channel receiver serial data input (rxdx), converts it to parallel format, checks for a start bit, stop bit, parity (if any), or break condition, and transfers the assembled character onto the imb during read operations. refer to 7.3.2.2 receiver for additional information. 7.1.2 baud rate generator logic the crystal oscillator operates directly from a 3.6864-mhz crystal connected across the x1 input and the x2 output or from an external clock of the same frequency connected to x1. the clock serves as the basic timing reference for the baud rate generator and other internal circuits. the baud rate generator operates from the oscillator or external ttl clock input and is capable of generating 19 commonly used data communication baud rates ranging from 50 to 76.8k by producing internal clock outputs at 16 times the actual baud rate. refer to 7.2 serial module signal definitions and 7.3.1 baud rate generator for additional information. the external clock input (sclk), which bypasses the baud rate generator, provides a synchronous clock mode of operation when used as a divide-by-1 clock and an asynchronous clock mode when used as a divide-by-16 clock. the external clock input allows the user to use sclk as the only clock source for the serial module if multiple baud rates are not required. 7.1.3 internal channel control logic the serial module receives operation commands from the host and, in turn, issues appropriate operation signals to the internal serial module control logic. this mechanism allows the registers within the module to be accessed and various commands to be performed. refer to 7.4 register description and programming for additional information. 7.1.4 interrupt control logic seven interrupt request ( irq7?rq1 ) signals are provided to notify the cpu32 that an interrupt has occurred. these interrupts are described in 7.4 register description and programming . the interrupt status register (isr) is read by the cpu32 to determine all f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 7- 4 mc68340 user? manual motorola currently active interrupt conditions. the interrupt enable register (ier) is programmable to mask any events that can cause an interrupt. 7.1.5 comparison of serial module to mc68681 the serial module is code compatible with the mc68681 with some modifications. the following paragraphs describe the differences. the programming model is slightly altered. the supervisor/user block in the mc68340 closely follows the mc68681. the supervisor-only block has the following changes: the interrupt vector register is moved from supervisor/user to supervisor only at a new address. mr2a and mr2b are moved from a hidden address location to a location at the bottom of the programming model. the timer/counter is eliminated as well as all associated command and status registers. only certain output port pins are available. there are no ip pins on the mc68340. rxrts and txrts are more automated on the mc68340. the xtal_rdy bit in the isr should be polled until it is cleared to prevent an unstable frequency from being applied to the baud rate generator. the following code is an example: if (xtal_rdy==0) begin write csr end else begin wait jump loop end 7.2 serial module signal definitions the following paragraphs contain a brief description of the serial module signals. figure 7- 2 shows both the external and internal signal groups. note the terms assertion and negation are used throughout this section to avoid confusion when dealing with a mixture of active-low and active-high signals. the term assert or assertion indicates that a signal is active or true, independent of the level represented by a high or low voltage. the term negate or negation indicates that a signal is inactive or false. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 7- 5 .. .. ... .. . .. . data bus mux d15?0 address bus imb interface signals i n t e r n a l b u s data bus data d7?0 external interface signals x1 x2 sclk baud rate generator logic channel b four-character receive buffer two-character transmit buffer rxdb txdb rtsb ctsb channel a four-character receive buffer two-character transmit buffer rxda txda rtsa txrdya ctsa control internal control logic s e r i a l m o d u l e rxrdya figure 7-2. external and internal interface signals 7.2.1 crystal input or external clock (x1) this input is one of two connections to a crystal or a single connection to an external clock. a crystal or an external clock signal, at 3.6864 mhz, must be supplied when using the baud rate generator. if a crystal is used, a capacitor of approximately 10 pf should be connected from this signal to ground. if this input is not used, it must be connected to v cc or gnd. refer to section 10 applications for an example of a clock driver circuit. 7.2.2 crystal output (x2) this output is the additional connection to a crystal. if a crystal is used, a capacitor of approximately 5 pf should be connected from this signal to ground. if an external ttl- level clock is used on x1, the x2 output must be left open. refer to section 10 applications for an example of a clock driver circuit. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 7- 6 mc68340 user? manual motorola 7.2.3 external input (sclk) this input can be used as the clock input for channel a and/or channel b and is programmable in the clock-select registers (csr). when used as the receiver clock, received data is sampled on the rising edge of the clock. when used as the transmitter clock, data is output on the falling edge of the clock. if this input is not used, it must be connected to v cc or gnd. 7.2.4 channel a transmitter serial data output (txda) this signal is the transmitter serial data output for channel a. the output is held high ('mark' condition) when the transmitter is disabled, idle, or operating in the local loopback mode. data is shifted out on this signal on the falling edge of the clock source, with the least significant bit transmitted first. 7.2.5 channel a receiver serial data input (rxda) this signal is the receiver serial data input for channel a. data received on this signal is sampled on the rising edge of the clock source, with the least significant bit received first. 7.2.6 channel b transmitter serial data output (txdb) this signal is the transmitter serial data output for channel b. the output is held high ('mark' condition) when the transmitter is disabled, idle, or operating in the local loopback mode. data is shifted out on this signal at the falling edge of the clock source, with the least significant bit transmitted first. 7.2.7 channel b receiver serial data input (rxdb) this signal is the receiver serial data input for channel b. data on this signal is sampled on the rising edge of the clock source, with the least significant bit received first. 7.2.8 channel a request-to-send ( rtsa ) this active-low output signal is programmable as the channel a request-to-send or as a dedicated parallel output. 7.2.8.1 rtsa . when used for this function, this signal can be programmed to be automatically negated and asserted by either the receiver or transmitter. when connected to the clear-to-send ( cts ? ) input of a transmitter, this signal can be used to control serial data flow. 7.2.8.2 op0. when used for this function, this output is controlled by bit 0 in the output port data register (op). 7.2.9 channel b request-to-send ( rtsb ) this active-low output signal is programmable as the channel b request-to-send or as a dedicated parallel output. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 7- 7 7.2.9.1 rtsb . when used for this function, this signal can be programmed to be automatically negated and asserted by either the receiver or transmitter. when connected to the cts ? input of a transmitter, this signal can be used to control serial data flow. 7.2.9.2 op1. when used for this function, this output is controlled by bit 1 in the op. 7.2.10 channel a clear-to-send ( ctsa ) this active-low input is the channel a clear-to-send. 7.2.11 channel b clear-to-send ( ctsb ) this active-low input is the channel b clear-to-send. 7.2.12 channel a transmitter ready ( t ? rdya ) this active-low output signal is programmable as the channel a transmitter ready or as a dedicated parallel output, and cannot be masked by the interrupt enable register (ier). 7.2.12.1 t ? rdya . when used for this function, this signal reflects the complement of the status of bit 2 of the channel a status register (sra). this signal can be used to control parallel data flow by acting as an interrupt to indicate when the transmitter contains a character. 7.2.12.2 op6. when used for this function, this output is controlled by bit 6 in the op. 7.2.13 channel a receiver ready ( r ? rdya ) this active-low output signal is programmable as the channel a receiver ready, channel a fifo full indicator, or a dedicated parallel output, and cannot be masked by the ier. 7.2.13.1 r ? rdya . when used for this function, this signal reflects the complement of the status of bit 1 of the isr. this signal can be used to control parallel data flow by acting as an interrupt to indicate when the receiver contains a character. 7.2.13.2 ffulla . when used for this function, this signal reflects the complement of the status of bit 1 of the isr. this signal can be used to control parallel data flow by acting as an interrupt to indicate when the receiver fifo is full. 7.2.13.3 op4. when used for this function, this output is controlled by bit 4 in the op. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 7- 8 mc68340 user? manual motorola 7.3 operation the following paragraphs describe the operation of the baud rate generator, transmitter and receiver, and other functional operating modes of the serial module. 7.3.1 baud rate generator the baud rate generator consists of a crystal oscillator, baud rate generator, and clock selectors (see figure 7-3). the crystal oscillator operates directly from a 3.6864-mhz crystal or from an external clock of the same frequency. the sclk input bypasses the baud rate generator and provides a synchronous clock mode of operation when used as a divide-by-1 clock and an asynchronous clock mode when used as a divide-by-16 clock. the clock is selected by programming the clock-select register (csr) for each channel. .. .. ... .. . .. . .. . baud rate generator logic crystal oscillator baud rate generator clock selectors x1 x2 sclk external interface figure 7-3. baud rate generator block diagram 7.3.2 transmitter and receiver operating modes the functional block diagram of the transmitter and receiver, including command and operating registers, is shown in figure 7-4. the paragraphs that follow contain descriptions for both these functions in reference to this diagram. for detailed register information, refer to 7.4 register description and programming . f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 7- 9 .. .. ... .. . .. . .. . . .. . channel a channel b transmit buffer (tba) (2 registers) receiver holding register 1 receiver holding register 2 receiver holding register 3 receiver shift register txda rxda fifo transmit holding register transmit shift register receive buffer (rba) (4 registers) w r command register (cra) mode register a (mr1a) mode register b (mr2a) status register (sra) w r/w r/w r external interface receiver holding register 1 receiver holding register 2 receiver holding register 3 receiver shift register txdb rxdb fifo transmit holding register transmit shift register receive buffer (rbb) (4 registers) w r command register (crb) mode register 1 (mr1b) mode register 2 (mr2b) status register (srb) w r/w r/w r transmit buffer (tbb) (2 registers) note: r/w = read/write r = read w = write figure 7-4. transmitter and receiver functional diagram f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 7- 10 mc68340 user? manual motorola 7.3.2.1 transmitter. the transmitters are enabled through their respective command registers (cr) located within the serial module. the serial module signals the cpu32 when it is ready to accept a character by setting the transmitter-ready bit (txrdy) in the channel's status register (sr). functional timing information for the transmitter is shown in figure 7-5. the transmitter converts parallel data from the cpu32 to a serial bit stream on txdx. it automatically sends a start bit followed by the programmed number of data bits, an optional parity bit, and the programmed number of stop bits. the least significant bit is sent first. data is shifted from the transmitter output on the falling edge of the clock source. c1 c2 c3 c4 c6 w w w w w w w w c1 c2 c3 c4 stop break start break c5 not transmitted c6 break c1 in transmission txdx transmitter enable d txrdy (sr 2) cs cts rts 2 1 notes: 1. timing shown for mr2(4) = 1 2. timing shown for mr2(5) = 1 3. c = transmit character 4. w = write n manually asserted b y bit- set command manually asserte d figure 7-5. transmitter timing diagram following transmission of the stop bits, if a new character is not available in the transmitter holding register, the txdx output remains high ('mark' condition), and the transmitter empty bit (txemp) in the sr is set. transmission resumes and the txemp bit is cleared when the cpu32 loads a new character into the transmitter buffer (tb). if a disable command is sent to the transmitter, it continues operating until the character in the f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 7- 11 transmit shift register, if any, is completely sent out. if the transmitter is reset through a software command, operation ceases immediately (refer to 7.4.1.7 command register (cr) ). the transmitter is re-enabled through the cr to resume operation after a disable or software reset. if clear-to-send operation is enabled, cts ? must be asserted for the character to be transmitted. if cts ? is negated in the middle of a transmission, the character in the shift register is transmitted, and txdx remains in the 'mark' state until cts ? is asserted again. if the transmitter is forced to send a continuous low condition by issuing a send break command, the state of cts ? is ignored by the transmitter. the transmitter can be programmed to automatically negate request-to-send ( rts ? ) outputs upon completion of a message transmission. if the transmitter is programmed to operate in this mode, rts ? must be manually asserted before a message is transmitted. in applications in which the transmitter is disabled after transmission is complete and rts ? is appropriately programmed, rts ? is negated one bit time after the character in the shift register is completely transmitted. the transmitter must be manually re-enabled by reasserting rts ? before the next message is to be sent. 7.3.2.2 receiver. the receivers are enabled through their respective crs located within the serial module. functional timing information for the receiver is shown in figure 7-6. the receiver looks for a high-to-low (mark-to-space) transition of the start bit on rxdx. when a transition is detected, the state of rxdx is sampled each 16 clock for eight clocks, starting one-half clock after the transition (asynchronous operation) or at the next rising edge of the bit time clock (synchronous operation). if rxdx is sampled high, the start bit is invalid, and the search for the valid start bit begins again. if rxdx is still low, a valid start bit is assumed, and the receiver continues to sample the input at one-bit time intervals, at the theoretical center of the bit, until the proper number of data bits and parity, if any, is assembled and one stop bit is detected. data on the rxdx input is sampled on the rising edge of the programmed clock source. the least significant bit is received first. the data is then transferred to a receiver holding register, and the rxrdy bit in the appropriate sr is set. if the character length is less than eight bits, the most significant unused bits in the receiver holding register are cleared. after the stop bit is detected, the receiver immediately looks for the next start bit. however, if a nonzero character is received without a stop bit (framing error) and rxdx remains low for one-half of the bit period after the stop bit is sampled, the receiver operates as if a new start bit is detected. the parity error (pe), framing error (fe), overrun error (oe), and received break (rb) conditions (if any) set error and break flags in the appropriate sr at the received character boundary and are valid only when the rxrdy bit in the sr is set. if a break condition is detected (rxdx is low for the entire character including the stop bit), a character of all zeros is loaded into the receiver holding register, and the rb and rxrdy bits in the sr are set. the rxdx signal must return to a high condition for at least one-half bit time before a search for the next start bit begins. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 7- 12 mc68340 user? manual motorola c6, c7, c8 are lost rxd receiver enable d rxrdy (sr 0) ffull (sr 1) rxrdya overrun (sr 4) rts 1 status data status data status data cs reset by command opr(0) = 1 c4 c3 c5 c6 c7 c8 c1 c2 notes: 1. timing shown for mr1(7) = 1 2. timing shown for opcr(4) = 1 and mr1(6) = 0 3. r = read 4. c = received character n r r r r r r r r c1 c2 c3 c4 c5 l ost status data figure 7-6. receiver timing diagram the receiver detects the beginning of a break in the middle of a character if the break persists through the next character time. when the break begins in the middle of a character, the receiver places the damaged character in the receiver first-in-first-out (fifo) stack and sets the corresponding error conditions and rxrdy bit in the sr. then, if the break persists until the next character time, the receiver places an all-zero character into the receiver fifo and sets the corresponding rb and rxrdy bits in the sr. 7.3.2.3 fifo stack. the fifo stack is used in each channel's receiver buffer logic. the stack consists of three receiver holding registers. the receive buffer consists of the fifo and a receiver shift register connected to the rxdx (refer to figure 7-4). data is f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 7- 13 assembled in the receiver shift register and loaded into the top empty receiver holding register position of the fifo. thus, data flowing from the receiver to the cpu32 is quadruple buffered. in addition to the data byte, three status bits, pe, fe, and rb, are appended to each data character in the fifo; oe is not appended. by programming the err bit in the channel's mode register (mr1), status is provided in character or block modes. the rxrdy bit in the sr is set whenever one or more characters are available to be read by the cpu32. a read of the receiver buffer produces an output of data from the top of the fifo stack. after the read cycle, the data at the top of the fifo stack and its associated status bits are 'popped', and new data can be added at the bottom of the stack by the receiver shift register. the fifo-full status bit (ffull) is set if all three stack positions are filled with data. either the rxrdy or ffull bit can be selected to cause an interrupt. in the character mode, status provided in the sr is given on a character-by-character basis and thus applies only to the character at the top of the fifo. in the block mode, the status provided in the sr is the logical or of all characters coming to the top of the fifo stack since the last reset error command. a continuous logical or function of the corresponding status bits is produced in the sr as each character reaches the top of the fifo stack. the block mode is useful in applications where the software overhead of checking each character's error cannot be tolerated. in this mode, entire messages are received, and only one data integrity check is performed at the end of the message. this mode allows a data-reception speed advantage, but does have a disadvantage since each character is not individually checked for error conditions by software. if an error occurs within the message, the error is not recognized until the final check is performed, and no indication exists as to which character in the message is at fault. in either mode, reading the sr does not affect the fifo. the fifo is 'popped' only when the receive buffer is read. the sr should be read prior to reading the receive buffer. if all three of the fifo's receiver holding registers are full when a new character is received, the new character is held in the receiver shift register until a fifo position is available. if an additional character is received during this state, the contents of the fifo are not affected. however, the character previously in the receiver shift register is lost, and the oe bit in the sr is set when the receiver detects the start bit of the new overrunning character. to support control flow capability, the receiver can be programmed to automatically negate and assert rts ? . when in this mode, rts ? is automatically negated by the receiver when a valid start bit is detected and the fifo stack is full. when a fifo position becomes available, rts ? is asserted by the receiver. using this mode of operation, overrun errors are prevented by connecting the rts ? to the cts ? input of the transmitting device. if the fifo stack contains characters and the receiver is disabled, the characters in the fifo can still be read by the cpu32. if the receiver is reset, the fifo stack and all receiver status bits, corresponding output ports, and interrupt request are reset. no additional characters are received until the receiver is re-enabled. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 7- 14 mc68340 user? manual motorola 7.3.3 looping modes each serial module channel can be configured to operate in various looping modes as shown in figure 7-7. these modes are useful for local and remote system diagnostic functions. the modes are described in the following paragraphs with further information available in 7.4 register description and programming . the channel's transmitter and receiver should both be disabled when switching between modes. the selected mode is activated immediately upon mode selection, regardless of whether a character is being received or transmitted. 7.3.3.1 automatic echo mode. in this mode, the channel automatically retransmits the received data on a bit-by-bit basis. the local cpu32-to-receiver communication continues normally, but the cpu32-to-transmitter link is disabled. while in this mode, received data is clocked on the receiver clock and retransmitted on txdx. the receiver must be enabled, but the transmitter need not be enabled. since the transmitter is not active, the sr txemp and txrdy bits are inactive, and data is transmitted as it is received. received parity is checked, but not recalculated for transmission. character framing is also checked, but stop bits are transmitted as received. a received break is echoed as received until the next valid start bit is detected. 7.3.3.2 local loopback mode. in this mode, txdx is internally connected to rxdx. this mode is useful for testing the operation of a local serial module channel by sending data to the transmitter and checking data assembled by the receiver. in this manner, correct channel operations can be assured. also, both transmitter and cpu32-to-receiver communications continue normally in this mode. while in this mode, the rxdx input data is ignored, the txdx is held marking, and the receiver is clocked by the transmitter clock. the transmitter must be enabled, but the receiver need not be enabled. 7.3.3.3 remote loopback mode. in this mode, the channel automatically transmits received data on the txdx output on a bit-by-bit basis. the local cpu32-to-transmitter link is disabled. this mode is useful in testing receiver and transmitter operation of a remote channel. while in this mode, the receiver clock is used for the transmitter. since the receiver is not active, received data cannot be read by the cpu32, and the error status conditions are inactive. received parity is not checked and is not recalculated for transmission. stop bits are transmitted as received. a received break is echoed as received until the next valid start bit is detected. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 7- 15 (a) automatic echo (b) local loopback (c) remote loopback disabled disabled disabled disabled rx tx rx tx rx tx txdx o utpu t rxdx i npu t rxdx i npu t rxdx i npu t txdx o utpu t txdx o utpu t disabled disabled cpu cpu cpu disabled disabled figure 7-7. looping modes functional diagram 7.3.4 multidrop mode a channel can be programmed to operate in a wakeup mode for multidrop or multiprocessor applications. functional timing information for the multidrop mode is shown in figure 7-8. the mode is selected by setting bits 3 and 4 in mode register 1 (mr1). this mode of operation allows the master station to be connected to several slave stations (maximum of 256). in this mode, the master transmits an address character followed by a block of data characters targeted for one of the slave stations. the slave stations have their channel receivers disabled. however, they continuously monitor the data stream sent out by the master station. when an address character is sent by the master, the slave receiver channel notifies its respective cpu by setting the rxrdy bit in the sr and generating an interrupt (if programmed to do so). each slave station cpu then compares the received address to its station address and enables its receiver if it wishes to receive the subsequent data characters or block of data from the master station. slave stations not addressed continue to monitor the data stream for the next address character. data fields in the data stream are separated by an address character. after a slave receives a block of data, the slave station's cpu disables the receiver and initiates the process again. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 7- 16 mc68340 user? manual motorola c6, c7, c8 are lost rxd receiver enable d rxrdy (sr 0) ffull (sr 1) rxrdya overrun (sr 4) rts 1 status data status data status data cs reset by command opr(0) = 1 c4 c3 c5 c6 c7 c8 c1 c2 notes: 1. timing shown for mr1(7) = 1 2. timing shown for opcr(4) = 1 and mr1(6) = 0 3. r = read 4. c = received character n r r r r r r r r c1 c2 c3 c4 c5 l ost status data figure 7-8. multidrop mode timing diagram a transmitted character from the master station consists of a start bit, a programmed number of data bits, an address/data (a/d) bit flag, and a programmed number of stop bits. the a/d bit identifies the type of character being transmitted to the slave station. the character is interpreted as an address character if the a/d bit is set or as a data character if the a/d bit is cleared. the polarity of the a/d bit is selected by programming bit 2 of the mr1. the mr1 should be programmed before enabling the transmitter and loading the corresponding data bits into the transmit buffer. in multidrop mode, the receiver continuously monitors the received data stream, regardless of whether it is enabled or disabled. if the receiver is disabled, it sets the f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 7- 17 rxrdy bit and loads the character into the receiver holding register fifo stack provided the received a/d bit is a one (address tag). the character is discarded if the received a/d bit is a zero (data tag). if the receiver is enabled, all received characters are transferred to the cpu32 via the receiver holding register stack during read operations. in either case, the data bits are loaded into the data portion of the stack while the a/d bit is loaded into the status portion of the stack normally used for a parity error (sr bit 5). framing error, overrun error, and break detection operate normally. the a/d bit takes the place of the parity bit; therefore, parity is neither calculated nor checked. messages in this mode may still contain error detection and correction information. one way to provide error detection, if 8-bit characters are not required, is to use software to calculate parity and append it to the 5-, 6-, or 7-bit character. 7.3.5 bus operation this section describes the operation of the imb during read, write, and interrupt acknowledge cycles to the serial module. all serial module registers must be accessed as bytes. 7.3.5.1 read cycles. the serial module is accessed by the cpu32 with no wait states. the serial module responds to byte reads. reserved registers return logic zero during reads. 7.3.5.2 write cycles. the serial module is accessed by the cpu32 with no wait states. the serial module responds to byte writes. write cycles to read-only registers and reserved registers complete in a normal manner without exception processing; however, the data is ignored. 7.3.5.3 interrupt acknowledge cycles. the serial module is capable of arbitrating for interrupt servicing and supplying the interrupt vector when it has successfully won arbitration. the vector number must be provided if interrupt servicing is necessary; thus, the interrupt vector register (ivr) must be initialized. if the ivr is not initialized, a spurious interrupt exception will be taken if interrupts are generated. 7.4 register description and programming this section contains a detailed description of each register and its specific function as well as flowcharts of basic serial module programming. 7.4.1 register description the operation of the serial module is controlled by writing control bytes into the appropriate registers. a list of serial module registers and their associated addresses are shown in figure 7-9. the mode, status, command, and clock-select registers are duplicated for each channel to provide independent operation and control. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 7- 18 mc68340 user? manual motorola note all serial module registers are only accessible as bytes. the contents of the mode registers (mr1 and mr2), clock-select register (csr), and the auxiliary control register (acr) bit 7 should only be changed after the receiver/transmitter is issued a software reset command?.e., channel operation must be disabled. care should also be taken if the register contents are changed during receiver/transmitter operations, as undesirable results may be produced. in the registers discussed in the following pages, the numbers in the upper right-hand corner indicate the offset of the register from the base address specified in the module base address register (mbar) in the sim40. the numbers above the register description represent the bit position in the register. the register description contains the mnemonic for the bit. the values shown below the register description are the values of those register bits after a hardware reset. a value of u indicates that the bit value is unaffected by reset. the read/write status and the access privilege are shown in the last line. note a cpu32 reset instruction will not affect the mcr, but will reset all the other serial module registers as though a hardware reset had occurred. the module is enabled when the stp bit in the mcr is cleared. the module is disabled when the stp bit in the mcr is set. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 7- 19 address fc register read (r/w = 1) register write (r/w = 0) 700 s 1 mcr (high byte) mcr (high byte) 701 s mcr (low byte) mcr (low byte) 702 s do not access 3 do not access 3 703 s do not access 3 do not access 3 704 s interrupt level (ilr) nterrupt level (ilr) 705 s interrupt vector (ivr) interrupt vector (ivr) 710 s/u 2 mode register 1a (mr1a) mode register 1a (mr1a) 711 s/u status register a (sra) clock-select register a (csra) 712 s/u do not access 3 command register a (cra) 713 s/u receiver buffer a (rba) transmitter buffer a (tba) 714 s/u input port change register (ipcr) auxiliary control register (acr) 715 s/u interrupt status register (isr) interrupt enable register (ier) 716 s/u do not access 3 do not access 3 717 s/u do not access 3 do not access 3 718 s/u mode register 1b (mr1b) mode register 1b (mr1b) 719 s/u status register b (srb) clock-select register b (csrb) 71a s/u do not access 3 command register b (crb) 71b s/u receiver buffer b (rbb) transmitter buffer b (tbb) 71c s/u do not access 3 do not access 3 71d s/u input port register (ip) output port control register (opcr) 71e s/u do not access 3 output port (op) 4 bit set 71f s/u do not access 3 output port (op) 4 bit reset 720 s/u mode register 2a (mr2a) mode register 2a (mr2a) 721 s/u mode register 2b (mr2b) mode register 2b (mr2b) notes: 1. s = register permanently defined as supervisor-only access 2. s/u = register programmable as either supervisor or user access 3. a read or write to these locations currently has no effect. 4. address-triggered commands figure 7-9. serial module programming model 7.4.1.1 module configuration register (mcr). the mcr controls the serial module configuration. this register can be either read or written when the module is enabled and is in the supervisor state. the mcr is not affected by a cpu32 reset instruction. only the mcr can be accessed when the module is disabled (i.e., the stp bit in the mcr is set). mcr $700 1514131211109876543210 stp frz1 frz0 iccs 0 000 supv 000 iarb reset: 0 000000010000000 read/write supervisor only f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 7- 20 mc68340 user? manual motorola stp?top mode bit 1 = the serial module will be disabled. setting the stp bit stops all clocks within the serial module (including the crystal or external clock and sclk), except for the clock from the imb. the clock from the imb remains active to allow cpu32 access to the mcr. the clock stops on the low phase of the clock and remains stopped until the stp bit is cleared by the cpu32 or a hardware reset. accesses to serial module registers while in stop mode produce a bus error. the serial module should be disabled in a known state prior to setting the stp bit; otherwise, unpredictable results may occur. the stp bit should be set prior to executing the lpstop instruction to reduce overall power consumption. 0 = the serial module is enabled and will operate in normal mode. when stp = 0, make sure the external crystal is stable (xtal_rdy bit (bit 3) of the interrupt status register (isr) is zero) before continuing. note the serial module should be disabled (i.e., the stp bit in the mcr is set) before executing the lpstop instruction to obtain the lowest power consumption. the x1/x2 oscillator will continue to run during lpstop if stp = 0. frz1?rz0?reeze these bits determine the action taken when the freeze signal is asserted on the imb when the cpu32 has entered background debug mode. table 7-1 lists the action taken for each combination of bits. table 7-1. frzx control bits frz1 frz0 action 0 0 ignore freeze 0 1 reserved (freeze ignored) 1 0 freeze on character boundary 1 1 freeze on character boundary if freeze is asserted, channel a and channel b freeze independently of each other. the transmitter and receiver freeze at character boundaries. the transmitter does not freeze in the send break mode. communications can be lost if the channel is not programmed to support flow control. see section 5 cpu32 for more information on freeze. iccs?nput capture clock select 1 = selects sclk as the clear-to-send input capture clock for both channels. clear- to-send operation is enabled by setting bit 4 in mr2. the data is captured on the cts ? pins on the rising edge of the clock. 0 = the crystal clock is the clear-to-send input capture clock for both channels. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 7- 21 bits 11?, 6??eserved supv?upervisor/user the value of this bit has no affect on registers permanently defined as supervisor only. 1 = the serial module registers, which are defined as supervisor or user, reside in supervisor data space and are only accessible from supervisor programs. 0 = the serial module registers, which are defined as supervisor or user, reside in user data space and are accessible from either supervisor or user programs. iarb3?arb0?nterrupt arbitration bits each module that generates interrupts has an iarb field. these bits are used to arbitrate for the bus in the case that two or more modules simultaneously generate an interrupt at the same priority level. no two modules can share the same iarb value. the reset value of the iarb field is $0, which prevents this module from arbitrating during the interrupt acknowledge cycle. the system software should initialize the iarb field to a value from $f (highest priority) to $1 (lowest priority). 7.4.1.2 interrupt level register (ilr). the ilr contains the priority level for the serial module interrupt request. when the serial module is enabled (i.e., the stp bit in the mcr is cleared), this register can be read or written to at any time while in supervisor mode. ilr $704 76543210 00000il2il1il0 reset: 00000000 read/write supervisor only bits 7??eserved il2?l0?nterrupt level bits each module that can generate interrupts has an interrupt level field. the priority level encoded in these bits is sent to the cpu32 on the appropriate irq ? signal. the cpu32 uses this value to determine servicing priority. the hardware reset value of $00 will not generate any interrupts. see section 5 cpu32 for more information. 7.4.1.3 interrupt vector register (ivr). the ivr contains the 8-bit vector number of the interrupt. when the serial module is enabled (i.e., the stp bit in the mcr is cleared), this register can be read or written to at any time while in supervisor mode. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 7- 22 mc68340 user? manual motorola ivr $705 76543210 ivr7 ivr6 ivr5 ivr4 ivr3 ivr2 ivr1 ivr0 reset: 00001111 read /write supervisor only ivr7?vr0?nterrupt vector bits each module that generates interrupts has an interrupt vector field. this 8-bit number indicates the offset from the base of the vector table where the address of the exception handler for the specified interrupt is located. the ivr is reset to $0f, which indicates an uninitialized interrupt condition. see section 5 cpu32 for more information. 7.4.1.4 mode register 1 (mr1). mr1 controls some of the serial module configuration. this register can be read or written at any time when the serial module is enabled (i.e., the stp bit in the mcr is cleared). mr1a, mr1b $710, $718 76543210 rxrts r/f err pm1 pm0 pt b/c1 b/c0 reset: 00000000 read/write supervisor/user rxrts?eceiver request-to-send control 1 = upon receipt of a valid start bit, rts ? is negated if the channel's fifo is full. rts ? is reasserted when the fifo has an empty position available. 0 = rts ? is asserted by setting bit 1 or 0 in the op and negated by clearing bit 1 or 0 in the op. this feature can be used for flow control to prevent overrun in the receiver by using the rts ? output to control the cts ? input of the transmitting device. if both the receiver and transmitter are programmed for rts control, rts control will be disabled for both since this configuration is incorrect. see 7.4.1.17 mode register 2 for information on programming the transmitter rts ? control. r/f?eceiver-ready select 1 = bit 5 for channel b and bit 1 for channel a in the isr reflect the channel fifo full status. these isr bits are set when the receiver fifo is full and are cleared when a position is available in the fifo. 0 = bit 5 for channel b and bit 1 for channel a in the isr reflect the channel receiver- ready status. these isr bits are set when a character has been received and are cleared when the cpu32 reads the receive buffer. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 7- 23 err?rror mode this bit controls the meaning of the three fifo status bits (rb, fe, and pe) in the sr for the channel. 1 = block mode?he values in the channel sr are the accumulation (i.e., the logical or) of the status for all characters coming to the top of the fifo since the last reset error status command for the channel was issued. refer to 7.4.1.7 command register (cr) for more information on serial module commands. 0 = character mode?he values in the channel sr reflect the status of the character at the top of the fifo. note err = 0 must be used to get the correct a/d flag information when in multidrop mode. pm1?m0?arity mode these bits encode the type of parity used for the channel (see table 7-2). the parity bit is added to the transmitted character, and the receiver performs a parity check on incoming data. these bits can alternatively select multidrop mode for the channel. pt?arity type this bit selects the parity type if parity is programmed by the parity mode bits, and if multidrop mode is selected, it configures the transmitter for data character transmission or address character transmission. table 7-2 lists the parity mode and type or the multidrop mode for each combination of the parity mode and the parity type bits. table 7-2. pmx and pt control bits pm1 pm0 parity mode pt parity type 0 0 with parity 0 even parity 0 0 with parity 1 odd parity 0 1 force parity 0 low parity 0 1 force parity 1 high parity 1 0 no parity x no parity 1 1 multidrop mode 0 data character 1 1 multidrop mode 1 address character b/c1?/c0?its per character these bits select the number of data bits per character to be transmitted. the character length listed in table 7-3 does not include start, parity, or stop bits. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 7- 24 mc68340 user? manual motorola table 7-3. b/cx control bits b/c1 b/c0 bits/character 0 0 five bits 0 1 six bits 1 0 seven bits 1 1 eight bits 7.4.1.5 status register (sr). the sr indicates the status of the characters in the fifo and the status of the channel transmitter and receiver. this register can only be read when the serial module is enabled (i.e., the stp bit in the mcr is cleared). sra, srb $711, $719 76543210 rb fe pe oe txemp txrdy ffull rxrdy reset: 00000000 read only supervisor/user rb?eceived break 1 = an all-zero character of the programmed length has been received without a stop bit. the rb bit is only valid when the rxrdy bit is set. only a single fifo position is occupied when a break is received. further entries to the fifo are inhibited until the channel rxdx returns to the high state for at least one-half bit time, which is equal to two successive edges of the internal or external 1 clock or 16 successive edges of the external 16 clock. the received break circuit detects breaks that originate in the middle of a received character. however, if a break begins in the middle of a character, it must persist until the end of the next detected character time. 0 = no break has been received. fe?raming error 1 = a stop bit was not detected when the corresponding data character in the fifo was received. the stop-bit check is made in the middle of the first stop-bit position. the bit is valid only when the rxrdy bit is set. 0 = no framing error has occurred. pe?arity error 1 = when the with parity or force parity mode is programmed in the mr1, the corresponding character in the fifo was received with incorrect parity. when the multidrop mode is programmed, this bit stores the received a/d bit. this bit is valid only when the rxrdy bit is set. 0 = no parity error has occurred. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 7- 25 oe?verrun error 1 = one or more characters in the received data stream have been lost. this bit is set upon receipt of a new character when the fifo is full and a character is already in the shift register waiting for an empty fifo position. when this occurs, the character in the receiver shift register and its break detect, framing error status, and parity error, if any, are lost. this bit is cleared by the reset error status command in the cr. 0 = no overrun has occurred. txemp?ransmitter empty 1 = the channel transmitter has underrun (both the transmitter holding register and transmitter shift registers are empty). this bit is set after transmission of the last stop bit of a character if there are no characters in the transmitter holding register awaiting transmission. 0 = the transmitter buffer is not empty. the transmitter holding register is loaded by the cpu32, or the transmitter is disabled. the transmitter is enabled/disabled by programming the tcx bits in the cr. txrdy?ransmitter ready this bit is duplicated in the isr; bit 0 for channel a and bit 4 for channel b. 1 = the transmitter holding register is empty and ready to be loaded with a character. this bit is set when the character is transferred to the transmitter shift register. this bit is also set when the transmitter is first enabled. characters loaded into the transmitter holding register while the transmitter is disabled are not transmitted and are lost. 0 = the transmitter holding register was loaded by the cpu32, or the transmitter is disabled. ffull?ifo full 1 = a character was transferred from the receiver shift register to the receiver fifo and the transfer caused the fifo to become full (all three fifo holding register positions are occupied). 0 = the cpu32 has read the receiver buffer and one or more fifo positions are available. note that if there is a character in the receiver shift register because the fifo is full, this character will be moved into the fifo when a position is available, and the fifo will remain full. rxrdy?eceiver ready 1 = a character has been received and is waiting in the fifo to be read by the cpu32. this bit is set when a character is transferred from the receiver shift register to the fifo. 0 = the cpu32 has read the receiver buffer, and no characters remain in the fifo after this read. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 7- 26 mc68340 user? manual motorola 7.4.1.6 clock-select register (csr). the csr selects the baud rate clock for the channel receiver and transmitter. this register can only be written when the serial module is enabled (i.e., the stp bit in the mcr is cleared). note this register should only be written after the external crystal is stable (xtal_rdy bit of the isr is zero). csra, csrb $711, $719 76543210 rcs3 rcs2 rcs1 rcs0 tcs3 tcs2 tcs1 tcs0 reset: 00000000 write only supervisor/user rcs3?cs0?eceiver clock select these bits select the baud rate clock for the channel receiver from a set of baud rates listed in table 7-4. the baud rate set selected depends upon the auxiliary control register (acr) bit 7. set 1 is selected if acr bit 7 = 0, and set 2 is selected if acr bit 7??. the receiver clock is always 16 times the baud rate shown in this list, except when sclk is used. table 7-4. rcsx control bits rcs3 rcs2 rcs1 rcs0 set 1 set 2 0 0 0 0 50 75 0 0 0 1 110 110 0 0 1 0 134.5 134.5 0 0 1 1 200 150 0 1 0 0 300 300 0 1 0 1 600 600 0 1 1 0 1200 1200 0 1 1 1 1050 2000 1 0 0 0 2400 2400 1 0 0 1 4800 4800 1 0 1 0 7200 1800 1 0 1 1 9600 9600 1 1 0 0 38.4k 19.2k 1 1 0 1 76.8k 38.4k 1 1 1 0 sclk/16 sclk/16 1 1 1 1 sclk/1 sclk/1 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 7- 27 tcs3?cs0?ransmitter clock select these bits select the baud rate clock for the channel transmitter from a set of baud rates listed in table 7-5. the baud rate set selected depends upon acr bit 7. set 1 is selected if acr bit 7 = 0, and set 2 is selected if acr bit 7 = 1. the transmitter clock is always 16 times the baud rate shown in this list, except when sclk is used. table 7-5. tcsx control bits tcs3 tcs2 tcs1 tcs0 set 1 set 2 0 0 0 0 50 75 0 0 0 1 110 110 0 0 1 0 134.5 134.5 0 0 1 1 200 150 0 1 0 0 300 300 0 1 0 1 600 600 0 1 1 0 1200 1200 0 1 1 1 1050 2000 1 0 0 0 2400 2400 1 0 0 1 4800 4800 1 0 1 0 7200 1800 1 0 1 1 9600 9600 1 1 0 0 38.4k 19.2k 1 1 0 1 76.8k 38.4k 1 1 1 0 sclk/16 sclk/16 1 1 1 1 sclk/1 sclk/1 7.4.1.7 command register (cr). the cr is used to supply commands to the channel. multiple commands can be specified in a single write to the cr if the commands are not conflicting?.g., reset transmitter and enable transmitter commands cannot be specified in a single command. this register can only be written when the serial module is enabled (i.e., the stp bit in the mcr is cleared). cra, crb $712, $71a 76543210 misc3 misc2 misc1 misc0 tc1 tc0 rc1 rc0 reset: 00000000 write only supervisor/user f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 7- 28 mc68340 user? manual motorola misc3?isc0?iscellaneous commands these bits select a single command as listed in table 7-6. table 7-6. miscx control bits misc3 misc2 misc1 misc0 command 0 0 0 0 no command 0 0 0 1 no command 0 0 1 0 reset receiver 0 0 1 1 reset transmitter 0 1 0 0 reset error status 0 1 0 1 reset break-change interrupt 0 1 1 0 start break 0 1 1 1 stop break 1 0 0 0 assert rts 1 0 0 1 negate rts 1 0 1 0 no command 1 0 1 1 no command 1 1 0 0 no command 1 1 0 1 no command 1 1 1 0 no command 1 1 1 1 no command reset receiver?he reset receiver command resets the channel receiver. the receiver is immediately disabled, the ffull and rxrdy bits in the sr are cleared, and the receiver fifo pointer is reinitialized. all other registers are unaltered. this command should be used in lieu of the receiver disable command whenever the receiver configuration is changed because it places the receiver in a known state. reset transmitter?he reset transmitter command resets the channel transmitter. the transmitter is immediately disabled, and the txemp and txrdy bits in the sr are cleared. all other registers are unaltered. this command should be used in lieu of the transmitter disable command whenever the transmitter configuration is changed because it places the transmitter in a known state. reset error status?he reset error status command clears the channel's rb, fe, pe, and oe bits (in the sr). this command is also used in the block mode to clear all error bits after a data block is received. reset break-change interrupt?he reset break-change interrupt command clears the delta break (dbx) bits in the isr. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 7- 29 start break?he start break command forces the channel's txdx low. if the transmitter is empty, the start of the break conditions can be delayed up to one bit time. if the transmitter is active, the break begins when transmission of the character is complete. if a character is in the transmitter shift register, the start of the break is delayed until the character is transmitted. if the transmitter holding register has a character, that character is transmitted after the break. the transmitter must be enabled for this command to be accepted. the state of the cts ? input is ignored for this command. stop break?he stop break command causes the channel's txdx to go high (mark) within two bit times. characters stored in the transmitter buffer, if any, are transmitted. assert rts ?he assert rts command forces the channel's rts ? output low. negate rts ?he negate rts command forces the channel's rts ? output high. tc1?c0?ransmitter commands these bits select a single command as listed in table 7-7. table 7-7. tcx control bits tc1 tc0 command 0 0 no action taken 0 1 enable transmitter 1 0 disable transmitter 1 1 do not use no action taken?he no action taken command causes the transmitter to stay in its current mode. if the transmitter is enabled, it remains enabled; if disabled, it remains disabled. transmitter enable?he transmitter enable command enables operation of the channel's transmitter. the txemp and txrdy bits in the sr are also set. if the transmitter is already enabled, this command has no effect. transmitter disable?he transmitter disable command terminates transmitter operation and clears the txemp and txrdy bits in the sr. however, if a character is being transmitted when the transmitter is disabled, the transmission of the character is completed before the transmitter becomes inactive. if the transmitter is already disabled, this command has no effect. do not use?o not use this bit combination because the result is indeterminate. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 7- 30 mc68340 user? manual motorola rc1?c0?eceiver commands these bits select a single command as listed in table 7-8. table 7-8. rcx control bits rc1 rc0 command 0 0 no action taken 0 1 enable receiver 1 0 disable receiver 1 1 do not use no action taken?he no action taken command causes the receiver to stay in its current mode. if the receiver is enabled, it remains enabled; if disabled, it remains disabled. receiver enable?he receiver enable command enables operation of the channel's receiver. if the serial module is not in multidrop mode, this command also forces the receiver into the search-for-start-bit state. if the receiver is already enabled, this command has no effect. receiver disable?he receiver disable command disables the receiver immediately. any character being received is lost. the command has no effect on the receiver status bits or any other control register. if the serial module is programmed to operate in the local loopback mode or multidrop mode, the receiver operates even though this command is selected. if the receiver is already disabled, this command has no effect. do not use?o not use this bit combination because the result is indeterminate. 7.4.1.8 receiver buffer (rb). the receiver buffer contains three receiver holding registers and a serial shift register. the channel's rxdx pin is connected to the serial shift register. the holding registers act as a fifo. the cpu32 reads from the top of the stack while the receiver shifts and updates from the bottom of the stack when the shift register has been filled (see figure 7-4). this register can only be read when the serial module is enabled (i.e., the stp bit in the mcr is cleared). rba, rbb $713, $71b 76543210 rb7 rb6 rb5 rb4 rb3 rb2 rb1 rb0 reset: 00000000 read only supervisor/user rb7?b0?hese bits contain the character in the receiver buffer. 7.4.1.9 transmitter buffer (tb). the transmitter buffer consists of two registers, the transmitter holding register and the transmitter shift register (see figure 7-4). the holding register accepts characters from the bus master if the txrdy bit in the channel's sr is set. a write to the transmitter buffer clears the txrdy bit, inhibiting any more f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 7- 31 characters until the shift register is ready to accept more data. when the shift register is empty, it checks to see if the holding register has a valid character to be sent (txrdy bit cleared). if there is a valid character, the shift register loads the character and reasserts the txrdy bit in the channel's sr. writes to the transmitter buffer when the channel's sr txrdy bit is clear and when the transmitter is disabled have no effect on the transmitter buffer. this register can only be written when the serial module is enabled (i.e., the stp bit in the mcr is cleared). tba, tbb $713, $71b 76543210 tb7 tb6 tb5 tb4 tb3 tb2 tb1 tb0 reset: 00000000 write only supervisor/user tb7?b0?hese bits contain the character in the transmitter buffer. 7.4.1.10 input port change register (ipcr). the ipcr shows the current state and the change-of-state for the ctsa and ctsb pins. this register can only be read when the serial module is enabled (i.e., the stp bit in the mcr is cleared). ipcr $714 76543210 0 0 cosb cosa 0 0 ctsb ctsa reset: 000000uu read only supervisor/user bits 7, 6, 3, 2?eserved cosb, cosa?hange-of-state 1 = a change-of-state (high-to-low or low-to-high transition), lasting longer than 25 50 m s when using a crystal as the sampling clock or longer than one or two periods when using sclk, has occurred at the corresponding cts ? input (mcr iccs bit controls selection of the sampling clock for clear-to-send operation). when these bits are set, the acr can be programmed to generate an interrupt to the cpu32. 0 = the cpu32 has read the ipcr. no change-of-state has occurred. a read of the ipcr also clears the isr cos bit. ctsb, ctsa?urrent state starting two serial clock periods after reset, the cts ? bits reflect the state of the cts ? pins. if a cts ? pin is detected as asserted at that time, the associated cosx bit will be set, which will initiate an interrupt if the corresponding iecx bit of the acr register is enabled. 1 = the current state of the respective cts ? input is negated. 0 = the current state of the respective cts ? input is asserted. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 7- 32 mc68340 user? manual motorola 7.4.1.11 auxiliary control register (acr). the acr selects which baud rate is used and controls the handshake of the transmitter/receiver. this register can only be written when the serial module is enabled (i.e., the stp bit in the mcr is cleared). acr $714 76543210 brg00000 iecb ieca reset: 00000000 write only supervisor/user brg?aud rate generator set select 1 = set 2 of the available baud rates is selected. 0 = set 1 of the available baud rates is selected. refer to 7.4.1.6 clock-select register (csr) for more information on the baud rates. iecb, ieca?nput enable control 1 = isr bit 7 will be set and an interrupt will be generated when the corresponding bit in the ipcr (cosb or cosa) is set by an external transition on the channel's cts ? input (if bit 7 of the interrupt enable register (ier) is set to enable interrupts). 0 = setting the corresponding bit in the ipcr has no effect on isr bit 7. 7.4.1.12 interrupt status register (isr). the isr provides status for all potential interrupt sources. the contents of this register are masked by the ier. if a flag in the isr is set and the corresponding bit in ier is also set, the irq ? output is asserted. if the corresponding bit in the ier is cleared, the state of the bit in the isr has no effect on the output. this register can only be read when the serial module is enabled (i.e., the stp bit in the mcr is cleared). note the ier does not mask reading of the isr. true status is provided regardless of the contents of ier. the contents of isr are cleared when the serial module is reset. isr $715 76543210 cos dbb rxrdyb txrdyb xtal_ rdy dba rxrdya txrdya reset: 00001000 read only supervisor/user cos?hange-of-state 1 = a change-of-state has occurred at one of the cts ? inputs and has been selected to cause an interrupt by programming bit 1 and/or bit 0 of the acr. 0 = the cpu32 has read the ipcr. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 7- 33 dbb?elta break b 1 = the channel b receiver has detected the beginning or end of a received break. 0 = the cpu32 has issued a channel b reset break-change interrupt command. refer to 7.4.1.7 command register (cr) for more information on the reset break-change interrupt command. rxrdyb?hannel b receiver ready or fifo full the function of this bit is programmed by mr1b bit 6. 1 = if programmed as receiver ready, a character has been received in channel b and is waiting in the receiver buffer fifo. if programmed as fifo full, a character has been transferred from the receiver shift register to the fifo, and the transfer has caused the channel b fifo to become full (all three positions are occupied). 0 = if programmed as receiver ready, the cpu32 has read the receiver buffer. after this read, if more characters are still in the fifo, the bit is set again after the fifo is 'popped'. if programmed as fifo full, the cpu32 has read the receiver buffer. if a character is waiting in the receiver shift register because the fifo is full, the bit will be set again when the waiting character is loaded into the fifo. txrdyb?hannel b transmitter ready this bit is the duplication of the txrdy bit in srb. 1 = the transmitter holding register is empty and ready to be loaded with a character. this bit is set when the character is transferred to the transmitter shift register. this bit is also set when the transmitter is first enabled. characters loaded into the transmitter holding register while the transmitter is disabled are not transmitted. 0 = the transmitter holding register was loaded by the cpu32, or the transmitter is disabled. xtal_rdy?erial clock running this bit is always read as a zero when the x1 clock is running. this bit cannot be enabled to generate an interrupt. 1 = this bit is set at reset. 0 = this bit is cleared after the baud rate generator is stable. the csr should not be accessed until this bit is zero. dba?elta break a 1 = the channel a receiver has detected the beginning or end of a received break. 0 = the cpu32 has issued a channel a reset break-change interrupt command. refer to 7.4.1.7 command register (cr) for more information on the reset break-change interrupt command. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 7- 34 mc68340 user? manual motorola rxrdya?hannel a receiver ready or fifo full the function of this bit is programmed by mr1a bit 6. 1 = if programmed as receiver ready, a character has been received in channel a and is waiting in the receiver buffer fifo. if programmed as fifo full, a character has been transferred from the receiver shift register to the fifo, and the transfer has caused the channel a fifo to become full (all three positions are occupied). 0 = if programmed as receiver ready, the cpu32 has read the receiver buffer. after this read, if more characters are still in the fifo, the bit is set again after the fifo is 'popped'. if programmed as fifo full, the cpu32 has read the receiver buffer. if a character is waiting in the receiver shift register because the fifo is full, the bit will be set again when the waiting character is loaded into the fifo. txrdya?hannel a transmitter ready this bit is the duplication of the txrdy bit in sra. 1 = the transmitter holding register is empty and ready to be loaded with a character. this bit is set when the character is transferred to the transmitter shift register. this bit is also set when the transmitter is first enabled. characters loaded into the transmitter holding register while the transmitter is disabled are not transmitted. 0 = the transmitter holding register was loaded by the cpu32, or the transmitter is disabled. 7.4.1.13 interrupt enable register (ier). the ier selects the corresponding bits in the isr that cause an interrupt output ( irq ? ). if one of the bits in the isr is set and the corresponding bit in the ier is also set, the irq ? output is asserted. if the corresponding bit in the ier is zero, the state of the bit in the isr has no effect on the irq ? output. the ier does not mask the reading of the isr. the isr xtal_rdy bit cannot be enabled to generate an interrupt. this register can only be written when the serial module is enabled (i.e., the stp bit in the mcr is cleared). ier $715 76543210 cos dbb rxrdyb txrdyb 0 dba rxrdya txrdya reset: 00000000 write only supervisor/user cos?hange-of-state 1 = enable interrupt 0 = disable interrupt dbb?elta break b 1 = enable interrupt 0 = disable interrupt f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 7- 35 rxrdyb?hannel b receiver ready or fifo full 1 = enable interrupt 0 = disable interrupt txrdyb?hannel b transmitter ready 1 = enable interrupt 0 = disable interrupt bit 3?eserved dba?elta break a 1 = enable interrupt 0 = disable interrupt rxrdya?hannel a receiver ready or fifo full 1 = enable interrupt 0 = disable interrupt txrdya?hannel a transmitter ready 1 = enable interrupt 0 = disable interrupt 7.4.1.14 input port (ip). the ip register shows the current state of the cts ? inputs. this register can only be read when the serial module is enabled (i.e., the stp bit in the mcr is cleared). ip $71d 76543210 000000 ctsb ctsa reset: 000000uu read only supervisor/user ctsb, ctsa?urrent state 1 = the current state of the respective cts ? input is negated. 0 = the current state of the respective cts ? input is asserted. the information contained in these bits is latched and reflects the state of the input pins at the time that the ip is read. note these bits have the same function and value of the ipcr bits 1 and 0. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 7- 36 mc68340 user? manual motorola 7.4.1.15 output port control register (opcr). the opcr individually configures four bits of the 8-bit parallel op for general-purpose use or as an auxiliary function serving the communication channels. this register can only be written when the serial module is enabled (i.e., the stp bit in the mcr is cleared). opcr $71d 76543210 op7 t ? rdyb op6 t ? rdya op5 r ? rdyb op4 r ? rdya op3 op2 op1 rtsb op0 rtsa reset: 00000000 write only supervisor/user note op bits 7, 5, 3, and 2 are not pinned out on the mc68340; thus changing bits 7, 5, 3, and 2 of this register has no effect. op6?utput port 6/ t ? rdya 1 = the op6/ t ? rdya pin functions as the transmitter-ready signal for channel a. the signal reflects the complement of the value of bit 2 of the sra; thus, t ? rdya is a logic zero when the transmitter is ready. 0 = the op6/ t ? rdya pin functions as a dedicated output. the signal reflects the complement of the value of bit 6 of the op. op4?utput port 4/ r ? rdya 1 = the op4/ r ? rdya pin functions as the fifo-full or receiver-ready signal for channel a (depending on the value of bit 6 of mr1a). the signal reflects the complement of the value of isr bit 1; thus, r ? rdya is a logic zero when the receiver is ready. 0 = the op4/ r ? rdya pin functions as a dedicated output. the signal reflects the complement of the value of bit 4 of the op. op1?utput port 1/ rtsb 1 = the op1/ rtsb pin functions as the ready-to-send signal for channel b. the signal is asserted and negated according to the configuration programmed by rxrts bit 7 in the mr1b for the receiver and txrts bit 5 in the mr2b for the transmitter. 0 = the op1/ rtsb pin functions as a dedicated output. the signal reflects the complement of the value of bit 1 of the op. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 7- 37 op0?utput port 0/ rtsa 1 = the op0/ rtsa pin functions as the ready-to-send signal for channel a. the signal is asserted and negated according to the configuration programmed by rxrts bit 7 in the mr1a for the receiver and txrts bit 5 in the mr2a for the transmitter. 0 = the op0/ rtsa pin functions as a dedicated output. the signal reflects the complement of the value of bit 0 of the op. 7.4.1.16 output port data register (op). the bits in the op register are set by performing a bit set command (writing to offset $71e) and are cleared by performing a bit reset command (writing to offset $71f). this register can only be written when the serial module is enabled (i.e., the stp bit in the mcr is cleared). bit set op $71e 76543210 op7 op6 op5 op4 op3 op2 op1 op0 reset: 00000000 write only supervisor/user note op bits 7, 5, 3, and 2 are not pinned out on the mc68340; thus, changing these bits has no effect. op6, op4, op1, op0 ?utput port parallel outputs 1 = these bits can be set by writing a one to the bit position(s) at this address. 0 = these bits are not affected by writing a zero to this address. bit reset op $71f 76543210 op7 op6 op5 op4 op3 op2 op1 op0 reset: 00000000 write only supervisor/user note op bits 7, 5, 3, and 2 are not pinned out on the mc68340; thus, changing these bits has no effect. op6, op4, op1, op0 ?utput port parallel outputs 1 = these bits can be cleared by writing a one to the bit position(s) at this address. 0 = these bits are not affected by writing a zero to this address. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 7- 38 mc68340 user? manual motorola 7.4.1.17 mode register 2 (mr2). mr2 controls some of the serial module configuration. this register can be read or written at any time the serial module is enabled (i.e., the stp bit in the mcr is cleared). mr2a, mr2b $720, $721 76543210 cm1 cm0 txrts txcts sb3 sb2 sb1 sb0 reset: 00000000 read/write supervisor/user cm1?m0?hannel mode these bits select a channel mode as listed in table 7-9. see 7.3.3 looping modes for more information on the individual modes. table 7-9. cmx control bits cm1 cm0 mode 0 0 normal 0 1 automatic echo 1 0 local loopback 1 1 remote loopback txrts?ransmitter ready-to-send this bit controls the negation of the rtsa or rtsb signals. the output is normally asserted by setting op0 or op1 and negated by clearing op0 or op1 (see 7.4.1.15 output port control register (opcr) ). 1 = in applications where the transmitter is disabled after transmission is complete, setting this bit causes the particular op bit to be cleared automatically one bit time after the characters, if any, in the channel transmit shift register and the transmitter holding register are completely transmitted, including the programmed number of stop bits. this feature is used to automatically terminate transmission of a message. if both the receiver and the transmitter in the same channel are programmed for rts control, rts control is disabled for both since this is an incorrect configuration. 0 = clearing this bit has no effect on the transmitter rts ? . f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 7- 39 txcts?ransmitter clear-to-send 1 = enables clear-to-send operation. the transmitter checks the state of the cts ? input each time it is ready to send a character. if cts ? is asserted, the character is transmitted. if cts ? is negated, the channel txdx remains in the high state, and the transmission is delayed until cts ? is asserted. changes in cts ? while a character is being transmitted do not affect transmission of that character. if both txcts and txrts are enabled, txcts controls the operation of the transmitter. 0 = the cts ? has no effect on the transmitter. sb3?b0?top-bit length control these bits select the length of the stop bit appended to the transmitted character as listed in table 7-10. stop-bit lengths of nine-sixteenth to two bits, in increments of one- sixteenth bit, are programmable for character lengths of six, seven, and eight bits. for a character length of five bits, one and one-sixteenth to two bits are programmable in increments of one-sixteenth bit. in all cases, the receiver only checks for a high condition at the center of the first stop-bit position?.e., one bit time after the last data bit or after the parity bit, if parity is enabled. if an external 1 clock is used for the transmitter, mr2 bit 3 = 0 selects one stop bit, and mr2 bit 3 = 1 selects two stop bits for transmission. table 7-10. sbx control bits sb3 sb2 sb1 sb0 length 6-8 bits length 5 bits 0 0 0 0 0.563 1.063 0 0 0 1 0.625 1.125 0 0 1 0 0.688 1.188 0 0 1 1 0.750 1.250 0 1 0 0 0.813 1.313 0 1 0 1 0.875 1.375 0 1 1 0 0.938 1.438 0 1 1 1 1.000 1.500 1 0 0 0 1.563 1.563 1 0 0 1 1.625 1.625 1 0 1 0 1.688 1.688 1 0 1 1 1.750 1.750 1 1 0 0 1.813 1.813 1 1 0 1 1.875 1.875 1 1 1 0 1.938 1.938 1 1 1 1 2.000 2.000 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 7- 40 mc68340 user? manual motorola 7.4.2 programming the basic interface software flowchart required for operation of the serial module is shown in figure 7-10. the routines are divided into three categories: serial module initialization i/o driver interrupt handling 7.4.2.1 serial module initialization. the serial module initialization routines consist of sinit and chchk. sinit is called at system initialization time to check channel a and channel b operation. before sinit is called, the calling routine allocates two words on the system stack. upon return to the calling routine, sinit passes information on the system stack to reflect the status of the channels. if sinit finds no errors in either channel a or channel b, the respective receivers and transmitters are enabled. the chchk routine performs the actual channel checks as called from the sinit routine. when called, sinit places the specified channel in the local loopback mode and checks for the following errors: transmitter never ready receiver never ready parity error incorrect character received 7.4.2.2 i/o driver example. the i/o driver routines consist of inch, outch, and poutch. inch is the terminal input character routine and gets a character from the channel a receiver and places it in the lower byte of register d0. outch is used to send the character in the lower byte of register d0 to the channel a transmitter. poutch sends the character in the lower byte of d0 to the channel b transmitter. 7.4.2.3 interrupt handling. the interrupt handling routine consists of sirq, which is executed after the serial module generates an interrupt caused by a channel a change- in-break (beginning of a break). sirq then clears the interrupt source, waits for the next change-in-break interrupt (end of break), clears the interrupt source again, then returns from exception processing to the system monitor. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 7- 41 serial module initiate: channel a c hannel b i nterrupts point to channel a save channel a status point to channel b save channel b status any errors in channel a ? enable channel a's receiver assert channel a request to send any errors in channel b ? enable channel b's transmitter return sinit chk1 chk2 enabla y n enablb sinitr call chchk call chchk y n figure 7-10. serial module programming flowchart (1 of 5) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 7- 42 mc68340 user? manual motorola y n chchk place channel in local loopback mode enable channel's transmitter clear channel status word is t ransmitter ready ? waited too long ? waited too long ? n y send character to transmitter has receiver received character ? chchk txchk sndchr rxchk n y n set transmitter- never-ready flag set receiver- never-ready flag a b y figure 7-10. serial module programming flowchart (2 of 5) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 7- 43 b y n n a y a b y n return have framing error ? set framing error flag have parity erro r ? set parity error flag get character from receiver same as character transmitted ? set incorrect character flag disable channel's transmitter restore channel to original mode frchk rstchn prchk chrchk figure 7-10. serial module programming flowchart (3 of 5) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 7- 44 mc68340 user? manual motorola was irqx caused by beginning of a break ? clear change-in- break status bit has end-of-break irqx arrived yet ? clear change-in- break status bit remove break character from receiver fifo replace return address on system stack and monitor warm start address rte sirqr n y n does channel a receiver have a character ? place character in d0 n y abrki1 abrki y inch return sirq figure 7-10. serial module programming flowchart (4 of 5) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 7- 45 pouch n y is channel b transmitter ready ? send character i n d0 to channe l b transmitter n y pouchi poutchr was character a carriage return ? is channel b transmitter ready ? send a line feed character to channel b transmitter n return outch n y is channel a transmitter ready ? send character in d0 to channel a transmitter n y outchi outchr was character a carriage return ? is channel a transmitter ready ? send a line feed character to channel a transmitter n return y y figure 7-10. serial module programming flowchart (5 of 5) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 7- 46 mc68340 user? manual motorola 7.5 serial module initialization sequence the following paragraphs discuss a suggested method for initializing the serial module. 7.5.1 serial module configuration if the serial capability of the mc68340 is being used, the following steps are required to properly initialize the serial module. note the serial module registers can only be accessed by byte operations. command register (cr) reset the receiver and transmitter for each channel. the following steps program both channels: module configuration register (mcr) initialize the stop bit (stp) for normal operation. select whether to respond to or ignore freeze (frzx bits). select the input capture clock (iccs bit). select the access privilege for the supervisor/user registers (supv bit). select the interrupt arbitration level for the serial module (iarbx bits). interrupt vector register (ivr) program the vector number for a serial module interrupt. interrupt level register (ilr) program the interrupt priority level for a serial module interrupt. interrupt enable register (ier) enable the desired interrupt sources. auxiliary control register (acr) select baud rate set (brg bit). initialize the input enable control (iec bits). output port control register (opcr) select the function of the output port pins. interrupt status register (isr) the xtal_rdy bit should be polled until it is cleared to ensure that an unstable crystal input is not applied to the baud rate generator. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 7- 47 the following steps are channel specific: clock select register (csr) select the receiver and transmitter clock. mode register 1 (mr1) if desired, program operation of receiver ready-to-send (rxrts bit). select receiver-ready or fifo-full notification (r/f bit). select character or block error mode (err bit). select parity mode and type (pm and pt bits). select number of bits per character (b/cx bits). mode register 2 (mr2) select the mode of channel operation (cmx bits). if desired, program operation of transmitter ready-to-send (txrts bit). if desired, program operation of clear-to-send (txcts bit). select stop-bit length (sbx bits). command register (cr) ?enable the receiver and transmitter. 7.5.2 serial module example configuration code the following code is an example of a configuration sequence for the serial module. *************************************************************************** * mc68340 basic serial module register initialization example code. * this code is used to initialize the 68340's internal serial module registers, * providing basic functions for operation. * it sets up serial channel a for communication with a 9600 baud terminal. * note: all serial module registers must be accessed as bytes. *************************************************************************** *************************************************************************** * equates *************************************************************************** mbar equ $0003ff00 address of sim40 module base address reg. modbase equ $fffff000 sim40 mbar address value *************************************************************** * serial module equates serial equ $700 offset from mbar for serial module regs mcrh equ $0 serial mcr high byte mcrl equ $1 serial mcr low byte f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 7- 48 mc68340 user? manual motorola * serial register offsets from serial base address mr1a equ $10 mode register 1 a mr2a equ $20 mode register 2 a sra equ $11 status register a csra equ $11 clock select reg a cra equ $12 command reg a acr equ $14 auxiliary control reg opcr equ $1d output port control reg op_bs equ $1e output port bit set (write 1 to set) op_br equ $1f output port bit reset (write 1 to clear) *************************************************************************** *************************************************************************** * initialize serial channel a *************************************************************************** lea modbase+serial,a0 pointer to serial channel a * module configuration register: * enable serial module for normal operation, ignore freeze, select the * crystal clock. supervisor/user serial registers unrestricted. * interrupt arbitration at priority $02. move.b #$00,mcrh(a0) move.b #$02,mcrl(a0) * wait for transmitter empty (or timeout) move.w #$2000,d0 init loop counter xbmtwait equ * btst #3,sra(a0) tx empty in status reg? nop dbne d0,xbmtwait loop until set or timeout * negate rtsa signal output move.b #0,opcr(a0) make op0-7 general purpose move.b #$01,op_br(a0) clear rtsa /op0 output * reset receiver/transmitter move.b #$20,cra(a0) issue reset receiver command move.b #$30,cra(a0) issue reset transmitter command * set baud rate set 2 move.b #$80,acr(a0) * mode register 1 move.b #$93,mr1a(a0) 8 bits, no parity, auto rts control f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 7- 49 * mode register 2 move.b #$07,mr2a(a0) normal, 1 stop bit * set up baud rate for port in clock select register move.b #$bb,csra(a0) set 9600 baud for rx and tx * set rtsa active move.b #$01,op_bs(a0) set rtsa /op0 output * enable port move.b #$45,cra(a0) reset error status, enable rx & tx *************************************************************************** end *************************************************************************** f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 8- 1 section 8 timer modules each mc68340 timer module contains a counter/timer (timer 1 and timer 2) as shown in figure 8-1. each timer interfaces directly to the cpu32 via the intermodule bus (imb). each timer consists of the following major areas: ?a general-purpose counter/timer ?internal control logic ?interrupt control logic timer 2 interrupt control logic imb interface tin2 tout2 tgate2 timer 2 timer 1 interrupt control logic imb interface tin1 tout1 tgate1 timer 1 figure 8-1. simplified block diagram 8.1 module overview each timer module consists of the following functional features: ?versatile general-purpose timer ?8-bit prescaler/16-bit counter ?timers can be externally cascaded for a maximum count width of 48 bits ?programmable timer modes: ?input capture/output compare ?square-wave generation ?variable duty-cycle square-wave generation ?variable-width single-shot pulse generation f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 8- 2 mc68340 user? manual motorola ?pulse-width measurement ?period measurement ?event counting ?seven maskable interrupt conditions based on programmable events 8.1.1 timer and counter functions the term 'timer' is used to reference either timer 1 or timer 2, since the two are functionally equivalent. the timer can perform virtually any application traditionally assigned to timers and counters. the timer can be used to generate timed events that are independent of the timing errors to which real-time programmed microprocessors are susceptible?or example, those of dynamic memory refreshing, dma cycle steals, and interrupt servicing. the timer has several functional areas: an 8-bit countdown prescaler, a 16-bit downcounter, timeout logic, compare logic, and clock selection logic. figure 8-2 shows a functional diagram of the timer module. 8.1.1.1 prescaler and counter. the counter can be driven directly by the selected clock or the prescaler output. both the counter and prescaler are updated on the falling edge of the clock. during reset, the prescaler is set to $ff, and the counter is set to $0000. the counter is loaded with a programmed value on the first falling edge of the counter clock after the timer is enabled and again when a timeout occurs (counter reaches $0000). the prescaler and counter can be used as one 24-bit counter by enabling the prescaler and selecting the divide-by-256 prescaler output. refer to 8.4 register description for additional information on how to program the timer. 8.1.1.2 timeout detection. timeout is achieved when all 16 stages of the counter transition to zero, a counter value of $0000. timeout is a defined counter event which triggers specific actions depending upon the programmed mode of operation. refer to 8.3 operating modes for descriptions of the individual modes. 8.1.1.3 comparator. the comparator block compares the value in the 16-bit compare register (com) with the output of the 16-bit counter. when an exact match is detected, bits in the status register (sr) are set to indicate this condition. when in the input capture/output compare mode, a match is a defined counter event that can affect the output of the timer (toutx). refer to 8.3.1 input capture/output compare for additional information on this mode. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 8- 3 i m b module configuration register interrupt register control register status register preload 1 register preload 2 register (system clock) clock mux 16-bit c ounte r clock logic counter clock mux 8-bit p rescale r selected c lock tin tgate timeout 16-bit c omparato r tout counter register compare register timer external i nterfac e figure 8-2. timer functional diagram 8.1.1.4 clock selection logic. the clock selection logic consists of two multiplexers that select the clocks applied to the prescaler and counter. the first multiplexer (labeled clock logic in figure 8-2) selects between the clock input to the timer (tinx) or one-half the frequency of the system clock (clkout). this output of the first multiplexer (called selected clock) is applied to both the 8-bit prescaler and the second multiplexer. the second multiplexer selects the clock for the 16-bit counter, which is either the selected clock or the 8-bit prescaler output. 8.1.2 internal control logic the timer receives operation commands on the imb and, in turn, issues appropriate operation signals to the internal timer control logic. this mechanism allows the timer registers to be accessed and programmed. refer to 8.4 register description for additional information. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 8- 4 mc68340 user? manual motorola 8.1.3 interrupt control logic each timer provides seven interrupt request outputs ( irq7 irq1 ) to notify the cpu32 that an interrupt has occurred. the interrupts are described in 8.4 register description . bits in the sr indicate all currently active interrupt conditions. the interrupt enable (ie) bits in the control register (cr) are programmable to mask any events that may cause an interrupt. 8.2 timer modules signal definitions this section contains a brief description of the timer module signals (see figure 8-3). note the terms assertion and negation are used throughout this section to avoid confusion when dealing with a mixture of active-low and active-high signals. the term assert or assertion indicates that a signal is active or true independent of the level represented by a high or low voltage. the term negate or negation indicates that a signal is inactive or false. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 8- 5 external i nterface s ignals timer 2 tin2 tgate2 tout2 tin1 tgate1 tout1 clock logic prescaler counter output c ontro l i m b interrupt control timer 1 clock logic prescaler counter output c ontro l interrupt control external i nterface s ignals figure 8-3. external and internal interface signals 8.2.1 timer input (tin1, tin2) this input can be programmed to be the clock that causes events to occur in the counter and prescaler. tinx is internally synchronized to the system clock to guarantee that a valid tinx level is recognized. additionally, the high and low levels of tinx must each be stable f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 8- 6 mc68340 user? manual motorola for at least one system clock period plus the sum of the setup and hold times for tinx. refer to section 11 electrical characteristics , for additional information. 8.2.2 timer gate ( tgate1, tgate2 ) this active-low input can be programmed to enable and disable the counter and prescaler. tgate ? may also be programmed to be a simple input. for more information on the modes of operation, refer to 8.3 operating modes . to guarantee that the timer recognizes a valid level on tgate ? , the signal is synchronized with the system clock. additionally, the high and low levels of this input must each be stable for at least one system clock period plus the sum of the setup and hold times for tgate ? . refer to section 11 electrical characteristics , for additional information. 8.2.3 timer output (tout1, tout2) this output drives the various output waveforms generated by the timer. the initial level and transitions can be programmed by the output control (oc) bits in the cr. 8.3 operating modes the following paragraphs contain a detailed description of each timer operation mode and of the imb operation during accesses to the timer. changing the contents of the cr should only be attempted when the timer is disabled (the software reset (swr) bit in the cr is cleared). changing the cr while the timer is running may produce unpredictable results. 8.3.1 input capture/output compare this mode has the capability of capturing a counter value by holding the value in the counter register (cntr). additionally, this mode can provide compare information via toutx to indicate when the counter has reached the compare value. this mode can be used for square-wave generation, pulse-width modulation, or periodic interrupt generation. this mode can be selected by programming the operation mode bits (modex) in the cr to 000. the timer is enabled when the counter prescaler enable (cpe) and swrx bits in the cr are set. once enabled, the counter enable (on) bit in the sr is set, and the next falling edge of the counter clock causes the counter to be loaded with the value in the preload 1 register (prel1). the tgate ? signal functions differently in this mode than it does in the other modes. tgate ? does not enable or disable the counter/prescaler input clock; instead, it is used to disable shadowing. normally, the counter is decremented on the falling edge of the counter clock, and the cntr is updated on the next rising edge of the system clock; thus, the cntr shadows the actual value of the counter. the timer gate interrupt (tg) bit in the sr must be cleared for shadowing to occur. tgate ? is used to set the tg bit and disable shadowing. if the timing gate is enabled (tge bit of the cr is set), the tg bit is set by the rising edge of tgate ? . shadowing is disabled until the tg bit is cleared by writing a one f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 8- 7 to its location in the sr. see figure 8-4 for a depiction of this mode. if the timing gate is disabled (cr tge bit is cleared), tgate ? has no effect on the operation of the timer; thus the input capture function is inoperative. at all times, the tgate ? level bit (tgl) in the sr reflects the level of the tgate ? signal. counter cloc k counter counter registe r tgate tout modex bits in control register = 000 preload 1 register = 8 compare register = 7 tge bit of status register = 1 tg bit in status register initially = 0 ocx bits in control register = 10 0 0 8 7 6 5 4 3 2 1 0 7 7 8 8 0 1 2 3 4 5 6 7 8 0 0 0 8 7 6 6 6 6 2 1 0 8 8 8 0 1 2 3 6 6 6 7 8 0 0 tg set tg cleared tg set timeout tc set tc set enable figure 8-4. input capture/output compare mode since the counter is not affected by tgate ? , it continues to decrement on the falling edge of the counter clock and load from the prel1 at timeout, regardless of the value of tgate ? . when the counter counts down to the value contained in the com, this condition is reflected by setting the timer compare (tc) and compare (com) bits in the sr. toutx responds as selected by the ocx bits in the cr. the output level (out) bit in the sr reflects the value on toutx. shadowing does not affect this operation. if the counter counts down to $0000, a timeout is detected, causing the sr timeout interrupt (to) bit to be set and the sr com bit to be cleared. on the next falling edge of the counter clock after the timeout is detected, the value in prel1 is again loaded into the counter. toutx responds as selected by the cr ocx bits. a square-wave generator can be implemented by programming the cr ocx bits to toggle mode. the value in the com should be one-half the value in prel1 to cause an event to happen twice in the countdown. this mode can be used as a pulse-width modulator by programming the cr ocx bits to zero mode or one mode. the value in the prel1 specifies the frequency, and the com determines the pulse width. the pulse widths can be changed by writing a new value to the com. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 8- 8 mc68340 user? manual motorola periodic interrupt generation can be accomplished by enabling the to, tg, and/or tc bits in the sr to generate interrupts by programming the ie bits of the cr. when enabled, the programmed irq ? signal is asserted whenever the specified bits are set. toutx signal transitions can be controlled by writing new values into the com. caution must be exercised when accessing the com. if it were to be accessed simultaneously by the compare logic and by a write, the old compare value may actually get compared to the counter value. 8.3.2 square-wave generator this mode can be used for generating both square-wave output and periodic interrupts. the square wave is generated by counting down from the value in the prel1 to timeout (counter value of $0000). toutx changes state on each timeout as programmed. this mode can be selected by programming the cr modex bits to 001. the timer is enabled by setting the swr and cpe bits in the cr and, if tgate ? is programmed to control the enabling and disabling of the counter (tge bit set in the cr), then asserting tgate ? . when the timer is enabled, the on bit in the sr is set. on the next falling edge of the counter clock, the counter is loaded with the value stored in the prel1 (n). with each successive falling edge of the counter clock, the counter decrements. the time between enabling the timer and the first timeout can range from n to n + 1 periods. when tgate ? is used to enable the timer, the enabling of the timer is asynchronous; however, if timing is carefully considered, the time to the first timeout can be known. for additional details on timing, see section 11 electrical characteristics . toutx behaves as a square wave when the ocx bits of the cr are programmed for toggle mode. a timeout occurs every n + 1 periods (allowing for the zero cycle), resulting in a change of state on toutx (see figure 8-5). the sr out bit reflects the level of toutx. if this mode is used to generate periodic interrupts, toutx may be enabled if a square wave is also desired. counter cloc k 0 0 3 2 1 0 3 2 1 0 3 2 1 0 counter tout n: n + 1 n + 1 n + 1 enable timeout timeout timeout modex bits in control register = 001 preload 1 register = n = 3 ocx bits in control register = 01 3 figure 8-5. square-wave generator mode if tgate ? is negated when it is enabled to control the timer (tge = 1), the prescaler and counter are disabled. additionally, the sr tg bit is set, indicating that tgate ? was negated. the sr on bit is cleared, indicating that the timer is disabled. if tgate ? is f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 8- 9 reasserted, the timer is re-enabled and begins counting from the value attained when tgate ? was negated. the sr on bit is set again. if tgate ? is disabled (tge = 0), tgate ? has no effect on the operation of the timer. in this case, the counter begins counting on the falling edge of the counter clock immediately after the swr and cpe bits in the cr are set. the tg bit of the sr cannot be set. at all times, tgl in the sr reflects the level of tgate ? . if the counter counts down to the value stored in the com register, then the com and tc bits in the sr are set. the counter continues counting down to timeout. at this time, the sr to bit is set, and the sr com bit is cleared. the next falling edge of the counter clock after timeout causes the value in prel1 to be loaded back into the counter, and the counter begins counting down from this value. the period of the square-wave generator can be changed dynamically by writing a new value into the prel1. caution must be used because, if prel1 is accessed simultaneously by the counting logic and a cpu32 write, the old prel1 value may actually get loaded into the counter at timeout. periodic interrupt generation can be accomplished by enabling the to, tg, and/or tc bits in the sr to generate interrupts by programming the cr ie bits. when enabled, the programmed irq ? signal is asserted whenever the specified bits are set. 8.3.3 variable duty-cycle square-wave generator in this mode, both the prel1 and prel2 registers are used to generate a square wave with virtually any duty cycle. the square wave is generated by counting down from the value in the prel1 to timeout (count value $0000), then loading that value from prel2 and again counting down to timeout. when this second timeout occurs, the value from prel1 is loaded into the counter, and the cycle repeats. toutx can be programmed to change state with every timeout, thus generating a variable duty-cycle square wave. this mode can be selected by programming the mode bits in the cr to 010. the timer is enabled by setting both the swr and cpe bits in the cr and, if tgate ? is enabled (cr tge bit is set), then asserting tgate ? . when the timer is enabled, the on bit in the sr is set. on the next falling edge of the counter clock, the counter is loaded with the value stored in the prel1 register (n1). with each successive falling edge of the counter clock, the counter decrements. the time between enabling the timer and the first timeout can range from n1 to n1+1 periods. when tgate ? is used to enable the timer, the enabling of the timer is asynchronous; however, if timing is carefully considered, the time to the first timeout can be known. for additional details on timing, see the section 11 electrical characteristics . if the counter counts down to the value stored in the com register, the com and timer compare interrupt (tc) bits in the sr are set. the counter continues counting down to timeout. at this time, the to bit in the sr is set, and the com bit is cleared. the next falling edge of the counter clock after timeout causes the value in prel2 (n2) to be loaded into the counter, and the counter begins counting down from this value. each f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 8- 10 mc68340 user? manual motorola successive timeout causes the counter to be loaded alternately with the values from prel1 and prel2. toutx behaves as a variable duty-cycle square wave when the cr oc bits are programmed for toggle mode. the second timeout occurs after n2 + 1 periods (allowing for the zero cycle), resulting in a change of state on toutx. the third timeout occurs after n1 + 1 periods, resulting in a change of state on toutx, and so on (see figure 8-6). the out bit in the sr reflects the level of toutx. counter cloc k 0 0 4 3 2 1 0 2 1 0 4 3 2 1 counter tout n1: n1 + 1 n2 + 1 n1 + 1 enable timeout timeout timeout modex bits in control register = 010 preload 1 register = n1 = 4 preload 2 register = n2 = 2 ocx bits in control register = 01 0 2 1 0 timeout n2 + 1 figure 8-6. variable duty-cycle square-wave generator mode if tgate ? is negated when it is enabled (tge = 1), the prescaler and counter are disabled. additionally, the tg bit of the sr is set, indicating that tgate ? was negated. the on bit of the sr is cleared, indicating that the timer is disabled. if tgate ? is reasserted, the timer is re-enabled and begins counting from the value attained when tgate ? was negated. the on bit is set again. if tgate ? is not enabled (tge = 0), tgate ? has no effect on the operation of the timer. in this case, the counter would begin counting on the falling edge of the counter clock immediately after the swr and cpe bits in the cr are set. the sr tg bit cannot be set. at all times, the tgl bit in the sr reflects the level of tgate ? . the duty cycle of the waveform generated on toutx can be dynamically changed by writing new values into prel1 and/or prel2. if prel1 or prel2 is being accessed simultaneously by the counter logic and a cpu32 write, the old preload value may actually get loaded into the counter at timeout. if at timeout, the counting logic was accessing prel2 and the cpu32 was writing to prel1 (or visa versa), there would be no unexpected results. 8.3.4 variable-width single-shot pulse generator this mode is used to produce a one-time pulse that has a delay controlled by the value stored in prel1 and a duration controlled by the value stored in prel2. with toutx programmed to change state, this sequence creates a single pulse of variable width. this mode can be selected by programming the cr mode bits to 011. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 8- 11 the timer is enabled by setting both the swr and cpe bits in the cr and, if tgate ? is enabled (tge bit in the cr is set), then asserting tgate ? . when the timer is enabled, the on bit in the sr is set. on the next falling edge of the counter clock, the counter is loaded with the value stored in the prel1 register (n1). with each successive falling edge of the counter clock, the counter decrements. the time between enabling the timer and the first timeout can range from n1 to n1 + 1 periods. when tgate ? is used to enable the counter, the enabling of the timer is asynchronous; however, if timing is carefully considered, the time to the first timeout can be known. for additional details on timing, see section 11 electrical characteristics . if the counter counts down to the value stored in the com, the com and tc bits in the sr are set. the counter continues counting down to timeout. at this time, the sr to bit is set and the sr com bit is cleared. the next falling edge of the counter clock after timeout causes the value in prel2 (n2) to be loaded into the counter, and the counter begins counting down from this value. after the second timeout, the selected clock is held high, disabling the prescaler and counter. additionally, the sr on and com bits are cleared. toutx behaves as a variable-width pulse when the ocx bits of the cr are programmed for toggle mode. toutx is a logic zero between the time that the timer is enabled and the first timeout. when this event occurs, toutx transitions to a logic one. the second timeout occurs after n2 + 1 periods (allowing for the zero cycle), resulting in toutx returning to a logic zero (see figure 8-7). the out bit in the sr reflects the level of toutx. counter cloc k counter tout 0 0 2 1 0 5 4 3 2 1 0 n1: n1 + 1 n2 + 1 enable timeout timeout modex bits in control register = 011 preload 1 register = n1 = 2 preload 2 register = n2 = 5 ocx bits in control register = 01 figure 8-7. variable-width single-shot pulse generator mode if tgate ? is negated when it is enabled (tge = 1), the prescaler and counter are disabled. additionally, the sr tg bit is set, indicating that tgate ? was negated. the sr on bit is cleared, indicating that the timer is disabled. if tgate ? is reasserted, the timer is re-enabled and begins counting from the value attained when tgate ? was negated. the on bit is set again. if tgate ? is not enabled (tge = 0), tgate ? has no effect on the operation of the timer. in this case, the counter would begin counting on the falling edge of the counter clock f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 8- 12 mc68340 user? manual motorola immediately after the swr and cpe bits in the cr are set. the sr tg bit cannot be set. at all times, the tgl bit in the sr reflects the level of tgate ? . the width of the pulse generated on toutx (the value in prel2) can be changed while the counter is counting down from the value in prel1. caution must be used because, if prel2 is accessed simultaneously by the counting logic and a cpu32 write, the old prel2 value may actually get loaded into the counter at timeout. 8.3.5 pulse-width measurement this mode is used to count the clock cycles during a particular event (see figure 8-8). the event is defined by the assertion and negation of tgate ? . when tgate ? is asserted, the counter begins counting down from $ffff. when tgate ? is negated, the counter stops counting and holds the value at which it stopped. further assertions and negations of tgate ? have no effect on the counter. this mode can be selected by programming the cr modex bits to 100. the timer is enabled by setting the swr, cpe, and tge bits in the cr. asserting tgate ? starts the counter. when the timer is enabled, the sr on bit is set. on the next falling edge of the counter clock, the counter is loaded with the value $ffff. with each successive falling edge of the counter clock, the counter decrements. the prel1 and prel2 registers are not used in this mode. when tgate ? is negated, the sr tg bit is set, the on bit is negated, and the prescaler and counter are disabled. subsequent transitions on tgate ? do not re-enable the counter. the tgl bit in the sr reflects the level of tgate ? at all times. counter cloc k tgate 0 f f f f f f f f f f f f f e d c measured pulse f f f b f f f b start c ounting enable stop c ounting no effect modex bits in control register = 100 tge bit of control register = 1 counter figure 8-8. pulse-width measurement mode if the counter counts down to the value stored in the com register, the com and tc bits in the sr are set. if the counter counts down to $0000, a timeout is detected. this sets the sr to, and the clears the com bit. at timeout, the next falling edge of the counter clock f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 8- 13 causes the counter to reload with $ffff. toutx transitions at timeout or is disabled as programmed by the cr ocx bits. the sr out bit reflects the level on toutx. to determine the number of cycles counted, the value in the cntr must be read, inverted, and incremented by 1 (the first count is $ffff which, in effect, includes a count of zero). the counter counts in a true 2 16 fashion. for measuring pulses of even greater duration, the value in the pox bits in the sr is readable and can be thought of as an extension of the least significant bits in the cntr. note once the timer has been enabled, do not clear the sr tg bit until the pulse has been measured and tgate ? has been negated. 8.3.6 period measurement this mode is used to count the period of a particular event. the event is defined by the assertion, negation, and subsequent reassertion of tgate ? . when tgate ? is asserted, the counter begins counting down from $ffff. the negation of tgate ? has no effect on the counter. when tgate ? is reasserted, the counter stops counting and holds the value at which it stopped. further assertions and negations of tgate ? have no effect on the counter. this mode can be selected by programming the cr modex bits to 101. the timer is enabled by setting the swr, cpe, and the tge bits in the cr. the assertion of tgate ? starts the counter. when the timer is enabled, the sr on bit is set. on the next falling edge of the counter clock, the counter is loaded with the value of $ffff. with each successive falling edge of the counter clock, the counter decrements. the prel1 and prel2 registers are not used in this mode. the first negation of tgate ? is ignored, but on the second assertion of tgate ? , the sr tg bit is set, the sr on bit is negated, and the prescaler and counter are disabled. subsequent transitions on tgate ? do not re-enable the counter. see figure 8-9 for a depiction of this mode. the sr tgl bit reflects the level of tgate ? at all times. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 8- 14 mc68340 user? manual motorola f f f 9 start c ounting enable stop c ounting no effect modex bits in control register = 101 tge bit of control register = 1 tgate counter cloc k 0 f f f f f f f f f f f f f e d c f f f b counter f f f a f f f 9 period measured figure 8-9. period measurement mode if the counter counts down to the value stored in the com register, the com and tc bits in the sr are set. if the counter counts down to $0000, a timeout is detected. this sets the sr to bit, and clears the sr com bit. at timeout, the next falling edge of the counter clock reloads the counter with $ffff. toutx transitions at timeout or is disabled as programmed by the ocx bits of the cr, and the out bit in the sr reflects the level on toutx. to determine the number of cycles counted, the value in the cntr must be read, inverted, and incremented by 1 (the first count is $ffff which, in effect, includes a count of zero). the counter counts in a true 2 16 fashion. for measuring pulses of even greater duration, the value in the pox bits in the sr are readable and can be thought of as an extension of the least significant bits in the cntr. note once the timer has been enabled, do not clear the sr tg bit until the pulse has been measured and tgate ? has been negated. 8.3.7 event count this mode is used to count events by interpreting the falling edges of the counter clock as events (see figure 8-10). these events may be external or internal to the chip?or example, counting the number of system clock cycles required to execute a sequence of instructions. as another example, by connecting as to tinx, the number of bus cycles to complete a sequence of instructions could be counted. this mode can be selected by programming the cr modex bits to 110. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 8- 15 counter cloc k tgate 0 f f f f f f f f f f f f f f f f e d c b 0 0 0 0 0 f f 0 0 0 0 0 f f 0 0 0 0 0 f f 2 1 1 1 0 f e counter tg bit set timeout t o bit se t enable modex bits in control register = 110 tge bit of the control register = 1 0 0 0 1 figure 8-10. event count mode the timer is enabled by setting the swr and cpe bits in the cr and, if tgate ? is enabled (tge bit of the cr is set), then asserting tgate ? . when the timer is enabled, the sr on bit is set. on the next falling edge of the counter clock, the counter is loaded with the value of $ffff. with each successive falling edge of the counter clock, the counter decrements. the prel1 and prel2 registers are not used in this mode. if tgate ? is not enabled (cr tge bit is cleared), then tgate ? does not start or stop the timer or affect the tg bit of the sr. in this case, the counter would begin counting on the falling edge of the counter clock immediately after the swr and cpe bits in the cr are set. if tgate ? is enabled (cr tge bit is set), then the assertion of tgate ? starts the counter. the negation of tgate ? disables the counter, sets the sr tg bit, and clears the on bit in the sr. if tgate ? is reasserted, the timer resumes counting from where it was stopped, and the on bit is set again. further assertions and negations of tgate ? have the same effect. the tgl bit in the sr reflects the level of tgate ? at all times. if the counter counts down to the value stored in the com register, the com and tc bits in the sr are set. if the counter counts down to $0000, a timeout is detected. this event sets the to in the sr and clears the com bit. at timeout, the next falling edge of the counter clock reloads the counter with $ffff. toutx transitions at timeout or is disabled as programmed by the cr oc bits. the sr out bit reflects the level on toutx. to determine the number of cycles counted, the value in the cntr must be read, inverted, and incremented by 1 (the first count is $ffff which, in effect, includes a count of zero). the counter counts in a true 2 16 fashion. for measuring pulses of even greater duration, the value in the pox bits in the sr are readable and can be thought of as an extension of the least significant bits in the cntr. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 8- 16 mc68340 user? manual motorola 8.3.8 timer bypass in this mode, the counter and prescaler cannot be enabled. however tgate ? and toutx can be used for i/o. this mode can be selected by programming the cr mode bits to 111. tgate ? can be used as a simple input port when the cr is configured as follows: cr 1514131211109876543210 swr ie2 ie1 ie0 tge pclk cpe clk pot2 pot1 pot0 mode2 mode1 mode0 oc1 oc0 tgate ? as a simple input xx0 xxx1 xxxx 111xx x-don? care when tgate ? is asserted, the sr on bit is set. when tgate ? is negated, the on bit is cleared. the value of the tgl bit in the sr reflects the level of tgate ? . tgate ? can also be used as an input port that generates interrupts on a low-to-high transition of tgate ? when the cr is configured as follows: cr 1514131211109876543210 swr ie2 ie1 ie0 tge pclk cpe clk pot2 pot1 pot0 mode2 mode1 mode0 oc1 oc0 tgate ? as an input/interrupt xx1 x1 x1 xxxx 111xx when tgate ? is negated, the sr tg bit is set, and the programmed irqx signal is asserted to the cpu32. the tg bit can only be cleared by writing a one to this bit position. the value of the sr tgl bit reflects the level of tgate ? . additionally, toutx can be used as a simple output port when the cr is configured as follows: cr 1514131211109876543210 swr ie2 ie1 ie0 tge pclk cpe clk pot2 pot1 pot0 mode2 mode1 mode0 oc1 oc0 tgate ? as a simple output 0 xxxxx1 xxxx1 1 1oc1oc0 swr must be a zero to change the value of toutx. changing the value of the cr ocx bits determines the level of toutx as shown in table 8-1. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 8- 17 table 8-1. ocx encoding oc1 oc0 toutx 0 0 hi-z 01 0 10 0 11 1 a read of the sr while in this mode always shows the to, tc, and com bits cleared, and the po bits as $ff. the sr out bit always indicates the level on the toutx pin. 8.3.9 bus operation the following paragraphs describe the operation of the imb during read, write, and interrupt acknowledge cycles to the timer. 8.3.9.1 read cycles. the timer is accessed with no wait states. the timer responds to byte, word, and long-word reads, and 16 bits of valid data are returned. read cycles from reserved registers return logic zero. 8.3.9.2 write cycles. the timer is accessed with no wait states. the timer responds to byte, word, and long-word writes. write cycles to read-only registers and bits as well as reserved registers complete in a normal manner without exception processing; however, the data is ignored. 8.3.9.3 interrupt acknowledge cycles. the timer is capable of arbitrating for interrupt servicing and supplying the interrupt vector when it has successfully won arbitration. the vector number must be provided if interrupt servicing is necessary; thus, the interrupt register (ir) must be initialized. if the ir is not initialized, a spurious interrupt exception will be taken if interrupt servicing is necessary. 8.4 register description the following paragraphs contain a detailed description of each register and its specific function. the operation of the timer is controlled by writing control words into the appropriate registers. timer registers and their associated addresses are listed in figure 8-11. for more information about a particular register, refer to the individual register description. the addr column indicates the offset of the register from the base address of the timer. an fc column designation of s indicates that register access is restricted to supervisor only. a designation of s/u indicates that access is governed by the supv bit in the module configuration register (mcr). f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 8- 18 mc68340 user? manual motorola timer 1 timer 2 fc 15 0 $600 $640 s module configuration register (mcr) $602 $642 s reserved $604 $644 s interrupt register (ir) $606 $646 s/u control register (cr) $608 $648 s/u status/prescaler register (sr) $60a $64a s/u counter register (cntr) $60c $64c s/u preload 1 register (prel1) $60e $64e s/u preload 2 register (prel2) $610 $650 s/u compare register (com) $612-$63f $652-$67f s/u reserved figure 8-11. timer module programming model in the registers discussed in the following paragraphs, the numbers in the upper right- hand corner indicate the offset of the register from the base address specified by the module base address register (mbar) in the sim40. the first number is the offset for timer 1; the second number is the offset for timer 2. the numbers on the top line of the register represent the bit position in the register. the register contains the mnemonic for the bit. the value of these bits after a hardware reset is shown below the register. the access privilege is shown in the lower right-hand corner. note a cpu32 reset instruction will not affect the mcr, but will reset all other registers in the timer modules as though a hardware reset occurred. the term 'timer' is used to reference either timer 1 or timer 2, since the two are functionally equivalent. 8.4.1 module configuration register (mcr) the mcr controls the timer module configuration. this register can be either read or written when the module is enabled and is in the supervisor state. the mcr is not affected by a cpu32 reset instruction. mcr $600, $640 1514131211109876543210 stp frz1 frz0 00000 supv 0 0 0 iarb3 iarb2 iarb1 iarb0 reset: 0000000010000000 supervisor only f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 8- 19 stp?top bit 1 = setting the stp bit stops all clocks within the timer module except for the clock from the imb. the clock from the imb remains active to allow the cpu32 access to the mcr. the clock stops on the low phase of the clock and remains stopped until the stp bit is cleared by the cpu32 or a hardware reset. accesses to timer module registers while in stop mode produce a bus error. the timer module should be disabled in a known state prior to setting the stp bit; otherwise, unpredictable results may occur. the stp bit should be set prior to executing the lpstop instruction to reduce overall power consumption. 0 = the timer operates in normal mode. frz1, frz0?reeze these bits determine the action taken when the freeze signal is asserted on the imb, when the cpu32 has entered background debug mode. table 8-2 lists the action taken for each bit combination. table 8-2. frzx control bits frz1 frz0 action 0 0 ignore freeze 0 1 reserved (freeze ignored) 1 0 execution freeze 1 1 execution freeze bits 12?, 6??eserved supv?upervisor/user the value of this bit has no effect on registers permanently defined as supervisor-only access. 1 = the timer registers defined as supervisor/user reside in supervisor data space and are only accessible from supervisor programs. 0 = the timer registers defined as supervisor/user reside in user data space and are accessible from either supervisor or user programs. iarb3?arb0?nterrupt arbitration bits each module that generates interrupts has an iarb field. these bits are used to arbitrate for the bus in the case that two or more modules simultaneously generate an interrupt at the same priority level. no two modules can share the same iarb value. (timer 1 and timer 2 should be programmed with different values if both are used.) the reset value of the iarb field is $0, which prevents this module from arbitrating during the interrupt acknowledge cycle. the system software should initialize the iarb field to a value from $f (highest priority) to $1 (lowest priority). f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 8- 20 mc68340 user? manual motorola 8.4.2 interrupt register (ir) the ir contains the priority level for the timer interrupt request and the 8-bit vector number of the interrupt. the register can be read or written to at any time while in supervisor mode and while the timer module is enabled (i.e., the stp bit in the mcr is cleared). ir $604, $644 1514131211109876543210 00000il2il1il0 ivr7 ivr6 ivr5 ivr4 ivr3 ivr2 ivr1 ivr0 reset: 0000000000001111 supervisor only bits 15?1?eserved il2?l0?nterrupt level bits each module that can generate interrupts has an interrupt level field. the priority level encoded in these bits is sent to the cpu32 on the appropriate irq ? signal. the cpu32 uses this value to determine servicing priority. see section 5 cpu32 for more information. iv7?v0?nterrupt vector bits each module that can generate interrupts has an interrupt vector (iv) field. this 8-bit number indicates the offset from the base of the vector table where the address of the exception handler for the specified interrupt is located. the iv field is reset to $0f, which indicates an uninitialized interrupt condition. see section 5 cpu32 for more information. 8.4.3 control register (cr) the cr controls the operation of the timer. the register can always be read or written when the timer module is enabled (i.e., the stp bit in the mcr is cleared). changing the contents of the cr should only be attempted when the timer is disabled (the swr bit in the cr is cleared). changing the cr while the timer is running may produce unpredictable results. cr $606, $646 1514131211109876543210 swr ie2 ie1 ie0 tge pclk cpe clk pot2 pot1 pot0 mode2 mode1 mode0 oc1 oc0 reset: 0000000000000000 supervisor/user swr?oftware reset 1 = removes the software reset. 0 = a software reset is performed by first clearing this bit and then clearing the to, tg, and tc bits in the sr. the prescaler is loaded with $ff, the counter is set to $0000, and the sr com bit is cleared. when this bit is zero, the timer is disabled. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 8- 21 ie2?e0?nterrupt enable these bits determine which sources of interrupts, to, tg, and tc, are enabled to generate an interrupt request to the cpu32. table 8-3 lists which interrupts are enabled for all bit combinations. table 8-3. iex encoding ie2 ie1 ie0 enabled interrupts 0 0 0 polling mode (no interrupts enabled) 0 0 1 tc enabled 0 1 0 tg enabled 0 1 1 tg and tc enabled 1 0 0 to enabled 1 0 1 to and tc enabled 1 1 0 to and tg enabled 1 1 1 to, tg, and tc enabled tge?iming gate enable 1 = the tgate ? signal is enabled to control the enabling and disabling of the prescaler and counter, except in the input capture/output compare mode (see 8.3.1 input capture/output compare ). 0 = the tgate ? signal has no effect on the timer operation. pclk?rescaler clock select this bit selects which clock is used for the counter clock. 1 = the counter is decremented by the prescaler output tap as selected by the pot field in the cr. 0 = the counter is decremented by the selected clock. the prescaler continues to decrement regardless of how pclk is set. cpe?ounter prescaler enable 1 = the selected clock is enabled. if the tge bit is set, then tgate ? must also be asserted (except in the input capture/output compare mode). 0 = the selected clock is held high, halting the prescaler and counter. clk?lock 1 = the selected clock is taken from the tinx input. 0 = the selected clock is one-half the system clock's frequency. the toutx of one timer can be fed externally into the tinx input of the other timer, resulting in a 32-bit counter if the prescalers are not used and a 48-bit counter if they are used. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 8- 22 mc68340 user? manual motorola pot2?ot0?rescaler output tap if pclk is set, these bits encode which of the prescaler's output taps act as the counter clock. a division of the selected clock is applied to the counter as listed in table 8-4. table 8-4. pot encoding pot2 pot1 pot0 division of selected clock 0 0 1 divide by 2 0 1 0 divide by 4 0 1 1 divide by 8 1 0 0 divide by 16 1 0 1 divide by 32 1 1 0 divide by 64 1 1 1 divide by 128 0 0 0 divide by 256 mode2?ode0?peration mode these bits select one of the eight modes of operation for the timer as listed in table 8-5. refer to 8.3 operating modes for more information on the individual modes. table 8-5. modex encoding mode2 mode1 mode0 operation mode 0 0 0 input capture/output compare 0 0 1 square-wave generator 0 1 0 variable duty-cycle square-wave generator 0 1 1 variable-width single-shot pulse generator 1 0 0 pulse-width measurement 1 0 1 period measurement 1 1 0 event count 1 1 1 timer bypass (simple test mode) oc1?c0?utput control these bits select the conditions under which toutx changes (see table 8-6). these bits may have a different effect when in the input capture/output compare mode. caution should be used when modifying the oc bits near timer events. table 8-6. ocx encoding oc1 oc0 toutx mode 0 0 disabled 0 1 toggle mode 1 0 zero mode 1 1 one mode f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 8- 23 disabled?outx is disabled and three-stated. toggle mode?f the timer is disabled (swr = 0) when this encoding is programmed, toutx is immediately set to zero. if the timer is enabled (swr = 1), timeout events (counter reaches $0000) toggle toutx. in the input capture/output compare mode, toutx is immediately set to zero if the timer is disabled (swr = 0). if the timer is enabled (swr = 1), timer compare events toggle toutx. (timer compare events occur when the counter reaches the value stored in the com.) zero mode?f the timer is disabled (swr = 0) when this encoding is programmed, toutx is immediately set to zero. if the timer is enabled (swr = 1), toutx will be set to zero at the next timeout. in the input capture/output compare mode, toutx is immediately set to zero if the timer is disabled (swr = 0). if the timer is enabled (swr = 1), toutx will be set to zero at timeouts and set to one at timer compare events. if the com is $0000, toutx will be set to zero at the timeout/timer compare event. one mode?f the timer is disabled (swr = 0) when this encoding is programmed, toutx is immediately set to one. if the timer is enabled (swr = 1), toutx will be set to one at the next timeout. in the input capture/output compare mode, toutx is immediately set to one if the timer is disabled (swr = 0). if the timer is enabled (swr = 1), toutx will be set to one at timeouts and set to zero at timer compare events. if the com is $0000, toutx will be set to one at the timeout/timer compare event. 8.4.4 status register (sr) the sr contains timer status information as well as the state of the prescaler. this register is updated on the rising edge of the system clock when a read of its location is not in progress, allowing the most current information to be contained in this register. the register can be read, and the to, tg, and tc bits can be written when the timer module is enabled (i.e., the stp bit in the mcr is cleared). sr $608, $648 1514131211109876543210 irq to tg tc tgl on out com po7 po6 po5 po4 po3 po2 po1 po0 reset ( tgate ? negated): 0000100011111111 reset ( tgate ? asserted): 0000000011111111 supervisor/user irq?nterrupt request bit the positioning of this bit in the most significant location in this register allows it it be conditionally tested as if it were a signed binary integer. 1 = an interrupt condition has occurred. this bit is the logical or of the enabled to, tg, and tc interrupt bits. 0 = the bit(s) that caused the interrupt condition has been cleared. if an irq ? signal has been asserted, it is negated when this bit is cleared. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 8- 24 mc68340 user? manual motorola to?imeout interrupt 1 = the counter has transitioned from $0001 to $0000, and the counter has rolled over. this bit does not affect the programmed irq ? signal if the ie2 bit in the cr is cleared. 0 = this bit is cleared by the timer whenever the reset signal is asserted on the imb, regardless of the mode of operation. this bit may also be cleared by writing a one to it. writing a zero to this bit does not alter its contents. this bit is not affected by disabling the timer (swr = 0). tg?imer gate interrupt 1 = this bit is set whenever the cr tge bit is set and the tgate ? signal transitions in the manner to which the particular mode of operation responds. refer to 8.3 operating modes for more details. this bit does not affect the programmed irq ? signal if the ie1 bit in the cr is cleared. 0 = this bit is cleared by the timer whenever the reset signal is asserted on the imb, regardless of the mode of operation. this bit may also be cleared by writing a one to it. writing a zero to this bit does not alter its contents. this bit is not affected by disabling the timer (swr = 0). tc?imer compare interrupt 1 = this bit is set when the counter transitions (off a clock/event falling edge) to the value in the com. this bit does not affect the programmed irq ? signal if the ie0 bit in the cr is cleared. 0 = this bit is cleared by the timer whenever the reset signal is asserted on the imb, regardless of the mode of operation. this bit may also be cleared by writing a one to it. writing a zero to this bit does not alter its contents. this bit is not affected by disabling the timer (swr = 0). tgl tgate ? level 1 = the tgate ? signal is negated. 0 = the tgate ? signal is asserted. on?ounter enabled 1 = this bit is set whenever the swr and cpe bits are set in the cr. if the cr tge bit is set, tgate ? must also be asserted (except in the input capture/output compare mode) since this signal then controls the enabling and disabling of the counter. if all these conditions are met, the counter is enabled and begins counting down. 0 = the counter is not enabled and does not begin counting down. out?utput level 1 = toutx is a logic one. 0 = toutx is a logic zero, or the pin is three-stated. com?ompare bit this bit is used to indicate when the counter output value is at or between the value in the com and $0000 (timeout). f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 8- 25 1 = this bit is set when the counter output equals the value in the com. 0 = this bit is cleared when a timeout occurs, the com register is accessed (read or write), the timer is reset with the swr bit, or the reset signal is asserted on the imb. this bit is cleared regardless of the state of the tc bit. this bit can be used to indicate when a write to the prel1 or prel2 registers will not cause a problem during a counter reload at timeout. to ensure that the write to the prel register is recognized at timeout, the latency between the read of the com bit and the write to the prel register must be considered. po7?o0?rescaler output these bits show the levels on each of the eight output taps of the prescaler. these values are updated every time that the system clock goes high and a read cycle of this byte in the sr is not in progress. 8.4.5 counter register (cntr) the cntr reflects the value of the counter. this value can be reliably read at any time since it is updated on every rising edge of the system clock (except in the input capture/output compare mode) when a read of the register is not in progress. this read- only register can be read when the timer module is enabled (i.e. the stp bit in the mcr is cleared). cntr $60a, $64a 1514131211109876543210 cnt15 cnt14 cnt13 cnt12 cnt11 cnt10 cnt9 cnt8 cnt7 cnt6 cnt5 cnt4 cnt3 cnt2 cnt1 cnt0 reset: 0000000000000000 supervisor/user all 24 bits of the prescaler and the counter may be obtained by one long-word read at the address of the sr, since the cntr is contiguous to it. any changes in the prescaler value due to the two cycles necessary to perform a long-word read should be considered. if this latency presents a problem, the tgate ? signal may be used to disable the decrement function while the reads are occurring. 8.4.6 preload 1 register (prel1) the prel1 stores a value that is loaded into the counter in some modes of operation. this value is loaded into the counter on the first falling edge of the counter clock after the counter is enabled. this register can be be read and written when the timer module is enabled (i.e. the stp bit in the mcr is cleared). however, a write to this register must be completed before timeout for the new value to be reliably loaded into the counter. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 8- 26 mc68340 user? manual motorola prel1 $60c, $64c 1514131211109876543210 pr1-15 pr1-14 pr1-13 pr1-12 pr1-11 pr1-10 pr1-9 pr1-8 pr1-7 pr1-6 pr1-5 pr1-4 pr1-3 pr1-2 pr1-1 pr1-0 reset: 1111111111111111 supervisor/user for some modes of operation, this register is also used to reload the counter one falling clock edge after a timeout occurs. refer to 8.3 operating modes for more information on the individual modes. 8.4.7 preload 2 register (prel2) prel2 is used in addition to prel1 in the variable duty-cycle square-wave generator and variable-width single-shot pulse generator modes. when in either of these modes, the value in prel1 is loaded into the counter on the first falling edge of the counter clock after the counter is enabled. after timeout, the value in prel2 is loaded into the counter. this register can be be read and written when the timer module is enabled (i.e., the stp bit in the mcr is cleared). however, a write to this register must be completed before timeout for the new value to be reliably loaded into the counter. prel2 $60e, $64e 1514131211109876543210 pr2-15 pr2-14 pr2-13 pr2-12 pr2-11 pr2-10 pr2-9 pr2-8 pr2-7 pr2-6 pr2-5 pr2-4 pr2-3 pr2-2 pr2-1 pr2-0 reset: 1111111111111111 supervisor/user 8.4.8 compare register (com) the com can be used in any mode. when the 16-bit counter reaches the value in the com, the tc and com bits in the sr are set. in the input capture/output compare mode, a compare event can be programmed to set, clear, or toggle toutx. the register can be be read and written when the timer module is enabled (i.e., the stp bit in the mcr is cleared). com $610, $650 1514131211109876543210 com15 com14 com13 com12 com11 com10 com9 com8 com7 com6 com5 com4 com3 com2 com1 com0 reset: 0000000000000000 supervisor/user the com can be used to produce an interrupt when the sr tc bit has been enabled to produce an interrupt and the counter counts down to a preselected value. the com can also be used to indicate that the timer is approaching timeout. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 8- 27 caution must be exercised when accessing the com. if it were to be accessed simultaneously by the compare logic and by a write, the old compare value may get compared to the counter value. 8.5 timer module initialization sequence the following paragraphs discuss a suggested method for initializing the timer module. since both timers are functionally equivalent, only one timer module will be referenced. 8.5.1 timer module configuration if the timer capability of the mc68340 is being used, the following steps should be followed to initialize a timer module properly. note that this sequence must be done for each timer module used. control register (cr) ?clear the swr bit to disable the timer. status register (sr) ?clear the to, tg, and tg bits to reset the interrupts. module configuration register (mcr) ?initialize the stp for normal operation. ?select whether to respond to or ignore freeze (frzx bits). ?select the access privilege for the supervisor/user registers (supv bit). ?select the interrupt arbitration level for the timer module (iarbx bits). interrupt register (ir) ?program the interrupt priority level for the timer interrupts (ilx bits). ?program the interrupt vector number for the timer interrupts (ivx bits). preload registers (prel1 and prel2) ?if required, initialize the preload registers for mode of operation. compare register (com) ?if desired, initialize the compare register. the following steps begin operation: control register (cr) ?set the swr bit to enable the timer. ?enable the desired interrupts (iex bits). ?enable tgate if required for mode of operation (tge bit). ?select the prescaler clock (pclk bit). f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 8- 28 mc68340 user? manual motorola ?enable the counter prescaler (cpe bit). ?select the selected clock (clk bit). ?if the pclk bit is set, select the potx bits. ?select the mode of operation (modex bits). ?select the operation of tout (ocx bits). 8.5.2 timer module example configuration code the following code is an example of a configuration sequence for the timer module. *************************************************************************** * mc68340 basic timer module register initialization example code. * this code is used to initialize the 68340's internal timer module * registers, providing basic functions for operation. * it sets up timer1 for square wave generation. *************************************************************************** *************************************************************************** * equates *************************************************************************** mbar equ $0003ff00 address of sim40 module base address reg. modbase equ $fffff000 sim40 mbar address value *************************************************************************** * timer1 module equates timer1 equ $600 offset from mbar for timer1 module regs mcr1 equ $0 mcr for timer1 * timer1 register offsets from timer1 base address ir1 equ $604 interrupt register timer1 cr1 equ $606 control register timer1 sr1 equ $608 status register timer1 cntr1 equ $60a counter register timer1 prld11 equ $60c preload register 1 timer1 com1 equ $610 compare regis ter timer1 *************************************************************************** *************************************************************************** * initialize timer1 *************************************************************************** lea modbase+timer1,a0 pointer to timer1 module * disable timer1 clr.w cr1(a0) * clear the to, tg, and tc bits clr.w sr1(a0) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 8- 29 * module configuration register: * timer1 module is set for normal operation, ignore freeze. * supervisor/user timer1 registers unrestricted. * interrupt arbitration at priority $03. move.w #$0003,mcr1(a0) * initialize timer1 interrupt level to 2 and vector to $0f move.w #$020f,ir1(a0) * initialize preload 1 to 3 move.w #$0003,prld11(a0) * initialize the compare register to 0 clr.w com1(a0) * control register 1: * enable timer1, no interrupts are enabled, tgate signal has no effect. * use the selected clock for the counter clock, and enable it. * selected clock is 1/2 system's freq. square-wave generation, toggle tout. move.w #$8205,cr1(a0) *************************************************************************** end *************************************************************************** *************************************************************************** * mc68340 basic timer module register initialization example code. * this code is used to initialize the 68340's internal timer module * registers, providing basic functions for operation. * it sets up timer1 for pulse-width measurement. in this mode, the number * of clock cycles during a particular event are counted. the event is * defined by the assertion and negation of tgate. *************************************************************************** *************************************************************************** * equates *************************************************************************** mbar equ $0003ff00 address of sim40 module base address reg. modbase equ $fffff000 sim40 mbar address value *************************************************************************** * timer1 module equates timer1 equ $600 offset from mbar for timer1 module regs mcr1 equ $0 mcr for timer1 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 8- 30 mc68340 user? manual motorola * timer1 register offsets from timer1 base address ir1 equ $604 interrupt register timer1 cr1 equ $606 control register timer1 sr1 equ $608 status register timer1 cntr1 equ $60a counter register timer1 com1 equ $610 compare regis ter timer1 *************************************************************************** *************************************************************************** * initialize timer1 *************************************************************************** lea modbase+timer1,a0 pointer to timer1 module * disable timer1 clr.w cr1(a0) * allow tgate to negate and assert so that an accurate count will result. * if sr1 tgl bit=1, continue looping. tgate is negated. loop1 btst.b #$3,sr1(a0) bne.b loop1 * if tgl bit=0, continue looping. tgate is asserted. loop2 btst.b #$3,sr1(a0) beq.b loop2 * ready to initialize timer1, tgate is negated. * module configuration register: * timer1 module is set for normal operation, ignore freeze. * supervisor/user timer1 registers unrestricted. * interrupt arbitration at priority $03. move.w #$0003,mcr1(a0) * initialize timer1 interrupt level to 2 and vector to $0f move.w #$020f,ir1(a0) * initialize the compare register to 0 clr.w com1(a0) * clear the sr1 tg bit (by writing a 1) to use as a flag move.b #$20,sr1(a0) * control register 1: * enable timer1, no interrupts are enabled, tgate signal used to control * the counter. use the selected clock for the counter clock, and enable it. * selected clock is 1/2 system's freq. pulse-width measurement, * disable tout. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 8- 31 move.w #$8a10,cr1(a0) * if sr tg bit=0, continue looping tgate is asserted, * else tg=1 indicating tgate was negated. when tg=1, counting is stopped. loop3 btst.b #$5,sr1(a0) beq.b loop3 * counting is complete. to determine the number of cycles counted, the value * in cntr1 must be read, inverted, and incremented by 1. move.w cntr1(a0),d0 not.w d0 addq.w #$1,do * d0 contains the number of cycles counted. *************************************************************************** end *************************************************************************** f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 9- 1 section 9 ieee 1149.1 test access port the mc68340 includes dedicated user-accessible test logic that is fully compatible with the ieee 1149.1 standard test access port and boundary scan architecture . problems associated with testing high-density circuit boards have led to development of this proposed standard under the sponsorship of the test technology committee of ieee and the joint test action group (jtag). the mc68340 implementation supports circuit-board test strategies based on this standard. the test logic includes a test access port (tap) consisting of four dedicated signal pins, a 16-state controller, an instruction register, and two test data registers. a boundary scan register links all device signal pins into a single shift register. the test logic, implemented using static logic design, is independent of the device system logic. the mc68340 implementation provides the following capabilities: a. perform boundary scan operations to test circuit-board electrical continuity b. sample the mc68340 system pins during operation and transparently shift out the result in the boundary scan register c. bypass the mc68340 for a given circuit-board test by effectively reducing the boundary scan register to a single bit d. disable the output drive to pins during circuit-board testing note certain precautions must be observed to ensure that the ieee 1149.1 test logic does not interfere with nontest operation. see 9.6 non-ieee 1149.1 operation for details. 9.1 overview note this description is not intended to be used without the supporting ieee 1149.1 document. the discussion includes those items required by the standard and provides additional information specific to the mc68340 implementation. for internal details and applications of the standard, refer to the ieee 1149.1 document. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 9- 2 mc68340 user? manual motorola an overview of the mc68340 implementation of ieee 1149.1 is shown in figure 9-1. the mc68340 implementation includes a 16-state controller, a 3-bit instruction register, and two test registers (a 1-bit bypass register and a 132-bit boundary scan register). this implementation includes a dedicated tap consisting of the following signals: tck a test clock input to synchronize the test logic tms a test mode select input (with an internal pullup resistor) that is sampled on the rising edge of tck to sequence the tap controller's state machine tdi a test data input (with an internal pullup resistor) that is sampled on the rising edge of tck. tdo a three-state test data output that is actively driven in the shift-ir and shift- dr controller states. tdo changes on the falling edge of tck. 3-bit instruction register decoder tap ctlr tms tck boundary scan register bypass tdi m u x m u x tdo test data registers (133 bits) 2 0 132 0 figure 9-1. test access port block diagram 9.2 tap controller the tap controller is responsible for interpreting the sequence of logical values on the tms signal. it is a synchronous state machine that controls the operation of the jtag logic. the state machine is shown in figure 9-2; the value shown adjacent to each arc represents the value of the tms signal sampled on the rising edge of the tck signal. for a description of the tap controller states, please refer to the ieee 1149.1 document. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 9- 3 test logic reset run-test/idle select-dr_scan capture-dr select-ir_scan capture-ir shift-dr shift-ir exit1-dr exit1-ir pause-dr pause-ir exit2-dr update-dr exit2-ir update -ir 1 0 1 1 0 1 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 0 0 0 0 0 figure 9-2. tap controller state machine 9.3 boundary scan register the mc68340 ieee 1149.1 implementation has a 132-bit boundary scan register. this register contains bits for all device signal and clock pins and associated control signals. the xtal, x2, and xfc pins are associated with analog signals and are not included in the boundary scan register. all mc68340 bidirectional pins, except the open-drain i/o pins ( done1, done2, halt, and reset ), have a single register bit for pin data and an associated control bit in the boundary scan register. all open drain i/o pins have two register bits, input and output, for pin data and no associated control bit. to ensure proper operation, the open-drain pins require external pullups. twenty-three control bits in the boundary scan register define the output enable signal for associated groups of bidirectional and three-state pins. the control bits and their bit positions are listed in table 9-1. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 9- 4 mc68340 user? manual motorola table 9-1. boundary scan control bits name bit number name bit number name bit number tout2.ctl 29 cs0.ctl 66 ab28.ctl 95 irq7.ctl 52 ab.ctl 83 ab29.ctl 97 irq6.ctl 54 berr.ctl 84 ab30.ctl 99 irq5.ctl 56 db.ctl 85 ab31.ctl 101 cs3.ctl 58 ab24.ctl 87 modck.ctl 122 irq3.ctl 60 ab25.ctl 89 ifetch.ctl 125 cs2.ctl 62 ab26.ctl 91 tout1.ctl 130 cs1.ctl 64 ab27.ctl 93 boundary scan bit definitions are shown in table 9-2. the first column in table 9-2 defines the bit's ordinal position in the boundary scan register. the shift register bit nearest tdo (i.e., first to be shifted out) is defined as bit 0; the last bit to be shifted out is 131. the second column references one of the five mc68340 cell types depicted in figures 9-3?-7, which describe the cell structure for each type. the third column lists the pin name for all pin-related bits or defines the name of bidirectional control register bits. the active level of the control bits (i.e., output driver on) is defined by the last digit of the cell type listed for each control bit. for example, the active-high level for irq7.ctl (bit 52) is logic zero since the cell type is io.ctl0. the active level for ab.ctl (bit 83) is logic one, since the cell type is io.ctl1. io.ctl0 (see figure 9-6) differs from io.ctl1 (see figure 9-5) by an inverter in the output enable path. the fourth column lists the pin type: ts-output indicates a three-state output pin, i/o indicates a bidirectional pin, and od-i/o denotes an open-drain bidirectional pin. an open- drain output pin has two states: off (high impedance) and logic zero. the last column indicates the associated boundary scan register control bit for bidirectional, three-state, and open-drain output pins. bidirectional pins include a single scan bit for data (io.cell) as depicted in figure 9-7. these bits are controlled by one of the two bits shown in figures 9-5 and 9-6. the value of the control bit determines whether the bidirectional pin is an input or an output. one or more bidirectional data bits can be serially connected to a control bit as shown in figure 9- 8. note that, when sampling the bidirectional data bits, the bit data can be interpreted only after examining the io control bit to determine pin direction. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 9- 5 table 9-2. boundary scan bit definitions bit num cell type pin/cell name pin type output ctl cell bit num cell type pin/cell name pin type output ctl cell 0 io.cell fc3 i/o* ab.ctl 35 o.latch r ? rdya output 1 io.cell fc2 i/o* ab.ctl 36 o.latch t ? rdya output 2 io.cell fc1 i/o* ab.ctl 37 i.pin rxdb input 3 io.cell fc0 i/o* ab.ctl 38 o.latch txdb output 4 io.cell a23 i/o* ab.ctl 39 o.latch rtsb output 5 io.cell a22 i/o* ab.ctl 40 i.pin ctsb input 6 io.cell a21 i/o* ab.ctl 41 i.pin sclk input 7 io.cell a20 i/o* ab.ctl 42 i.pin x1 input 8 io.cell a19 i/o* ab.ctl 43 i.pin dreq1 input 9 io.cell a18 i/o* ab.ctl 44 o.latch dack1 output 10 io.cell a17 i/o* ab.ctl 45 o.latch done1 od-i/o 11 io.cell a16 i/o* ab.ctl 46 i.pin done1 od-i/o 12 io.cell a15 i/o* ab.ctl 47 i.pin dreq2 input 13 io.cell a14 i/o* ab.ctl 48 o.latch dack2 output 14 io.cell a13 i/o* ab.ctl 49 o.latch done2 od-i/o 15 io.cell a12 i/o* ab.ctl 50 i.pin done2 od-i/o 16 io.cell a11 i/o* ab.ctl 51 io.cell irq7 i/o irq7.ctl 17 io.cell a10 i/o* ab.ctl 52 io.ctl0 irq7.ctl 18 io.cell a9 i/o* ab.ctl 53 io.cell irq6 i/o irq6.ctl 19 io.cell a8 i/o* ab.ctl 54 io.ctl0 irq6.ctl 20 io.cell a7 i/o* ab.ctl 55 io.cell irq5 i/o irq5.ctl 21 io.cell a6 i/o* ab.ctl 56 io.ctl0 irq5.ctl 22 io.cell a5 i/o* ab.ctl 57 io.cell cs3 i/o cs3.ctl 23 io.cell a4 i/o* ab.ctl 58 io.ctl0 cs3.ctl 24 io.cell a3 i/o* ab.ctl 59 io.cell irq3 i/o irq3.ctl 25 io.cell a2 i/o* ab.ctl 60 io.ctl0 irq3.ctl 26 io.cell a1 i/o* ab.ctl 61 io.cell cs2 i/o cs2.ctl 27 i.pin tgate2 input 62 io.ctl0 cs2.ctl 28 o.latch tout2 ts-output tout2.ctl 63 io.cell cs1 i/o cs1.ctl 29 io.ctl0 tout2.ctl 64 io.ctl0 cs1.ctl 30 i.pin tin2 input 65 io.cell cs0 i/o cs0.ctl 31 i.pin rxda input 66 io.ctl0 cs0.ctl 32 o.latch txda output 67 io.cell d0 i/o db.ctl 33 o.latch rtsa output 68 io.cell d1 i/o db.ctl 34 i.pin ctsa input 69 io.cell d2 i/o db.ctl f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 9- 6 mc68340 user? manual motorola table 9-2. boundary scan bit definitions (continued) bit num cell type pin/cell name pin type output ctl cell bit num cell type pin/cell name pin type output ctl cell 70 io.cell d3 i/o db.ctl 101 io.ctl0 ab31.ctl 71 io.cell d4 i/o db.ctl 102 io.cell a0 i/o* ab.ctl 72 io.cell d5 i/o db.ctl 103 io.cell dsack0 i/o** berr.ctl 73 io.cell d6 i/o db.ctl 104 io.cell dsack1 i/o** berr.ctl 74 io.cell d7 i/o db.ctl 105 io.cell rmc i/o* ab.ctl 75 io.cell d8 i/o db.ctl 106 io.cell r/ w i/o* ab.ctl 76 io.cell d9 i/o db.ctl 107 io.cell siz1 i/o* ab.ctl 77 io.cell d10 i/o db.ctl 108 io.cell siz0 i/o* ab.ctl 78 io.cell d11 i/o db.ctl 109 io.cell ds i/o* ab.ctl 79 io.cell d12 i/o db.ctl 110 io.cell as i/o* ab.ctl 80 io.cell d13 i/o db.ctl 111 i.pin bgack input 81 io.cell d14 i/o db.ctl 112 o.latch bg output 82 io.cell d15 i/o db.ctl 113 i.pin br input 83 io.ctl1 ab.ctl 114 io.cell berr i/o** berr.ctl 84 io.ctl0 berr.ctl 115 o.latch halt od-i/o 85 io.ctl1 db.ctl 116 i.pin halt od-i/o 86 io.cell a24 i/o ab24.ctl 117 o.latch reset od-i/o 87 io.ctl0 ab24.ctl 118 i.pin reset od-i/o 88 io.cell a25 i/o ab25.ctl 119 o.latch clkout output 89 io.ctl0 ab25.ctl 120 i.pin extal input 90 io.cell a26 i/o ab26.ctl 121 io.cell modck i/o modck.ctl 91 io.ctl0 ab26.ctl 122 io.ctl0 modck.ctl 92 io.cell a27 i/o ab27.ctl 123 o.latch ipipe output 93 io.ctl0 ab27.ctl 124 io.cell ifetch i/o* ifetch.ctl 94 io.cell a28 i/o ab28.ctl 125 io.ctl0 ifetch.ctl 95 io.ctl0 ab28.ctl 126 i.pin bkpt input 96 io.cell a29 i/o ab29.ctl 127 o.latch freeze output 97 io.ctl0 ab29.ctl 128 i.pin tin1 input 98 io.cell a30 i/o ab30.ctl 129 o.latch tout1 ts-output tout1.ctl 99 io.ctl0 ab30.ctl 130 io.ctl0 tout1.ctl 100 io.cell a31 i/o ab31.ctl 131 i.pin tgate1 input notes: the noted pins are implemented differently than defined in the signal definition description: * input during motorola factory test ** output during motorola factory test f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 9- 7 1 mux 1 g1 1 mux 1 g1 from last cell 1 d c1 clock dr 1 d c1 update dr shift dr to next cell to output b uffer 1 ?extest 0 ?otherwise data from system logi c figure 9-3. output latch cell (o.latch) from last cell 1 mux 1 g1 input pin shift dr clock dr to next cell 1d c1 1 mux 1 g1 1d c1 update dr 1 ?extest 0 ?otherwise figure 9-4. input pin cell (i.pin) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 9- 8 mc68340 user? manual motorola fig. 9-4 1 mux 1 g1 1 mux 1 g1 output contro l fro m system logi c from last cell 1d c1 clock dr 1d c1 update dr to next cell to output enable r reset (1 = drive) 1 ?extest 0 ?otherwise shift dr figure 9-5. active-high output control cell (io.ctl1) 1 mux 1 g1 1 mux 1 g1 output contro l fro m system logi c from last cell 1d c1 clock dr 1d c1 update dr to next cell to output enable r reset (1 = drive) 1 ?extest 0 ?otherwise shift dr figure 9-6. active-low output control cell (io.ctl0) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 9- 9 1 mux 1 g1 1 mux 1 g1 output fro m system logi c from last cell 1d c1 clock dr 1d c1 update dr to next cell to output driver 1 ?extest 0 ?otherwise shift dr 1 mux 1 g1 from output enable from pin figure 9-7. bidirectional data cell (io.cell) io.ctl0 or io.ctl1 io.cell en from last cell output dat a input data output enabl e i/o pin to next cell to next bidirectional pin * note: more than one lo.cell could be serially connected and controlled by a single io.ctlx cell. figure 9-8. general arrangement for bidirectional pins 9.4 instruction register the mc68340 ieee 1149.1 implementation includes the three mandatory public instructions (extest, sample/preload, and bypass), but does not support any of the optional public instructions defined by ieee 1149.1. one additional public instruction (hi-z) provides the capability for disabling all device output drivers. the mc68340 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 9- 10 mc68340 user? manual motorola includes a 3-bit instruction register without parity, consisting of a shift register with three parallel outputs. data is transferred from the shift register to the parallel outputs during the update-ir controller state. the three bits are used to decode the four unique instructions listed in table 9-3. the parallel output of the instruction register is reset to all ones in the test-logic-reset controller state. note that this preset state is equivalent to the bypass instruction. table 9-3. instructions code b2 b1 b0 instruction 0 0 0 extest 0 0 1 sample/preload x 1 x bypass 1 0 0 hi-z 1 0 1 bypass during the capture-ir controller state, the parallel inputs to the instruction shift register are loaded with the standard 2-bit binary value (01) into the two least significant bits and the loss-of-crystal (loc) status signal into bit 2. the parallel outputs, however, remain unchanged by this action since an update-ir signal is required to modify them. the loc status bit of the instruction register indicates whether an internal clock is detected when operating with a crystal clock source. the loc bit is clear when a clock is detected and set when it is not. the loc bit is always clear when an external clock is used. the loc bit can be used to detect faulty connectivity when a crystal is used to clock the device. 9.4.1 extest (000) the external test (extest) instruction selects the 132-bit boundary scan register. extest asserts internal reset for the mc68340 system logic to force a predictable benign internal state while performing external boundary scan operations. by using the tap, the register is capable of a) scanning user-defined values into the output buffers, b) capturing values presented to input pins, c) controlling the direction of bidirectional pins, and d) controlling the output drive of three-state output pins. for more details on the function and uses of extest, please refer to the ieee 1149.1 document. 9.4.2 sample/preload (001) the sample/preload instruction selects the 132-bit boundary scan register and provides two separate functions. first, it provides a means to obtain a snapshot of system data and control signals. the snapshot occurs on the rising edge of tck in the capture- dr controller state. the data can be observed by shifting it transparently through the boundary scan register. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 9- 11 note since there is no internal synchronization between the ieee 1149.1 clock (tck) and the system clock (clkout), the user must provide some form of external synchronization to achieve meaningful results. the second function of sample/preload is to initialize the boundary scan register output bits prior to selection of extest. this initialization ensures that known data will appear on the outputs when entering the extest instruction. 9.4.3 bypass (x1x, 101) the bypass instruction selects the single-bit bypass register as shown in figure 9-9. this creates a shift-register path from tdi to the bypass register and, finally, to tdo, circumventing the 132-bit boundary scan register. this instruction is used to enhance test efficiency when a component other than the mc68340 becomes the device under test. 1 mux 1 g1 1 d c1 clock dr from tdi 0 shift dr to tdo figure 9-9. bypass register when the bypass register is selected by the current instruction, the shift-register stage is set to a logic zero on the rising edge of tck in the capture-dr controller state. therefore, the first bit to be shifted out after selecting the bypass register will always be a logic zero. 9.4.4 hi-z (100) the hi-z instruction is not included in the ieee 1149.1 standard. it is provided as a manufacturer? optional public instruction to prevent having to backdrive the output pins during circuit-board testing. when hi-z is invoked, all output drivers, including the two- state drivers, are turned off (i.e., high impedance). the instruction selects the bypass register. 9.5 mc68340 restrictions the control afforded by the output enable signals using the boundary scan register and the extest instruction requires a compatible circuit-board test environment to avoid device-destructive configurations. the user must avoid situations in which the mc68340 output drivers are enabled into actively driven networks. overdriving the tdo driver when it is active is not recommended. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 9- 12 mc68340 user? manual motorola the mc68340 includes on-chip circuitry to detect the initial application of power to the device. power-on reset (por), the output of this circuitry, is used to reset both the system and ieee 1149.1 logic. the purpose for applying por to the ieee 1149.1 circuitry is to avoid the possibility of bus contention during power-on. the time required to complete device power-on is power-supply dependent. however, the ieee 1149.1 tap controller remains in the test-logic-reset state while por is asserted. the tap controller does not respond to user commands until por is negated. the mc68340 features a low-power stop mode that uses a cpu instruction called lpstop. the interaction of the ieee 1149.1 interface with lpstop mode is as follows: 1. leaving the tap controller test-logic-reset state negates the ability to achieve minimal power consumption, but does not otherwise affect device functionality. 2. the tck input is not blocked in lpstop mode. to consume minimal power, the tck input should be externally connected to v cc or ground. 3. the tms and tdi pins include on-chip pullup resistors. in lpstop mode, these two pins should remain either unconnected or connected to v cc to achieve minimal power consumption. 9.6 non-ieee 1149.1 operation in non-ieee 1149.1 operation, there are two constraints. first, the tck input does not include an internal pullup resistor and should be pulled up externally to preclude mid-level inputs. the second constraint is to ensure that the ieee 1149.1 test logic is kept transparent to the system logic by forcing the tap controller into the test-logic-reset state, using either of two methods. during power-on, por forces the tap controller into this state. alternatively, sampling tms as a logic one for five consecutive tck rising edges also forces the tap controller into this state. if tms either remains unconnected or is connected to v cc , then the tap controller cannot leave the test-logic-reset state, regardless of the state of tck. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 10-1 section 10 applications this section provides guidelines for using the mc68340. minimum system-configuration requirements and memory interface information are discussed. 10.1 minimum system configuration one of the powerful features of the mc68340 is the small number of external components needed to create an entire system. the information contained in the following paragraphs details a simple high-performance mc68340 system (see figure 10-1). this system configuration features the following hardware: processor clock circuitry reset circuitry sram interface rom interface serial interface clock c ircuitr y mc68340 sram rom serial i nterfac e figure 10-1. minimum system configuration block diagram 10.1.1 processor clock circuitry the mc68340 has an on-chip clock synthesizer that can operate from an on-chip phase- locked loop (pll) and a voltage-controlled oscillator (vco). the clock synthesizer uses an external crystal connected between the extal and xtal pins as a reference frequency source. figure 10-2 shows a typical circuit using an inexpensive 32.768-khz watch crystal. the 20-m resistor connected between the extal and xtal pins provides biasing for a faster oscillator startup time. the crystal manufacturer's documentation should be consulted for specific recommendations on external component values. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 10-2 mc68340 user? manual motorola mc68340 xtal extal 20 m 4.7 pf 10 pf 330 k 32.768 khz figure 10-2. sample crystal circuit the circuit shown in figure 10-3 is the typical circuit recommended by statek corporation, for 32768 khz crystal, part number cx-iv. it is recommended to start with these values, but parameter values may need to be adjusted to compensate for variables in layout. mc68340 xtal extal 22 m 10 pf 20 pf 470 k 32.768 khz figure 10-3. statek corporation crystal circuit a separate power pin (v ccsyn ) is used to allow the clock circuits to operate with the rest of the device powered down and to provide increased noise immunity for the clock circuits. the source for v ccsyn should be a quiet power supply, and external bypass capacitors (see figure 10-4) should be placed as close as possible to the v ccsyn pin to ensure a stable operating frequency. additionally, the pll requires that an external low-leakage filter capacitor, typically in the range of 0.01 to 0.1 m f, be connected between the xfc and v ccsyn pins. the xfc capacitor should provide 50-m w insulation but should not be electrolytic. for external clock mode without pll, the xfc pin can be left open. smaller values of the external filter capacitor provide a faster response time for the pll, and larger values provide greater frequency stability. figure 10-4 depicts examples of both an external filter capacitor and bypass capacitors for v ccsyn . f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 10-3 mc68340 xfc v ccsyn 0.1 f 1 note 1: must be a low-leakage capacitor. v ccsyn 0.1 f m m 0.01 f m figure 10-4. xfc and v ccsyn capacitor connections 10.1.2 reset circuitry because it is optional, reset circuitry is not shown in figure 10-1. the mc68340 holds itself in reset after power-up and asserts reset to the rest of the system. if an external reset pushbutton switch is desired, an external reset circuit is easily constructed by using open-collector cross-coupled nand gates to debounce the output from the switch. 10.1.3 sram interface the sram interface is very simple when the programmable chip selects are used. external circuitry to decode address information and circuitry to return data and size acknowledge ( dsack ? ) is not required. however, external ics are required to provide write enables for the high and low bytes of data. mcm6206-35 mcm6206-35 r/w ce e r/w ce e d7-d0 d15-d8 a15-a1 r/w siz0 cs d15-d0 mc68340 uwe . . . . . . . . . . . . . . . . . . . . . . . . as lwe a0 figure 10-5. sram interface the sram interface shown in figure 10-5 is a two-clock interface at 16.78-mhz operating frequency. the mcm6206c-35 memories provide an access time of 15 ns when the chip enable ( e ) input is low. if buffers are required to reduce signal loading or if slower and less expensive memories are desired, a three-clock cycle can be used. in the circuit shown in figure 10-5, additional memories can be used provided the mc68340 specification for f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 10-4 mc68340 user? manual motorola load capacitance on the chip-select ( cs ? ) signal is not exceeded. (address buffers may be needed, however.) 10.1.4 rom interface using the programmable chip selects creates a very straightforward rom interface. as shown in figure 10-6, no external circuitry is needed. care must be used, however, not to overload the address bus. address buffers may be required to ensure that the total system input capacitance on the address signals does not exceed the c l specification. mc68340 a16?1 d15?0 cs0 16-bit rom ce ce figure 10-6. rom interface 10.1.5 serial interface the necessary circuitry to create an rs-232 interface with the mc68340 includes an external crystal and an rs-232 receiver/driver (see figure 10-7). the resistor and capacitor values shown are typical; the crystal manufacturer's documentation should be consulted for specific recommendations on external component values. the circuit shown does not include modem support (ready-to-send (rts) and clear-to-send (cts) are not shown); however, these signals can be connected to the receiver/driver and to the connector in a similar manner as the connections for txdx and rxdx. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 10-5 x1 x2 rxdx txdx mc68340 15 pf 5 pf 3.6864 mhz rx1 tx1 rs 232 connector c1+ c2+ mc145407 r t 10 f m 10 f m c1- c1- m 10 f m 10 f v ss g n d c 2 + c 2 - v cc figure 10-7. serial interface 10.2 memory interface information the following paragraphs contain information on using an 8-bit boot rom, performing access time calculations, calculating frequency-adjusted outputs, and interfacing an 8-bit device to 16-bit memory using the dma channel single-address mode. 10.2.1 using an 8-bit boot rom upon power-up, the mc68340 uses cs0 to begin operation. cs0 is a three-wait-state, 16- bit chip select, until otherwise programmed. if an 8-bit rom is desired, external circuitry can be added to return an 8-bit dsack ? in two wait states (see figure 10-8). clkout cs0 cp mr q0 q1 q2 q3 dsack0 '393 figure 10-8. external circuitry for 8-bit boot rom the `393 is a falling edge-triggered counter; thus, cs0 is stable during the time in which it is being clocked. cs0 acts as the asynchronous reset?.e., when it is asserted, the `393 is allowed to count. the falling edge of s2 provides the first counting edge. q1 does not transition on this falling edge, but transitions to a logic one on the subsequent edge. dsack0 is q1 inverted; thus, on the next falling edge, dsack0 is seen as asserted, indicating an 8-bit port. when cs0 is negated, q1 is again held in reset and dsack0 is negated. the timing diagram in figure 10-9 illustrates this operation. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 10-6 mc68340 user? manual motorola s0 s1 s2 sw sw sw sw s3 s4 s5 s0 s1 s2 clkout cs0 q1 dsack0 figure 10-9. 8-bit boot rom timing 10.2.2 access time calculations the two time paths that are critical in an mc68340 application using the cs ? signals are shown in figure 10-10. the first path is the time from address valid to when data must be available to the processor; the second path is the time from cs ? asserted to when data must be available to the processor. cs d15?0 a31?0 clkout s0 s4 s1 s5 s0 t 27 t csdv t t 6 ad v t 9 figure 10-10. access time computation diagram as shown in the diagram, an equation for the address access time, t adv , can be developed as follows: t adv = t cyc (n c ?0.5) ?t s9 ?t s27 where: t cyc = system clkout period n c = number of clocks per bus cycle t s6 = clkout high to address valid = 30 ns maximum at 16.78 mhz t s27 = data-in valid to clkout low setup = 5 ns minimum at 16.78 mhz f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 10-7 an equation for the chip select access time, t csdv , can be developed as follows: t csdv = t cyc (n c ?1) ?t s9 ?t s27 where: t cyc = system clock period n c = number of clocks per access t s9 = clkout low to cs ? asserted = 30 ns maximum at 16.78 mhz t s27 = data-in valid to clkout low setup = 5 ns minimum at 16.78 mhz using these equations, the memory access times at 16.78 mhz are shown in table 10-1. see section 11 electrical characteristics for more timing information. table 10-1. memory access times at 16.78 mhz access time n = 2 n = 3 n = 4 n = 5 n = 6 t adv 54 ns 114 ns 173 ns 233 ns 292 ns t csdv 24 ns 84 ns 143 ns 203 ns 263 ns the values can be used to determine how many clock cycles an access will take, given the access time of the memory devices and any delays through buffers or external logic that may be needed. 10.2.3 calculating frequency-adjusted output the general relationship between the clkout and most input and output signals is shown in figure 10-11. most outputs transition off of a falling edge of clkout, but the same principle applies to those outputs that transition off of a rising edge. clkout outputs asynchronous input s t d t su h t figure 10-11. signal relationships to clkout for outputs that are referenced to a clock edge, the propagation delay (t d ) does not change as the frequency changes. for instance, specification 6 in the electrical characteristics, shown in section 11 electrical characteristics , shows that address, function code, and size information is valid 3 to 30 ns after the rising edge of s0. this specification does not change even if the device frequency is less than 16.78 mhz. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 10-8 mc68340 user? manual motorola additionally, the relationship between the asynchronous inputs and the clock edge, as shown in figure 10-11, does not change as frequency changes. a second type of specification indicates the minimum amount of time a signal will be asserted. this type of specification is illustrated in figure 10-12. output clkout t w n t/2 t d figure 10-12. signal width specifications the method for calculating a frequency-adjusted t w is as follows: t w ' = t w + n (t f '/2 ?t f /2) + (t f '/2 ?t d ) where: t w ' = the frequency-adjusted signal width t w = the signal width at 16.78 mhz n = the number of full one-half clock periods in t w t f '/2 = one-half the new clock period t f /2 = one-half the clock period at full speed t d = the propagation time from the clock edge the following calculation uses a 16.78-mhz part, specification 14, as width asserted, at 12.5 mhz as an example: t w = 100 ns n = 3 t f '/2 = 80/2 = 40 ns t f /2 = 60/2 = 30 ns t d = 30 ns maximum therefore: t w ' = 100 + 3(40 ?30) + (40 ?30) = 140 ns the third type of specification used is a skew between two outputs (see figure 10-13). f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 10-9 output2 output1 clkout t/2 t d1 d2 t s t figure 10-13. skew between two outputs the method for calculating a frequency-adjusted t s is as follows: t s ' = t s + n (t f '/2 ?t f /2) + (t f '/2 ? t d1 ) where: t s ' = the frequency-adjusted skew t s = the skew at full speed n = the number of full one-half clock periods in t s , if any t f '/2 = one-half the new clock period t f /2 = one-half the clock period at full speed t d1 = the propagation time for the first output from the clock edge the following calculation uses a 16.78-mhz port, specification 21, r/ w high to as asserted, at 8 mhz as an example: t s = 15 ns minimum n = 0 t f '/2 = 125/2 = 62.5 ns t f /2 = 60/2 = 30 ns t d1 = 30 ns maximum therefore: t s ' = 15 + 0(62.5 ?30) + (62.5 ?30) = 47.5 ns minimum in this manner, new specifications for lower frequencies can be derived for an mc68340. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 10-10 mc68340 user? manual motorola 10.2.4 interfacing an 8-bit device to 16-bit memory using single- address dma mode one of the requirements of single-address mode is that the source and destination must be the same port size. however, the mc68340 can perform direct memory accesses in single-address mode between an 8-bit device and 16-bit memory. the port size must be specified as 8 bits, and some external logic is required as shown in figure 10-14. device 74f245 b t/r oe a mc68340 memory d15-d8 siz0 siz1 a0 r/w d7-d0 figure 10-14. circuitry for interfacing 8-bit device to 16-bit memory in single-address dma mode during even-byte accesses, the data is transferred directly on d15?8. however, during odd-byte accesses, the data must be routed on d15?8 for the 8-bit device and on d7 d0 for the 16-bit memory. 10.3 power consumption considerations the mc68340 can be designed into low-power applications that involve high-performance processing capability (32-bits), high functional density, small size, portable capability, and battery operation. the mc68340 fits into the following types of applications: "palmtop" computers telephony ?stylus input ?cordless phones ?voice input ?cellular phones ?image input cd-i, cd-rom transaction tracking defense industry ?car rental ?guidance systems ?cargo ?tracking systems ?courier data entry ?handheld instruments bar code scanners handheld games f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 10-11 10.3.1 mc68340 power reduction at 5v the following figures show how different variables affect typical power consumption at 5?. figure 10-15 shows how system activity affects current drain. figure 10-16 shows how voltage affects current drain at some typical operating temperatures. figure 10-17 shows how system clock frequency affects current drain. 0 30 60 90 120 +dma off +timer 1 off serial off max current initialization +timer 2 off typical values 32khz xtal 16.78 mhz 24 c +lpstop .06 i (ma) 42 93 81 73 66 62 cc figure 10-15. mc68340 current vs. activity at 5 v f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 10-12 mc68340 user? manual motorola 60 80 100 120 0 c 24 c 100 c 5.5 5 4 typical values 32khz xtal 16.78 mhz peak current v cc (v) i cc (ma) figure 10-16. mc68340 current vs. voltage/temperature 0 30 60 90 120 0 16 14 12 10 8 6 4 2 typical values 32khz xtal peak current 24 c clock frequency (mhz) i cc (ma) figure 10-17. mc68340 current vs. clock frequency at 5 v f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 10-13 10.3.2 mc68340v (3.3 v) the mc68340v can operate with a 3.3-v power supply for significant power savings. the formula for power dissipation is p d ? v 2 f + dc table 10-2 shows typical electrical characteristics for both the mc68340 and mc68340v. table 10-2. typical electrical characteristics parameter mc68340 (5.0 v) mc68340v (3.3 v) clock frequency 0?6.78 mhz 0?5 mhz 0?.39 mhz 0?6.78 mhz typical current (16 mhz) 95 ma tbd typical current (8 mhz) 55 ma 30 ma standby current 60 m a 25 m a running at 3.3 v saves 66% of the power consumption. the 3.3 v operation provides the following user advantages: advantage benefit lower supply voltage fewer batteries fewer batteries less weight smaller size lower current drain extended battery life less heat generated no fan no fan noise less emf radiation easier fcc certification less crosstalk closer pcb traces high functional integration all-in-one 3.3 v part: processor peripherals glue logic these advantages result in a much more portable system. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 11-1 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 (e.g., either gnd or v cc ). section 11 electrical characteristics this section contains detailed information on power considerations, dc/ac electrical characteristics, and ac timing specifications of the mc68340. refer to section 12 ordering information and mechanical data for specific part numbers corresponding to voltage, frequency, and temperature ratings. 11.1 maximum ratings rating symbol value unit supply voltage 1, 2 v cc ?.3 to +6.5 v input voltage 1, 2 v in ?.3 to +6.5 v operating temperature range t a 0 to 70 or ?0 to +85 c storage temperature range t stg ?5 to +150 c notes: 1. permanent damage can occur if maximum ratings are exceeded. exposure to voltages or currents in excess of recommended values affects device reliability. device modules may not operate normally while being exposed to electrical extremes. 2. although sections of the device contain circuitry to protect against damage from high static voltages or electrical fields, take normal precautions to avoid exposure to voltages higher than maximum-rated voltages. the following ratings define a range of conditions in which the device will operate without being damaged. however, sections of the device may not operate normally while being exposed to the electrical extremes. 11.2 thermal characteristics characteristic symbol value unit thermal resistance?unction to case ceramic 144-pin qfp plastic 145-pin pga q jc 6 tbd c/w thermal resistance?unction to ambient ceramic 144-pin qfp plastic 145-pin pga q ja 33 27* c/w * estimated f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11-2 mc68340 user? manual motorola 11.3 power considerations the average chip-junction temperature, t j , in c can be obtained from: t j = t a + (p d ? q ja ) (1) where: t a = ambient temperature, c q ja = package thermal resistance, junction-to-ambient, c/w p d =p int + p i/o p int =i cc x v cc , watts?hip internal power p i/o = power dissipation on input and output pins?ser determined 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 c) solving equations (1) and (2) for k gives: k = p d ?(t a + 273 c) + q ja ?p d 2 where k is a constant pertaining to the particular part. k can be determined from equation (3) by measuring p d (at thermal equilibrium) for a 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) iteratively for any value of t a . 11.4 ac electrical specification definitions the ac specifications presented consist of output delays, input setup and hold times, and signal skew times. all signals are specified relative to an appropriate edge of the clock and possibly to one or more other signals. the measurement of the ac specifications is defined by the waveforms shown in figure 11-1. to test the parameters guaranteed by motorola, inputs must be driven to the voltage levels specified in the figure. outputs are specified with minimum and/or maximum limits, as appropriate, and are measured as shown. inputs are specified with minimum setup and hold times and are measured as shown. finally, the measurement for signal-to-signal specifications are shown. note that the testing levels used to verify conformance to the ac specifications do not affect the guaranteed dc operation of the device as specified in the dc electrical characteristics. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 11-3 the mc68340v low voltage parts can operate up to 8.39 mhz or 16.78 mhz with a 3.3 v 0.3 v supply. separate part numbers are used to distinguish the operation of the parts according to the supply voltage. refer to section 12 ordering information and mechanical data for the part numbering schemes. mc68340 is used throughout this section to refer to the 16.78- or 25.16-mhz parts at 5.0 v 5%. mc68340v is used throughout this section to refer to the 8.39- or 16.78-mhz parts at 3.3 v 0.3 v. note the electrical specifications in this section for the mc68340 25.16 mhz at 5.0 v 5% and the 3.3 v 0.3 v specifications for both the 8.39- and 16.78-mhz parts are preliminary. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11-4 mc68340 user? manual motorola 0.8 v 2.0 v b 2.0 v 0.8 v valid output n valid output n + 1 2.0 v 0.8 v 2.0 v 0.8 v 2.0 v 0.8 v valid output n valid output n+1 2.0 v 0.8 v b a valid input 2.0 v 0.8 v 2.0 v 0.8 v d valid input 2.0 v 0.8 v 2.0 v 0.8 v d drive to 0.5 v drive to 2.4 v 2.0 v 0.8 v 2.0 v 0.8 v f clkout outputs(1) outputs(2) inputs(3) inputs(4) all signals(5) notes: 1. this output timing is applicable to all parameters specified relative to the rising edge of the clock. 2. this output timing is applicable to all parameters specified relative to the falling edge of the clock. 3. this input timing is applicable to all parameters specified relative to the rising edge of the clock. 4. this input timing is applicable to all parameters specified relative to the falling edge of the clock. 5. this timing is applicable to all parameters specified relative to the assertion/negation of another signal. legend: a. maximum output delay specification. b. minimum output hold time. c. minimum input setup time specification. d. minimum input hold time specification. e. signal valid to signal valid specification (maximum or minimum). f. signal valid to signal invalid specification (maximum or minimum). e a c c figure 11-1. drive levels and test points for ac specifications f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 11-5 11.5 dc electrical specifications (see notes (a), (b), (c), and (d) corresponding to part operation, gnd = 0 vdc, ta = 0 to 70 c; see numbered notes) characteristic symbol min max unit input high voltage (except clock) v ih 2.0 v cc v input low voltage v il gnd 0.8 v clock input high voltage v ihc 0.7 * (v cc )v cc +0.3 v undershoot ?.8 v input leakage current (all input only pins) v in = v cc or gnd i in ?.5 2.5 m a hi-z (off-state) leakage current (all noncrystal outputs and i/o pins) v in = 0.5/2.4 v 1 i oz ?0 20 m a signal low input current tms, tdi v il = 0.8 v signal high input current tms, tdi v ih = 2.0 v i l i h ?.015 ?.015 0.2 0.2 ma ma output high voltage 1, 2 i oh = ?.8 ma, v cc = 4.75 v all noncrystal outputs except halt , reset , done2, done1 v oh 2.4 v output low voltage 1 i ol = 2.0 ma clkout, freeze, ipipe , ifetch i ol = 3.2 ma a23?0, d15?0, fc3?c0, siz1, siz0 i ol = 5.3 ma all other output only and group 2 i/o pins i ol = 15.3 ma halt , reset v ol 0.5 0.5 0.5 0.5 v total supply current at 5 v +5% @ 16.78 mhz run 3 lpstop (vco off) i cc s icc 180 500 ma m a power dissipation at 5 v +5% @ 16.78 mhz 4 p d 945 mw total supply current at 3.3 v + 0.3 v @ 8.39 mhz run 5 lpstop (vco off) i cc s icc tbd tbd ma m a power dissipation at 3.3 v +0.3 v @ 8.39 mhz 6 p d tbd mw input capacitance 7 all input-only pins all i/o pins c in 10 20 pf load capacitance 7 c l 100 pf notes: (a) the electrical specifications in this document for both the 8.39 and 16.78 mhz @ 3.3 v 0.3 v are preliminary and apply only to the appropriate mc68340v low voltage part. (b) the 16.78-mhz specifications apply to the mc68340 @ 5.0 v 5% operation. (c) the 25.16 mhz @ 5.0 v 5% electrical specifications are preliminary. (d) for extended temperature parts ta = ?0 to +85 c. these specifications are preliminary. 1. input-only pins: berr, bg, bkpt, br, ctsb, ctsa, dreq2, dreq1, dsack1, dsack0 , extal, rxdb, rxda, sclk, tck, tdi, tgate2, tgate1 , tin2, tin1, tms output-only pins: a23?0, as , bg, clkout, dack2, dack1, ds , fc3?c0, freeze, ifetch, ipipe, rmc , rtsb, rtsa, r/ w , r ? rdya , siz1, siz0, tdo, tout2, tout1, txdb, txda, t ? rdya input/output pins: group 1: d15?0 group 2: a31?24, cs3?s0, done2, done1, irq7, irq5, irq3 , modck group 3: halt, reset 2. v oh specification for halt, reset, done2, and done1 is not applicable because they are open-drain pins. 3. supply current measured with system clock frequency of 16.78 mhz @ 5.25 v. 4. power dissipation measured with a system clock frequency of 16.78 mhz, all modules active. 5. supply current measured with system clock frequency of 8.39 mhz @ 3.6 v. 6. power dissipation measured with a system clock frequency of 8.39 mhz, all modules active. 7. capacitance is periodically sampled rather than 100% tested. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11-6 mc68340 user? manual motorola 11.6 ac electrical specifications control timing (see notes (a), (b), (c), and (d) corresponding to part operation, gnd = 0 vdc, ta = 0 to 70 c; see numbered notes) 3.3 v 3.3 v or 5.0 v 5.0 v 8.39 mhz 16.78 mhz 25.16 mhz num. characteristic symbol min max min max min max unit system frequency 1 f sys dc 8.39 dc 16.78 dc 25.16 mhz crystal frequency f xtal 25 50 25 50 25 50 khz on-chip vco system frequency f sys 0.13 8.39 0.13 16.78 0.13 25.16 mhz on-chip vco frequency range f vco 0.1 16.78 0.1 33.5 0.1 50.3 mhz external clock operation f sys 0 8 0 16 0 25 mhz pll start-up time 2 t rc 20 20 20 ms limp mode clock frequency 3 syncr x-bit = 0 syncr x-bit = 1 f limp f sys /2 f sys f sys /2 f sys f sys /2 f sys khz clkout stability 4 d clk ? +1 ? +1 ? +1 % 1 5 clkout period in crystal mode t cyc 119.2 59.6 40 ns 1b 6 external clock input period t extcyc 125 62.5 40 ns 1c 7 external clock input period with pll t extcyc 125 62.5 40 ns 2,3 8 clkout pulse width in crystal mode t cw 56 28 19 ns 2b, 3b 9 clkout pulse width in external mode t extcw 56 28 18 ns 2c, 3c 10 clkout pulse width in external w/pll mode t extcw 62.5 31 20 ns 4,5 clkout rise and fall times t crf 10 5 4 ns notes: (a) the electrical specifications in this document for both the 8.39 and 16.78 mhz @ 3.3 v 0.3 v are preliminary and apply only to the appropriate mc68340v low voltage part. (b) the 16.78-mhz specifications apply to the mc68340 @ 5.0 v 5% operation. (c) the 25.16 mhz @ 5.0 v 5% electrical specifications are preliminary. (d) for extended temperature parts t a = ?0 to +85 c. these specifications are preliminary. 1. all internal registers retain data at 0 hz. 2. assumes that a stable v ccsyn is applied, that an external filter capacitor with a value of 0.1 m f is attached to the xfc pin, and that the crystal oscillator is stable. lock time is measured from power-up to reset release. this specification also applies to the period required for pll lock after changing the w and y frequency control bits in the synthesizer control register (syncr) while the pll is running, and to the period required for the clock to lock after lpstop. 3. determined by the initial control voltage applied to the on-chip vco. the x-bit in the syncr controls a divide- by-two scaler on the system clock output. 4. clkout stability is the average deviation from programmed frequency measured at maximum f sys . measurement is made with a stable external clock input applied using the pll. 5. all crystal mode clock specifications are based on using a 32.768-khz crystal for the input. 6. when using the external clock input mode (modck reset value = 0 v), the minimum allowable t extcyc period will be reduced when the duty cycle of the signal applied to extal exceeds 5% tolerance. the relationship between external clock input duty cycle and minimum t extcyc is expressed: minimum t extcyc period = minimum t extcw / (50% ?external clock input duty cycle tolerance). minimum external clock low and high times are based on a 45% duty cycle. 7. when using the external clock input mode with the pll (modck reset value = 0 v), the external clock input duty cycle can be at minimum 20% to produce a clkout with a 50% duty cycle. 8. for crystal mode operation, the minimum clkout pulse width is based on a 47% duty cycle. 9. for external clock mode operation, the minimum clkout pulse width is based on a 45% duty cycle, with a 50% duty cycle input clock. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 11-7 10. for external clock w/pll mode operation, the minimum clkout pulse width is based on a 50% duty cycle. 11. for external clock mode, there is a 10?0 ns skew between the input clock signal and the output clkout signal from the mc68340. clock skew is measured from the rising edges of the clock signals. 12. for external clock mode w/pll, there is a 5 ns skew between the input clock signal and the output clkout signal from the mc68340. clock skew is measured from the rising edges of the clock signals. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11-8 mc68340 user? manual motorola 11.7 ac timing specifications (see notes (a), (b), (c), and (d) corresponding to part operation, gnd = 0 vdc, ta = 0 to 70 c; see numbered notes; see figures 11-2 11-11) 3.3 v 3.3 v or 5.0 v 5.0 v 8.39 mhz 16.78 mhz 25.16 mhz num. characteristic symbol min max min max min max unit 6 clkout high to address, fc, siz, rmc valid t chav 060030020 ns 7 clkout high to address, data, fc, siz, rmc high impedance t chazx 0 120 0 60 0 40 ns 8 clkout high to address, fc, siz, rmc invalid t chazn 0 0 0 ns 9 9 clkout low to as , ds , cs , ifetch , ipipe, iack ? asserted t clsa 3 60 3 30 3 20 ns 9a 2 as to ds or cs asserted (read) t stsa ?0 30 ?5 15 ? 6 ns 11 address, fc, siz, rmc valid to as , cs (and ds read) asserted t avsa 30 15 10 ns 12 clkout low to as, ds, cs, ifetch, ipipe, iack ? negated t clsn 3 60 3 30 3 20 ns 13 as , ds , cs , iack ? negated to address, fc, siz invalid (address hold) t snai 30 15 10 ns 14 as , cs (and ds read) width asserted t swa 200 100 70 ns 14a ds width asserted (write) t swaw 90 45 30 ns 14b as , cs , iack ? (and ds read) width asserted (fast termination cycle) t swdw 80 40 30 ns 15 3 as , ds , cs width negated t sn 80 40 30 ns 16 clkout high to as , ds , r/ w high impedance t chsz 120 60 40 ns 17 as , ds , cs negated to r/ w high t snrn 30 15 10 ns 18 clkout high to r/ w high t chrh 060030020 ns 20 clkout high to r/ w low t chrl 060030020 ns 21 9 r/ w high to as , cs asserted t raaa 30 15 10 ns 22 r/ w low to ds asserted (write) t rasa 140 70 47 ns 23 clkout high to data-out valid t chdo ?0?0?0 ns 24 data-out valid to negating edge of as , cs , (fast termination write) t dvasn 30 15 10 ns 25 ds , cs , negated to data-out invalid (data-out hold) t sndoi 30 15 10 ns 26 data-out valid to ds asserted (write) t dvsa 30 15 10 ns 27 data-in valid to clkout low (data setup) t dicl 10?? ns 27a late berr , halt , bkpt asserted to clkout low (setup time) t belcl 40 20 10 ns 28 as , ds negated to dsack ? , berr , halt negated t sndn 0 160 0 80 0 50 ns 29 4 ds , cs negated to data-in invalid (data-in hold) t sndi 0 0 0 ns 29a 4 ds , cs negated to data-in high impedance t shdi 120 60 40 ns f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 11-9 11.7 ac timing specifications (continued) 3.3 v 3.3 v or 5.0 v 5.0 v 8.39 mhz 16.78 mhz 25.16 mhz num. characteristic symbol min max min max min max unit 30 4 clkout low to data-in invalid (fast termination hold) t cldi 30 15 10 ns 30a 4 clkout low to data-in high impendance t cldh 180 90 60 ns 31 5 dsack ? asserted to data-in valid t dadi 100 50 32 ns 31a dsack ? asserted to dsack ? valid (skew) t dadv 60 30 20 ns 32 halt and reset input transition time t hrrf 400 200 140 ns 33 clkout low to bg asserted t clba 60 30 20 ns 34 clkout low to bg negated t clbn 60 30 20 ns 35 6 br asserted to bg asserted ( rmc not asserted) t braga 1 1 1 clkout 37 bgack asserted to bg negated t gagn 1 2.5 1 2.5 1 2.5 clkout 39 bg width negated t gh 2?? clkout 39a bg width asserted t ga 1?? clkout 46 r/ w width asserted (write or read) t rwa 300 150 100 ns 46a r/ w width asserted (fast termination write or read) t rwas 180 90 60 ns 47a 8 asynchronous input setup time t aist 15 8, 5 5 ns 47b asynchronous input hold time t aiht 30 15 10 ns 48 5,7 dsack ? asserted to berr , halt asserted t daba 60 30 20 ns 53 data-out hold from clkout high t doch 0?? ns 54 clkout high to data-out high impedance t chdh 60 30 20 ns 55 r/ w asserted to data bus impedance change t radc 80 40 25 ns 56 reset pulse width (reset instruction) t hrpw 512 512 512 clkout 56a reset pulse width (input from external device) t rpwi 590 590 590 clkout 57 berr negated to halt negated (rerun) t bnhn 0?? ns 70 clkout low to data bus driven (show cycle) t scldd 0 60 0 30 0 20 ns 71 data setup time to clkout low (show cycle) t sclds 30 15 10 ns 72 data hold from clkout low (show cycle) t scldh 20 10? ns 80 dsi input setup time t dsisu 30 15 10 ns 81 dsi input hold time t dsih 20 10? ns 82 dsclk setup time t dscsu 30 15 10 ns 83 dsclk hold time t dsch 20 10? ns 84 dso delay time t dsod t cyc + 50 t cyc + 25 t cyc + 16 ns f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11-10 mc68340 user? manual motorola 11.7 ac timing specifications (continued) 3.3 v 3.3 v or 5.0 v 5.0 v 8.39 mhz 16.78 mhz 25.16 mhz num. characteristic symbol min max min max min max unit 85 dsclk cycle t dsccyc 2?? clkout 86 clkout high to freeze asserted t frza 0 100 0 50 0 35 ns 87 clkout high to freeze negated t frzn 0 100 0 50 0 35 ns 88 clkout high to ifetch high impedance t ifz 0 100 0 50 0 35 ns 89 clkout high to ifetch valid t if 0 100 0 50 0 35 ns notes: (a) the electrical specifications in this document for both the 8.39 and 16.78 mhz @ 3.3 v 0.3 v are preliminary and apply only to the appropriate mc68340v low voltage part. (b) the 16.78-mhz specifications apply to the mc68340 @ 5.0 v 5% operation. (c) the 25.16 mhz @ 5.0 v 5% electrical specifications are preliminary. (d) for extended temperature parts t a = ?0 to +85 c. these specifications are preliminary. 1. all ac timing is shown with respect to 0.8 v and 2.0 v levels unless otherwise noted. 2. this number can be reduced to 5 ns if strobes have equal loads. 3. if multiple chip selects are used, the cs width negated (#15) applies to the time from the negation of a heavily loaded chip select to the assertion of a lightly loaded chip select. 4. these hold times are specified with respect to ds or cs on asynchronous reads and with respect to clkout on fast termination reads. the user is free to use either hold time for fast termination reads. 5. if the asynchronous setup time (#47) requirements are satisfied, the dsack ? low to data setup time (#31) and dsack ? low to berr low setup time (#48) can be ignored. the data must only satisfy the data-in to clkout low setup time (#27) for the following clock cycle: berr must only satisfy the late berr low to clkout low setup time (#27a) for the following clock cycle. 6. to ensure coherency during every operand transfer, bg will not be asserted in response to br until after cycles of the current operand transfer are complete and rmc is negated. 7. in the absence of dsack ? , berr is an asynchronous input using the asynchronous setup time (#47). 8. specification #47a for 16.78 mhz @ 3.3 v 0.3v will be 8 ns. 9. during interrupt acknowledge cycles up to two wait states may be inserted by the processor between states s0 and s1. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 11-11 r/w ds as a31?0 11 14 9 9a 12 20 21 46 cs dsack1 berr d15?0 47a 28 29 27 27a 48 12 12 9 47a halt ifetch asynchronous inputs 31 27a bkpt rmc 47b 29a note: all timing is shown with respect to 0.8v and 2.0v levels. clkout s0 s2 s4 s1 s3 s5 8 fc3?c0 siz1?iz0 18 dsack0 6 13 figure 11-2. read cycle timing diagram f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11-12 mc68340 user? manual motorola r/w as ds a31?0 clkout s0 s2 s4 s1 s3 s5 6 8 11 14 15 9 12 13 22 cs 9 20 14a 17 dsack0 berr d15?0 47a 28 27a 48 halt 25 53 55 26 23 54 bkpt note: all timing is shown with respect to 0.8-v and 2.0-v levels. 46 dsack1 fc3?c0 siz1?iz0 figure 11-3. write cycle timing diagram f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 11-13 as a31?0 clkout s0 s4 s0 s1 s5 8 6 9 ds d15?0 12 14b 46a 30 27 30a r/w cs 18 bkpt 27a fc3?c0 siz1?iz0 figure 11-4. fast termination read cycle timing diagram f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11-14 mc68340 user? manual motorola as a31?0 clkout s0 s1 s0 8 6 12 r/w ds s4 s5 9 14b 20 46a cs d15-d0 18 25 24 23 bkpt 27a fc3?c0 siz1?iz0 figure 11-5. fast termination write cycle timing diagram f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 11-15 clkout a31?0 r/w as ds d15?0 dsack1 br bg bgack s0 s1 s2 s3 s4 47a 33 16 7 s5 39a 34 35 37 dsack0 figure 11-6. bus arbitation timing?ctive bus case f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11-16 mc68340 user? manual motorola clkout as d15?0 a31?0 br bg bgack 47a 47a 47a 37 35 33 34 figure 11-7. bus arbitration timing?dle bus case a31?0 clkout s0 s42 s1 s41 s43 s2 s0 8 6 18 20 r/w as 15 9 12 72 71 ds d15?0 show cycle start of external cycle bkpt 27a 70 figure 11-8. show cycle timing diagram f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 11-17 dsack0 r/w as ds a31?0, clkout s0 s1 s2 s3 s5 s4 6 8 14 11 20 13 12 9 9a 21 18 46 iackx 28 31 29 fc3?c0 siz1?iz0 29a 27 d15-d0 up to two wait states may be inserted by the processor between states s0 and s1. 47a 31a dsack1 0? clocks * * figure 11-9. iack cycle timing diagram f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11-18 mc68340 user? manual motorola freeze clkout bkpt/dsclk ifetch/dsi ipipe/dso 83 81 82 85 80 84 figure 11-10. background debug mode serial port timing freeze clkout ifetch/dsi 88 86 87 89 figure 11-11. background debug mode freeze timing f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 11-19 11.8 dma module ac electrical specifications (see notes (a), (b), (c), and (d) corresponding to part operation, gnd = 0 vdc, ta = 0 to 70 c; see figure 11-12) 3.3 v 3.3 v or 5.0 v 5.0 v 8.39 mhz 16.78 mhz 25.16 mhz num. characteristic min max min max min max unit 1 clkout low to as , dack , done asserted 60 30 20 ns 2 clkout low to as , dack negated 60 30 20 ns 3 dreq ? asserted to as asserted (for dma bus cycle) 3t cyc + t aist + t clsa ns 4 1 asynchronous input setup time to clkout low 15 8, 5 5 ns 5 asynchronous input hold time from clkout low 30 15 10 ns 6 as to dack assertion skew -30 30 15 15 10 10 ns 7 dack to done assertion skew -30 30 15 15 8 8 ns 8 as , dack , done width asserted 200 100 70 ns 8a as , dack , done width asserted (fast termination cycle) 80 40 28 ns notes: (a) the electrical specifications in this document for both the 8.39 and 16.78 mhz @ 3.3 v 0.3 v are preliminary and apply only to the appropriate mc68340v low voltage part. (b) the 16.78-mhz specifications apply to the mc68340 @ 5.0 v 5% operation. (c) the 25.16 mhz @ 5.0 v 5% electrical specifications are preliminary. (d) for extended temperature parts t a = ?0 to +85 c. these specifications are preliminary. 1. specification #4 for 16.78 mhz @ 3.3 v 0.3 v will be 8 ns. done (input) dreq clkout as dack done (output) 4 5 1 8 2 1 7 1 6 3 s0 s1 s2 s3 s4 s5 s0 s1 s2 s3 s4 s5 cpu_cycle (dma request) dma_cycle figure 11-12. dma signal timing diagram f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11-20 mc68340 user? manual motorola 11.9 timer module electrical specifications (see notes (a), (b), (c), and (d) corresponding to part operation, gnd = 0 vdc, ta = 0 to 70 c; see figures 11-13 and 11-14) 3.3 v 3.3 v or 5.0 v 5.0 v 8.39 mhz 16.78 mhz 25mhz num. characteristic symbol min max min max min max unit 1 clkout period in crystal mode t cyc 119.2 59.6 40 ns 2 clock rise and fall time t rf ?0 10 5ns 3 tin/ tgate high or low time, minimum pulse width t cyc +40 t cyc +20 t cyc +12 ns 4 1 asynchronous input setup time to clkout low 15 8, 5 5 ns 5 asynchronous input hold time from clkout low 30 15 8 ns 6 asynchronous input setup time to clkout high 10 5 3 ns 7 asynchronous input hold time from clkout high 30 15 8 ns 8 clkout high to tout valid t to 360330320ns notes: (a) the electrical specifications in this document for both the 8.39 and 16.78 mhz @ 3.3 v 0.3 v are preliminary and apply only to the appropriate mc68340v low voltage part. (b) the 16.78-mhz specifications apply to the mc68340 @ 5.0 v 5% operation. (c) the 25.16 mhz @ 5.0 v 5% electrical specifications are preliminary. (d) for extended temperature parts t a = ?0 to +85 c. these specifications are preliminary. 1. specification #4 for 16.78 mhz @ 3.3 v 0.3 v will be 8 ns. tgate tin clkout 2 3 2 3 1 figure 11-13. timer module clock signal timing diagram f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 11-21 5 7 8 4 6 tin clkout tgate tout figure 11-14. timer module signal timing diagram f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11-22 mc68340 user? manual motorola 11.10 serial module electrical specifications (see notes (a), (b), (c), and (d) corresponding to part operation, gnd = 0 vdc, ta = 0 to 70 c; see numbered notes; see figures 11-15?1-18) 3.3 v 3.3 v or 5.0 v 5.0 v 8.39 mhz 16.78 mhz 25.16 mhz num. characteristic symbol min max min max min max unit 1 clkout cycle time t cyc 119.2 59.6 40 ns 2 clock rise or fall time t rf ?0?0 5 ns 3 2 clock input (x1 or sclk ) synchronizer setup time t cs 15 8, 5 5 ns 4 clock input (x1 or sclk ) synchronizer hold time t ch 30 15 8 ns 5 txd data valid from clkout high t vld 0.5 t cyc max 6 x1 cycle time t x1 2.25 t cyc min 7 x1 high or low time t x1hl 0.55 t cyc + 0.75(t cs + t ch ) min 8 sclk high or low time, asynchronous (16x) mode t ahl t cyc + t cs + t ch min 9 1 sclk high time, synchronous (1x) mode t sh t cyc (gx) + t cs (gx) + t ch (gx) min 10 sclk low time, synchronous (1x) mode t sl greater of ({1.5t cyc (tx) + t cs (tx) + t vld (tx)} + 0.5t cyc (rx) + t cs (rx) + t ch (rx)}) or t sh min 11 txd data valid from sclk low, synchronous (1x) mode t t d 1.5t cyc (tx) + t cs (tx) + t vld (tx) max 12 rxd setup time to sclk high, synchronous (1x) mode t r s 0.5t cyc (rx) + t cs (rx) + t ch (rx) min 13 rxd hold time from sclk high, synchronous (1x) mode t r h 0.5t cyc (rx) + t cs (rx) + t ch (rx) min notes: (a) the electrical specifications in this document for both the 8.39 and 16.78 mhz @ 3.3 v 0.3 v are preliminary and apply only to the appropriate mc68340v low voltage part. (b) the 16.78-mhz specifications apply to the mc68340 @ 5.0 v 5% operation. (c) the 25.16 mhz @ 5.0 v 5% electrical specifications are preliminary. (d) for extended temperature parts t a = ?0 to +85 c. these specifications are preliminary. 1. asynchronous operation numbers take into account a receiver and transmitter operating at different clock frequencies. (rx) refers to receiver value. (tx) refers to transmitter value. (gx) refers to the value that is greater, either receiver or transmitter. 2. specification #3 for 16.78 mhz @ 3.3 v 0.3 v will be 8 ns. clkout txd 1 5 figure 11-15. serial module general timing diagram f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 11-23 2 2 6 7 7 x1 figure 11-16. serial module asynchronous mode timing (x1) sclk (16x) 2 2 88 figure 11-17. serial module asynchronous mode timing (sclk?6x) sclk (1x) txd rxd 2 10 9 11 12 13 2 figure 11-18. serial module synchronous mode timing diagram f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 11-24 mc68340 user? manual motorola 11.11 ieee 1149.1 electrical specifications ( see notes (a), (b), (c), and (d) corresponding to part operation, gnd = 0 vdc, ta = 0 to 70 c; see figures 11-19?1-21) 3.3 v 3.3 v or 5.0 v 5.0 v 8.39 mhz 16.78 mhz 25.16 mhz num. characteristic min max min max min max unit tck frequency of operation 0 8.39 0 16.78 0 25 mhz 1 tck cycle time in crystal mode 119.2 59.6 40 ns 2 tck clock pulse width measured at 1.5 v 56 28 18 ns 3 tck rise and fall times 0 10 0503ns 6 boundary scan input data setup time 32 16 10 ns 7 boundary scan input data hold time 52 26 18 ns 8 tck low to output data valid 0 80 0 40 0 26 ns 9 tck low to output high impedance 0 120 0 60 0 40 ns 10 tms, tdi data setup time 30 15 10 ns 11 tms, tdi data hold time 30 15 10 ns 12 tck low to tdo data valid 0 50 0 25 0 16 ns 13 tck low to tdo high impedance 0 50 0 25 0 16 ns notes: (a) the electrical specifications in this document for both the 8.39 and 16.78 mhz @ 3.3 v 0.3 v are preliminary, and apply only to the appropriate mc68340v low voltage part. (b) the 16.78-mhz specifications apply to the mc68340 @ 5.0 v 5% operation. (c) the 25.16 mhz @ 5.0 v 5% electrical specifications are preliminary. (d) for extended temperature parts t a = ?0 to +85 c. these specifications are preliminary. v v tck 1 2 2 3 3 ih il figure 11-19. test clock input timing diagram f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 11-25 tck data outputs data inputs data outputs data outputs v v input data valid output data valid output data valid 7 8 il ih 6 9 8 figure 11-20. boundary scan timing diagram tclk tdi tms tdo tdo tdo v v input data valid output data valid output data valid 11 12 13 12 il ih 10 figure 11-21. test access port timing diagram f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 12-1 section 12 ordering information and mechanical data this section contains ordering information, pin assignments and package dimensions of the mc68340. 12.1 standard mc68340 ordering information supply voltage package type frequency (mhz) temperature order number 5.0 v ceramic quad flat pack fe suffix 0 ?16.78 0 ?16.78 0 ?25 0 c to +70 c ?0 c to +85 c 0 c to +70 c mc68340fe16 mc68340cfe16 mc68340fe25 5.0 v plastic pin grid array rp suffix 0 ?16.78 0 ?16.78 0 ?25 0 c to +70 c ?0 c to +85 c 0 c to +70 c mc68340rp16 mc68340crp16 mc68340rp25 3.3 v ceramic quad flat pack fe suffix 0 ?8.39 0 ?8.39 0 ?16.78 0 c to +70 c ?0 c to +85 c 0 c to +70 c mc68340fe8v mc68340cfe8v mc68340fe16v 3.3 v plastic pin grid array rp suffix 0 ?8.39 0 ?8.39 0 ?16.78 0 c to +70 c ?0 c to +85 c 0 c to +70 c mc68340rp8v mc68340crp8v mc68340rp16v f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 12-2 mc68340 user? manual motorola 12.2 pin assignmen ?ceramic surface mount 12.2.1 144-lead ceramic quad flat pack (fe suffix) . v cc v cc dsack 1 dsack 0 a0 a31 a30 a29 a28 a27 a26 a25 a24 d15 d14 d13 d12 v cc d11 d10 d9 d8 d7 d6 d5 d4 v cc d3 d2 d1 d0 rmc r/w siz1 siz0 ds as bgack bg br berr halt reset gnd clkout v cc xfc extal xtal modck v cc ipipe ifetch bkpt freeze tin1 tout1 tgate1 tck tms tdi tdo v cc fc3 fc2 fc1 fc0 a23 a22 a21 a20 a19 a18 a17 a16 a15 a14 a13 a12 a11 a10 a9 a8 a7 a6 a5 a4 v cc a3 a2 a1 1 144 top view mc68340 72 73 108 109 91 18 36 37 54 127 126 55 90 19 v ccsyn v cc v cc v cc gnd gnd gnd gnd gnd gnd gnd gnd gnd gnd gnd gnd cs0 cs1 cs2 irq3 cs3 v cc irq5 irq6 irq7 done2 dack2 dreq2 done1 dack1 dreq1 x2 v cc x1 sclk ctsb rtsb txdb rxdb rxrdy a txrdya ctsa rtsa v cc rxda tin2 tout2 tgate 2 gnd gnd gnd v cc txda f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 12-3 the v cc and gnd pins are separated into groups to help electrically isolate the output drivers for different functions of the mc68340. these groups are shown in the following table for the fe suffix package. pin group ?fe suffix v cc gnd address bus, function codes 41, 50, 59, 68, 134 42, 51, 60, 69, 135 data bus 113, 123 114, 124 as, bg , clkout, ds , freeze, halt, ifetch, ipipe , modck , reset, rmc , r/ w , siz ? , tdo, tout1, internal logic 15, 17, 35, 143 13, 21, 36, 144 cs ? , dack ? , done ? , irq ? , rts ? , r ? rdya, tout2, txdx, t ? rdya , internal logic 78, 90, 102 79, 91, 103 oscillator 19 internal only 23 55, 126 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 12-4 mc68340 user? manual motorola 12.2.2 145-lead plastic pin grid array (rp suffix) . fc1 fc3 tdi tck tin1 freeze ipipe modck extal xfc reset berr br as siz1 tin2 a23 fc2 tdo tms tout1 bkpt v cc xtal v cc clkout halt bgack ds r/w rmc a22 fc0 gnd v cc tgate1 ifetch gnd v ccsyn gnd bg siz0 gnd dsack1 dsack0 a20 gnd v cc a0 a3o a18 a19 a21 a31 a29 a28 a16 a17 gnd a27 v cc v cc v cc a25 a24 a26 gnd d14 d15 d12 d13 d7 d8 d9 gnd d11 d10 v cc gnd d5 d6 a4 gnd nc a7 a6 a5 a10 a9 a8 a11 gnd a12 a13 gnd a14 a15 gnd v cc v cc a3 a2 tgate2 gnd dack1 irq7 gnd cs2 d1 v cc txdb gnd v cc v cc d4 d3 d2 d0 cs0 irq3 cs1 cs3 irq5 irq6 dack2 done2 dreq2 done1 x1 dreq1 sclk x2 rtsb ctsb rxdb rxrdya txrdya rtsa txda tout2 a1 rxda ctsa v cc 1 234 56 7 8910 11 12 13 14 15 bottom view q p n m l k j h g f e d c b a v cc f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 12-5 the v cc and gnd pins are separated into groups to help electrically isolate the different output drivers of the mc68340. these groups are shown in the following table for the rp suffix package. pin group ?rp suffix v cc gnd address bus, function codes d2, g3, k3, k14, m3 d3, g2, j3, k13, m2 data bus c14, f13 d13, g13 as, bg , clkout, ds , freeze, halt , ifetch, ipipe , modck, reset, rmc , r/ w , sizx, tdo, tout1, internal logic m13, n4, n9, p9 n3, n7, n10, n13 cs ? , dack ? , done ? , irq ? , rts ? , r ? rdya , tout2, txdx, t ? rdya , internal logic b11, c4, c7 c5, c8, c11 oscillator n8 internal only p7 h3, h13 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . 12-6 mc68340 user? manual motorola 12.3 package dimensions 12.3.1 fe suffix x pin one inde n z a/b trimmed, formed discre t showing datum featu r q y 0.5 0 tx y z s s m r k m j c h w m 0.1 0 t ? seating plan e 144 x g d 0.2 0 0.2 0 m m t t x-y z x-y z s s s 144 x s/ v 0.2 0 0.2 0 t t x-y z x-y z s s s side vie w gull wing lead configur a top vie w di m a b c d g h j k m q millimet e inch e mi n ma x mi n ma x 25.8 4 27.7 0 1.01 7 1.09 25.8 4 27.7 0 1.01 7 1.09 3.5 5 4.3 1 0.14 0 0.17 0 0.2 2 0.4 1 0.00 9 0.01 6 0.65 bs 0.0256 b s 0.2 5 0.8 8 0.01 0 0.03 5 0.1 3 0.2 5 0.00 5 0.01 0 0.6 5 0.9 5 0.02 6 0.03 7 0 80 8 0.325 b s 0.0128 b s notes: 1. dimensioning and tolerancing per ansi y14.5 m 2. controlling dimension: millimeters 3. dim a and b define maximum ceramic body dimen including glass protrusion and mismatch of c e body top and bottom. 4. datum plane -w- is located at the underside o where leads exit package body. 5. datums x-y and z to be determined where cent exit package body at datum -w-. 6. dim s and v to be determined at seating plan e 7. dim a and b to be determined at datum plane - fe suffix packa g ceramic qfp case 863a-01 s s f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual 12-7 12.3.2 rp suffix . .. . . . . . d c s 1 2345 6789101112131415 a b c d e f g h k l m n p q j bottom view g g dim millimeters inches min max min max a b c d g k 1.550 1.570 1.550 1.570 0.895 0.905 39.37 39.88 39.37 39.88 22.75 22.97 22.75 22.97 0.895 0.905 0.100 basic 2.54 basic 2.92 3.43 0.115 0.135 145 pin pga case no. 768e-01 t pin a-1 b a v v l k m 145 pl l m s v 1.02 1.52 0.040 0.060 0.43 0.55 0.017 0.022 4.32 4.95 0.170 0.195 35.56 basic 1.400 basic f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68330 user? manual index-1 index ?a a-line instructions, 5-47 a/d bit, 7-15?-16, 7-23 field, 5-73 register, 5-76?-77 a0 signal, 3-6?-13 access time calculations, 10-6 address access time, 10-6 bus signals, 2-4, 3-4, 3-16 error exception, 3-7, 3-39, 5-42?-43, 5-45?-46 mask register example, 4-33 mask registers, 4-31, 4-37 registers, 5-10, 5-13 space bits, 4-20 space block size, 4-2, 4-3, 4-14 spaces, 2-5, 3-3?-4, 4-2, 4-20, 4-30?-31, 6-32 strobe signal, 2-6, 3-2, 3-4, 3-14?-21, 3-44, 3-46, 4-22 with postincrement, 5-14 with predecrement, 5-14 advantages, 10-13 alternate function code registers, 5-10 applications profile, 10-10 arithmetic/logical instruction timing table, 5-102 5-104 assert rts command, 7-28?-29 asynchronous inputs, 3-1?-2, 3-14?-15, 3-44 operation, 3-14 setup and hold times, 3-2, 3-15, 3-18?-21,10-7 atemp register, 5-67 automatic echo modes, 7-14, 7-38 autovector operation timing, 3-31 register, 4-5, 4-6, 4-23 signal, 2-6, 3-5, 3-29, 3-32, 4-6 auxiliary control register, 7-18, 7-26?-27, 7-32, 7-46 ?b b bits, 5-56, 5-57?-58 b/c bits, 7-23?-24, 7-47 background debug mode, 5-64?-65, 5-94 command execution, 5-67 command summary, 5-75?-76 serial interface, 5-68?-69 background processing state, 5-7, 5-37, 5-64?-73, 5-95?-101 base address bits, 4-20 base address registers, 4-14, 4-30, 4-33, 4-37 battery operation, 10-10 baud rate clock, 7-2, 7-26?-27 generator, 7-3, 7-8 bb bits, 6-4, 6-29, 6-38 bdm sources, 5-66 bed bit, 6-27, 6-27, 6-30?-31, 6-37 berr signal, 5-45?-47 bes bit, 6-20, 6-31, 6-37 bfc bits, 4-30 bgnd instruction, 5-66 binary-coded decimal extended instructions timing table, 5-106 instructions, 5-26 bit manipulation instructions, 5-25 timing table, 5-109 bit set/reset command, 7-37 bits per character, 7-23 bkpt signal, 5-65?-66, 5-68, 5-71?-72 bkpt_tag, 5-72 block mode, 7-13, 7-23 bme bit, 4-6, 4-25, 4-37 bmt bits, 4-25?-26, 4-37 boot rom, 4-14?-15, 4-36 boundary scan bit definitions, 9-4 register, 9-1?-3 break condition, 7-11 breakpoint acknowledge cycle operation, 3-22 flowchart, 3-24 timing, opcode returned, 3-25 timing, exception signaled, 3-26 breakpoint exception, 5-42, 5-46?-47, 5-53 breakpoint instruction, 3-22, 5-28, 5-40, 5-42, 5-46, 5-63, 5-94, 5-97 breakpoint signal, 2-10, 3-22, 3-24, 6-31 brg bit, 7-32, 7-46 brkp bit, 6-20, 6-27, 6-31, 6-37?-38 burst mode transfers, 6-5 bus arbitration operation, 3-40, 3-41?-45 flowchart, 3-41 interaction with show cycles, 3-44 control, 3-44 state diagram 3-45 bandwidth, 6-4?-5, 6-29 controller operation, 5-89?-90 cycle termination response time, 4-6, 4-30, 4-32 cycle termination, 3-34?-36, 3-47 cycle, 3-2 error exception, 5-45 error signal, 2-8, 3-5, 3-14?-15, 3-22, 3-24, 3-30, 3-32?-37, 3-44, 4-4, 4-6, 4-22, 4-30 error stack frame, 5-60?-63 errors types, 3-34 timing, without dsack ? , 3-35 timing, late bus error, 3-36 resulting in double bus faults, 3-39 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . index-2 mc68340 user? manual motorola during dma transfers, 6-18, 6-20, 6-31, 6-33?-35 grant acknowledge signal, 3-40?-44 request signal, 2-7, 3-37, 3-40?-44, 6-25 state diagram, 3-45 bypass register, 9-11 byte transfer counter, 6-15, 6-19?-20, 6-34?-35, 6-37?-38 ?c calculate effective address instruction timing table, 5-100 calculating frequency adjusted output, 10-7,?0-9 call command, 5-68, 5-84?-85 cd-i, 1-9, 10-11 cd-rom, 10-11 cell types, 9-4 output latch diagram, 9-7 input pin diagram, 9-7 active-high output control diagram, 9-8 active-low output control diagram, 9-8 bidirectional data diagram, 9-9 change of flow, 5-91, 5-94 changing privilege levels, 5-38 timer modes, 8-6 channel control register, 6-4?-5, 6-18?-20, 6-26, 6-30, 6-36?-37 mode, 7-38 status register, 6-18, 6-20, 6-30, 6-37?-38 character mode, 7-13, 7-23 chip-select 0 signal, 3-30, 4-14?-16, 4-33, 4-36, 10-5 chip select, 4-1, 4-13?-15, 4-29 access time, 10-6?0-7 overlapped, 4-15, 4-33 programming example, 4-33 registers, 4-29 signals, 2-5, 4-15?-17, 10-4, 10-6?0-7 clear to send signal, 2-11 clk bit, 8-21, 8-27 clkout signal, 2-8, 4-1, 4-9, 4-11, 4-13, 4-17, 5-69, 8-3, 9-11 clock operating modes, 4-9?-12 select register, 7-8, 7-18, 7-26?-27, 7-33, 7-47 synthesizer control register, 4-10?-11, 4-13, 4-28, 4-36, synthesizer, 4-1, 4-9 cm bits, 7-38 code compatibility, 5-8, 5-11 com bit, 8-7?-9, 8-12, 8-24?-25, 8-27 command format, 5-73?-74 register, 7-10?-11, 7-23, 7-27, 7-46?-47 sequence diagram, 5-74?-75 compare register, 8-2, 8-12, 8-26?-27 compressed tables, 5-31?-32 condition code register, 5-10, 5-14, 5-20?-21 condition codes, 5-10, 5-26?-27 condition test instructions, 5-20?-21, 5-29 conditional branch instruction timing table, 5-110 conf bit, 6-20, 6-30?-31, 6-37?-38 configuration code (modules) sim40, 4-38?-40 dma, 6-38?-45 serial, 7-47?-49 timer, 8-28?-31 control instruction timing table, 5-111 control register, 8-4, 8-20?-23 cos bit, 7-31?-32, 7-34 counter clock, 8-3 events, 8-2 register, 8-6?-7, 8-13?-14, 8-25 cpe bit, 8-6, 8-8, 8-21, 8-24, 8-28 cpu space, 3-3, 3-21?-23, 3-28 address encoding, 3-21 cpu32 block diagram, 5-3 privilege levels, 5-7, 5-37?-38 processing states, 5-7, 5-36?-37 programming model, 5-8?-9 serial logic, 5-71?-73 stack frames, 5-60?-63 crystal oscillator, 4-9?-10, 4-29 cts bits, 7-31, 7-35 operation, 7-11 ctsx signal, 7-6?-7, 7-11, 7-13, 7-20, 7-22, 7-29, 7-31?-32, 7-35, 7-39 current drain, 10-11 typical operation data, 10-12?0-13 current instruction program counter, 5-67?-68 cycle steal transfers, 6-5?-6 cycle termination, 3-1 ?d dapi bits, 6-19, 6-28, 6-37 data bus signals, 2-4, 3-2, 3-16 holding register, 6-12, 6-15 misalignment, 5-45?-46 movement instructions, 5-21 port organization, 3-5?-7 registers, 5-10 strobe signal, 2-7, 3-4, 3-17?-21, 3-44?-46, 4-22 transfer and size acknowledge signals, 2-6, 3-5, 3-8?-15, 3-17?-23, 3-28?-30, 3-32?-36, 4-2, 4-4, 4-6, 4-14?-15, 4-32, transfer capabilities, 3-5, 3-8?-15 dba bit, 7-33, 7-35 dbb bit, 7-33, 7-34 dbcc instruction, 5-3 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual index-3 dbf bit, 4-6, 4-23 dbfe bit, 4-6, 4-25, 4-37 dd bits, 4-14, 4-17, 4-32 destination address register, 6-15, 6-18?-19, 6-28, 6-33?-34, 6-37?-38 deterministic opcode tracking, 5-64, 5-87?-88 dfc bits, 6-32 differences between mc68020 instruction set and mc68340 instruction set, 5-5 div instructions, dma acknowledge signals, 2-10, 6-4?-7, 6-10, 6-12, 6-15 capabilities, 6-1 channel initialization, 6-18?-19, 6-36 operation sequence, 6-18?-21 termination, 6-18, 6-20?-21 done signals, 2-10, 6-4, 6-7, 6-10, 6-12, 6-15 programming model, 6-23 programming sequence, 6-18 request signals, 2-10, 6-4?-7, 6-18?-19, 6-21 timing single-address read (external burst), 6-8 single-address read (cycle steal), 6-9 single-address write (external burst), 6-10 single-address write (cycle steal), 6-11 dual-address read (external burst?ource requesting), 6-13 dual-address read (cycle steal?ource requesting), 6-14 dual-address write (external burst?estination requesting), 6-16 dual-address write (cycle steal?estination requesting), 6-17 fast termination (cycle steal), 6-21 fast termination (external burst source requesting), 6-22 transfer type, 3-5 transfers, control of bus, 6-6, 6-18 transfers, 32 bits, 6-2, 6-7, 6-35 documentation, 1-10 done bit, 6-15, 6-20, 6-27, 6-31, 6-37?-38, 6-30 double bus fault, 3-39, 3-41, 5-43, 5-66 monitor, 3-40, 4-1, 4-4, 4-6, 4-23, 4-37 dsack encoding, 3-5 signals, 4-2, 4-4, 4-6, 4-14, 4-32, 10-5 dsclk signal, 5-69?-71 dsi signal, 5-69, 5-71 dsize bits, 6-15, 6-29, 6-37 dso signal, 5-69, 5-71 dual-address destination write, 6-15 mode, 6-12, 6-28, 6-37 source read, 6-12 transfer, 6-3 dump memory block command, 5-80?-81 dynamic bus sizing, 3-5, 3-14 ?e early bus error, 3-34 ebi, 4-2, 4-22, 4-33 eco bit, 6-7, 6-27?-28, 6-37 effects of wait states on instruction timing, 5-92 electrical characteristics, 11-1 ac electrical specifications definitions, 11-2, 11-4 control timing, 11-6?1-7 timing specifications, 11-8?1-10 timing diagram, 11-11?1-18 dma module specifications, 11-19 dma timing diagram, 11-19 timer module specifications, 11-20 timer module timing diagrams, 11-20?1-21 serial module specifications, 11-22 serial module timing diagrams, 11-22?1-23 ieee 1149.1 specifications, 11-24 ieee 1149.1 timing diagrams, 11-24?1-25 typical characteristics, 10-11 dc electrical specifications, 11-5 err bit, 7-13, 7-23, 7-47 error status, serial, 7-13 event counting, 8-14?-15 exception handler, 5-42, 5-51, 5-57, 5-59, 5-56 priorities, 5-41?-42 processing, 3-32, 5-4, 5-38, 5-61 faults, 5-54?-59 sequence, 5-40?-41 state, 5-7, 5-38, 5-40?-41 stack frame, 5-4, vectors, 5-39?-40 exception-related instructions and operands timing table, 5-112 extal pin, 2-9, 4-7, 4-9?-11, 10-21 external bus interface, 4-2 bus master, 3-4, 3-16, 3-40?-44, 4-6 dma request, 6-2, 6-5?-6, 6-19?-20, 6-29?-30 exceptions, 5-40 reset, 10-3 ?f f-line instructions, 5-47 fast termination timing, 3-15 operation, 3-4, 3-15, 4-14, 4-30, 4-33 dma transfers, 6-20 fault address register, 5-67 correction, 5-57?-59 recovery, 5-52 types, 5-54?-55, 5-57?-59, 5-83?-86 fc bits, 4-2 fcm bits, 4-32 fe bit, 7-13, 7-24, 7-28 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . index-4 mc68340 user? manual motorola fetch effective address instruction timing table, 5-99 ffull bit, 7-25 ffulla signal, 7-7 fill memory block command, 5-82 firq bit, 4-5, 4-16, 4-22, 4-35?-36 force_bgnd, 5-72 format error exception, 5-47, 5-52 four-word stack frame, 5-51, 5-60 framing error, 7-11, 7-24 freeze operation, 4-17, 6-24, 7-20, 8-19 freeze signal, 2-10, 4-3, 4-17, 4-22?-23, 4-36, 5-66?-68, 5-71?-72 frequency adjusted signal skew, 10-9 width, 10-8 frequency divider, 4-12 frz bits, 4-17?-18, 4-21?-22, 4-36, 6-24, 7-20, 7-46, 8-19, 8-27, fte bit, 4-14, 4-30 full format instruction word, function code, 3, 6-18, 6-32 encoding, 2-5, 3-3 register, 6-7, 6-10, 6-12, 6-15, 6-32, 6-38, 6-37 signals, 2-5, 3-2, 3-17 ?g global chip select, 4-14?-15, 4-36 go command, 5-68, 5-83?-84 ?h halt operation, 3-38, 3-39, 3-41 signal, 2-8, 3-4, 3-13?-15, 3-30, 3-32?-38, 4-4, 4-6, 4-17 halted processing state, halted processor causes, 3-40 hardware breakpoints, 5-60, 5-64?-65 ?i iack signals, 4-15, 4-34 iarb bits, 4-5, 4-22, 4-36, 6-25?-26, 6-36, 7-21, 7-46, 8-19, 8-27 iccs bit, 7-20, 7-46 ie bits, 8-4, 8-8?-9, 8-21, 8-27 iec bits, 7-32, 7-46 ieee 1149.1, 4-2, 9-1 capabilities, 9-1, 9-4 implementation, 9-2 block diagram, 9-2 instruction encoding, 9-10 control bits, 9-4 restrictions, 9-11 ifetch signal, 5-64, 5-68?-69, 5-87?-88 il bits, 7-21, 7-46, 8-20, 8-27 imb, 6-19, 7-1, 8-1 immediate arithmetic/logical instruction timing table, 5-105 in bit, 5-53, 5-56, 5-61 input port, 7-35 change register, 7-31 instruction cycles, 5-97 execution overlap, 5-91?-92, 5-94?-95 execution time calculation, 5-92?-93 fetch signal, 2-19 heads, 5-91?-94, 5-97 pipe signal, 2-10 pipeline operation, 5-89?-90, 5-93 register, 9-9?-10 stream timing examples, 5-94?-97 tails, 5-91?-94, 5-97 timing table overview, 5-97?-98 intb bit, 6-20, 6-27, 6-36 inte bit, 6-20, 6-27, 6-36 integer arithmetic operations, 5-46?-47 internal autovector, 3-4, 3-29, 4-23, 4-36 bus arbitration, 6-18 bus masters, 4-6, 6-25 bus monitor, 3-4, 3-32, 4-4, 4-6, 4-17 data multiplexer, 3-7 dma request, 6-2, 6-4, 6-5 dsack signals, 3-5, 3-13?-14, 3-28, 4-2, 4-4, 4-14?-15, 4-32 exceptions, 5-66 interrupt acknowledge arbitration, 4-6, 6-25?-26, 7-17 acknowledge cycle types, 3-27 autovector, 3-29 autovector, timing, 3-31 flowchart, 3-28 terminated normally, 3-27, 4-7 timing, 3-29 acknowledge cycle, 3-27 acknowledge signals, 3-29 arbitration, 4-5?-6, 7-21 enable register, 7-4, 7-34, 7-46 exception, 5-68?-69 level register, 7-21, 7-46 register, 6-26, 8-20, 8-27 request signals, 2-5?-6, 3-27?-28, 6-26, 7-3, 7-21, 7-34, 8-4, 8-8, 8-9, 8-20 status register, 7-4, 7-22, 7-32, 7-34, 7-46 vector register, 7-4, 7-17, 7-21, 7-46 intl bits, 6-26, 6-36 intn bit, 6-27, 6-36 intv bits, 6-26, 6-36 ipipe signal, 5-87?-88, 5-64, 5-68?-69 irq bit, 6-20, 6-31, 8-23 ism bits, 6-25, 6-36 ivr bits, 7-22, 8-20, 8-27 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual index-5 ?j jtag, 4-2 ?l late bus error, 3-34 lg bit, 5-56?-57 limp mode, 4-19, 4-29 local loopback mode, 7-14, 7-38 location of modules, 4-2?-3, 4-20 logical instructions, 4-48 long-word read 8-bit port, timing, 3-11 16-bit port, timing, 3-13 write 8-bit port, timing, 3-12 16-bit port, timing, 3-13 looping modes, 7-14?-15 loss of input signal, 4-9, 4-11, 4-29 low power stop mode, 3-23, 4-13, 4-17, 4-29, 10-12 low-voltage, 10-10, 10-11 lpstop cycle, 3-23 ?m maid bits, 6-25, 6-36 master station, 7-15 maximum rating, 11-1 mc68681, 7-4 memory access times, 10-7 interfacing, 10-5, 10-10 memory-to-memory transfer, 6-1, 6-3, 6-5 microbus controller, 5-89, 5-91 microsequencer operation, 5-89?-90 misaligned operands, 3-7 misc bits, 7-28 modck signal, 2-9, 4-7, 4-35 mode bits, 8-6, 8-8?-10, 8-12?-14, 8-16, 8-22, 8-28 mode register 1, 7-13, 7-16?-17, 7-22, 7-34, 7-47 mode register 2, 7-4, 7-17, 7-38, 7-47 module base address register, 4-2, 4-20, 4-36 access, 3-27 module configuration register, 4-21, 4-36, 6-23, 7-19, 7-46, 8-18, 8-27 locations, 4-3, 4-5 move instruction timing table, 5-101?-102 movem faults, 5-56, 5-58?-59, 5-61 movep faults, 5-55?-56 multidrop mode, 7-15?-16, 7-23 timing, 7-16 multiprocessor systems, 5-61 ?n ncs bit, 4-31 negate rts command, 7-29 negative tails, 5-93?-94 no operation command, 5-86 ?o oc bits, 8-6?-8, 8-10, 8-22, 8-28 oe bit, 7-13, 7-25, 7-28 on bit, 8-6, 8-8, 8-11, 8-24 one mode, 8-23 op0, 7-6, 7-36?-38 op1, 7-7, 7-36?-38 op4, 7-7, 7-36?-37 op6, 7-7, 7-36?-37 opcode tracking in loop mode, 5-88 operand faults, 5-56, 5-58, 5-61 misalignment, 3-7 size field, 5-73 operation field, 5-73 ordering information, 12-1 out bit, 8-7?-8, 8-10, 8-24 output port control register, 7-36, 7-46 data register, 7-6?-7, 7-22, 7-37 overrun error, 7-11, 7-25 ?p package dimensions, 12-6?2-7 package types, 1-9, 12-1?2-2, 12-4 parity error, 7-11, 7-24 mode, 7-23 type, 7-23 pclk bit, 8-21, 8-22, 8-27 pe bit, 7-11, 7-13, 7-24, 7-28 period measurement, 8-13 periodic interrupt control register, 4-7, 4-26, 4-37 generation, 8-6, 8-8, 8-9 timer register, 4-7, 4-27, 4-37 timer, 4-1, 4-4, 4-7, 4-9, 4-17 periodic timer period calculation, 4-8 phase comparator, 4-11?-12 phase-locked loop, 4-9?-12, 10-1?0-2 pin group, 12-3, 12-5 pirql bits, 4-7, 4-26, 4-37 pitr bits, 4-27, 4-37 piv bits, 4-26 pm bits, 7-23, 7-47 po bits, 8-25 port a data direction register, 4-34 data register, 4-34 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . index-6 mc68340 user? manual motorola pin assignment register 1, 4-15, 4-33, 4-37 pin assignment register 2, 4-15, 4-34, 4-37 pins functions, 4-15 assignment encoding, 4-15, 4-34 port b configuration, 4-5, 4-16 data direction register, 4-35 data register, 4-35 functions, 4-16 pin assignment register, 4-16, 4-35, 4-37 pins functions, 2-6, 2-9, 4-16 pin assignment encoding, 4-16, 4-35 port size, 4-14, 6-31 port width, 3-1, 3-7 pot bits, 8-22, 8-28 power considerations, 11-2 power consumption, 1-8?-9, 10-11 power dissipation, 10-11 prefetch controller, 5-90?-91 prefetch faults, 5-55?-58, 5-62 preload register 1, 8-6?-13, 8-25?-27 preload register 2, 8-10?-11, 8-13, 8-26?-27 privilege violations, 5-48 processor clock circuitry, 10-1?0-2 program control instructions, 5-26?-27 program counter, 5-6, 5-67?-68 programming model cpu32, 5-8?-9 dma, 6-23 serial, 7-19 sim40, 4-19 timer, 8-18 propagation delays, 10-7 ps bits, 4-14, 4-32 pt bit, 7-23, 7-47 ptp bit, 4-7, 4-27, 4-37 pulse-width measurement, 8-12?-13 pulse-width modulation, 8-6?-7 ?r r/f bit, 7-22, 7-47 r/w field, 5-73 rb bit, 7-13, 7-24, 7-30 rc bits, 7-30 rcs bits, 7-26 read a/d register command, 5-76?-77 cycle word read, flowchart, 3-16 memory location command, 5-79?-80 modify write cycle, 5-53 modify write faults, 5-55?-56, 5-58 system register command, 5-67, 5-77?-78 read-modify-write cycle timing, 3-19 retry operation, 3-36 interruption, 3-36, 3-43 operation, 3-4 read-modify-write signal, 2-8, 3-19?-21, 3-40, 3-42?-43, 3-45 read/write signal, 2-7, 3-2 real-time clock, 4-9 receive data signal, 2-11 received break, 7-11, 7-24, 7-33 receiver, 7-9, 7-11 baud rates, 7-26 buffer, 7-11?-12, 7-25, 7-30 disable command, 7-30 enable command, 7-30 fifo, 7-12?-13, 7-17, 7-22?-23, 7-25, 7-33?-34 holding registers, 7-9, 7-11 ready signal, 2-12 shift register, 7-9, 7-12 timing, 7-12 register field, 5-74 indirect addressing mode, 5-5 released write, 5-57 remote loopback mode, 7-14, 7-38 req bits, 6-27, 6-29, 6-37 request to send signal, 2-11 reset break-change interrupt, 7-28 effect on dma transfers, 6-20 error status command, 7-28 exception, 5-43?-44 instruction, 5-85 peripherals command, 5-85?-86 operation, 3-45, 3-46 receiver command, 7-28 signal, 2-8, 3-45?-48, 5-66 status register, 4-3, 4-23 types, 3-45 timing, 3-47 transmitter command, 7-28 values for counter and prescaler, 8-2 vector, 5-4 reset signal, 3-45?-48, 5-43 retry bus cycle operation, 3-32, 3-34?-35 timing, 3-37 timing, late retry, 3-38 return from exception, 5-51?-52 return program counter, 5-67?-68 returning from background mode, 5-68 rm bit, 5-53 rom interface, 10-3 rr bit, 5-53 rs-232 interface, 10-4?0-5 rsten bit, 4-29 rte instruction, 5-57?-59, 5-61 rts operation, 7-11, 7-22 rtsa signal, 7-6, 7-37 rtsb signal, 7-6, 7-36 rts ? signal, 7-11, 7-13, 7-22, 7-29, 7-38 rw bit, 5-54 rxdx signal, 7-6, 7-11, 7-14, 7-24 rxrda bit, 7-11, 7-13, 7-15, 7-24, 7-25 rxrdya bit, 7-34?-35 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual index-7 r ? rdya signal, 7-7, 7-36 rxrdyb bit, 7-33, 7-35 rxrts bit, 7-22, 7-47 ?s s/d bit, 6-30, 6-37 sapi bits, 6-12, 6-19, 6-28, 6-37 save and restore operations timing table, 5-113 sb bits, 7-39, 7-47 sclk signal, 7-3, 7-6, 7-8, 7-20 se bit, 6-25, 6-36 selected clock, 8-3, 8-21 serial clock signal, 2-11 command control, 7-27 communication overview, 7-3 compatibility with mc68681, 7-4 crystal oscillator, 7-3, 7-5 diagnostic functions, 7-14 initialization, 7-46?-49 interface timing, 5-68?-71 interface, 10-4?0-5 maximum data transfer rate, 7-2 module capabilities, 7-2 module programming model, 7-19 module programming, 7-40 state machine, 5-69?-71 sfc bits, 6-32 shadowing, 8-6?-7 shen bits, 4-5, 4-22 shift and rotate instructions, 5-24?-25 instruction timing table, 5-108 show cycles, 4-3, 4-22 operation, 3-42?-43, 3-45 signal relationships to clkout, 10-7 signal widths, 10-8 sim40 configuration, 4-3 programming model, 4-19 simultaneous interrupts, 4-9 single address mode, 6-2, 6-6?-7, 6-10, 6-19, 6-27, 6-37 source read, 6-7?-8 source write, 6-10?-11 single operand instruction timing table, 5-107 single step operation, 3-36 six-word stack frame, 5-52, 5-60 siz bits, 5-56?-57, 5-73 size signal encoding, 2-7, 3-3 signals, 2-7, 3-3, 3-5?-7 skew between outputs, 10-9 slave station, 7-15 slimp bit, 4-11, 4-29 slock, 4-11, 4-29 software breakpoints, 5-53?-54 interrupt vector register, 4-7, 4-24, 4-36 operation, 4-4, 4-6, 4-17, 4-27 service register, 4-7, 4-28 service routine, 4-7, 4-25 timeout, 4-25 watchdog, 4-1, 4-4, 4-6 watchdog clock rate, 4-7 source address register, 6-7, 6-12, 6-18?-19, 6-28, 6-33, 6-37, 6-38 special status word, 5-45, 5-52 special-purpose move instruction timing table, 5-101?-102 spurious interrupt, 3-29 monitor, 4-1, 4-4, 4-6, 4-17, square-wave generation, 8-6, 8-8?-9 sram interface, 10-3 ssize bits, 6-12, 6-19, 6-29, 6-37 stack frames, 5-60?-63 pointer, 5-60?-63 start break command, 7-29 status register, 5-57, 5-59?-60, 5-62?-63, 7-10, 7-11, 7-24, 8-2, 8-4, 8-23?-25 stext bit, 4-13, 4-17, 4-29, 4-36 stop bit, 7-11 length, 7-39 stop break command, 7-29 stop instruction, 4-17 stop module operation, 6-24, 7-20, 8-19 stopped processing state, 5-37 stp bit, 4-17, 6-24, 6-36, 7-20, 7-46, 8-19, str bit, 6-3, 6-4, 6-5, 6-19, 6-30, 6-35, 6-37?-38 stsim bit, 4-13, 4-17, 4-29, 4-36 supervisor privilege level, 3-3 supv bit, 4-22, 6-22, 6-25, 6-36, 7-21, 7-46, 8-19, 8-27 surface interpolation with tables, 5-29?-36 sw bit, 4-23 swe bit, 4-6, 4=24, 4-37 swp bit, 4-7, 4-25, 4-27, 4-37 swr bit, 8-6, 8-8, 8-13, 8-20, 8-27 swri bit, 4-7, 4-24, 4-37 swt bits, 4-7, 4-25, 4-37 synchronous accesses, 3-4 operation, 3-14 system clock, 8-3 configuration and protection, 4-1, 4-3, 4-6 control instructions, 5-27?-28 protection and control register, 4-6, 4-24, 4-37 ?t table lookup and interpolate instructions, 5-7, 5-12, 5-29?-36 tap controller, 9-2?-3 tc bits, 8-7, 8-24 tck signal, 2-13, 9-2, 9-11, 9-12 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . index-8 mc68340 user? manual motorola tcs bits, 7-27 tdi signal, 2-13, 9-2 tdo signal, 2-13, 9-2, 9-4 test access port, 9-1 tg bit, 8-6, 8-8, 8-23?-24, 8-27 tge bit, 8-8?-11, 8-15, 8-24, 8-27 tgl bit, 8-7, 8-24 thermal characteristics, 11-1 three point three volts, 10-11 timeout, 8-2, 8-7?-9, 8-12, 8-15 timer bypass, 8-16 clock selection logic, 8-3 compare function, 8-2, 8-6?-9, 8-11?-12, 8-14, 8-15, 8-25 counter, 8-2 counting function, 8-13, 8-15 gate signal, 2-12, 8-6, 8-7?-16, 8-21, 8-24?-25 input signal, 2-12, 8-2, 8-5?-17 interrupt operation, 8-4, 8-17, 8-19, 8-21, 8-23?-24, 8-27 output signal, 2-12, 8-2, 8-5?-17 prescaler, 8-2?-3, 8-21 programming model, 8-28 uses, 8-2 using to compare values, 8-6?-8 tms signal, 2-13, 9-2 to bit, 8-8?-9, 8-23?-24, 8-27 toggle mode, 8-23 tp bit, 5-61 tr bit, 5-56, 5-58, 5-61 trace exception, 5-57 modes, 5-10 on instruction execution, 5-63 tracing, 5-56?-58 control bits encoding, 5-53 transfer cases, 3-5 mechanism, 3-5, 3-16?-18 transition to background mode, 5-65?-68 transmit data signal, 2-11 shift register, 7-9, 7-11 transmitter, 7-10?-11 baud rates, 7-27 buffer, 7-9?-10, 7-25, 7-30?-31 disable command, 7-29 enable command, 7-29 holding register, 7-9?-10, 7-25, 7-33 ready signal, 2-11 timing, 7-10 trap instruction, 5-46 two-clock bus cycles, 10-3 txcts bit, 7-39, 7-47 txdx signal, 7-3, 7-6, 7-10, 7-14, 7-29 txemp bit, 7-10, 7-25, 7-28 txrdy bit, 7-10, 7-25, 7-28, 7-31 txrdya bit, 7-34?-35 txrdya signal, 7-7, 7-36 txrdyb bit, 7-33, 7-35 txrts bit, 7-38, 7-47 types of dma interrupts, 6-20 ?u unimplemented instructions, 5-12 emulation, 5-74 exception, 5-48, 5-50 unlk instruction, 5-36 use of chip selects, 4-15, 10-3?0-4 user privilege level, 5-7, 5-37?-38, 5-48 using 8-bit boot rom, 10-5 tgate as an input port, 8-16 table lookup and interpolate instructions, 5-7, 5-12, 5-20?-35 tout as an output port, 8-16?-17 ?v v bit, 4-14?-15, 4-20, 4-31, 4-36 variable duty-cycle square-wave generator, 8-9?-10 variable-width single-shot pulse generator, 8-10?-12 vccsyn, 2-13, 4-9?-11, 10-2?0-3 vector base register, 5-4, 5-10, 5-39?-41, 5-43 vector numbers, 5-34?-40 virtual memory, 5-2 voltage-controlled oscillator, 4-9?-12, 4-28?-29, 10-1?0-2 ?w w bit, 4-10, 4-12?-13, 4-28, 4-36 wait states, 3-14, 3-16?-20, 4-1, 4-14?-15, 4-17, 4-32 wakeup mode, 7-15 word operands, 5-12 wp bit, 4-14 write a/d register command, 5-77?-79 cycle word, flowchart, 3-18 memory location command, 5-79?-80 system register command, 5-78?-79 write-pending buffer, 5-91 ?x x bit, 4-9, 4-11?-13, 4-28, 4-36 x1 signal, 2-11, 7-5 x2 signal, 2-11, 7-5 xfc pin, 2-9, 4-12, 10-2?0-3 xtal pin, 2-9, 4-9?-11, 10-1?0-2 xtal_rdy bit, 7-4, 7-26, 7-33?-34, 7-46 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola mc68340 user? manual index-9 ?y y bits, 4-12?-13, 4-28, 4-36 ?z zero mode, 8-23 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . |
Price & Availability of AN1063D
![]() |
|
|
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] |