![]() |
|
If you can't view the Datasheet, Please click here to try to view without PDF Reader . |
|
Datasheet File OCR Text: |
! "# $ % &'#""##" ()&'#""##* + ,-./ ,-./ 0+ $% + 1 + + 2 $ % % )! + 3 +!++& ! "# $ % &'#""##" ()&'#""##* + 4 53-+ 3 67 2!8+ 4% 83 % +++ 4% + ! +! +% 42 + 44 2 !890:9$::,-8;88$<(==>=?80=>=:9$$89( ,=<($89(=-$89!0?8:!=$9<0:=8;089$8: 0,-9$:0:9$::,-8;88$<(=89$$,>=>=$< 89(=89-9$=$0899<-99=$,:(89(=-$89!0?8:!= $9<0:=8;0=89=$=8:0 + 2!8+ + 2 2 3 2 4% !8+$ 3 : !8+5 23 +% 2 3 3 2 )+ %% ) 3! 33 ! + ! +% 42+ + + 3 3 2 % @ 9 + + 2 ! + 2 % ! 2% + 2 + 2 4% i scc /escc u ser s m anual chapter 1. general description 1.1 introduction .................................................................................................................................... 1-1 1.2 scc? capabilities ......................................................................................................................... 1-2 1.3 block diagram ............................................................................................................................... 1-4 1.4 pin descriptions ............................................................................................................................. 1-5 1.4.1 pins common to both z85x30 and z80x30 .................................................................... 1-7 1.4.2 pin descriptions, (z85x30 only) ...................................................................................... 1-8 1.4.3 pin descriptions, (z80x30 only) ...................................................................................... 1-9 chapter 2. interfacing the scc/escc 2.1 introduction .................................................................................................................................... 2-1 2.2 z80x30 interface timing ................................................................................................................ 2-1 2.2.1 z80x30 read cycle timing ............................................................................................. 2-2 2.2.2 z80x30 write cycle timing .............................................................................................. 2-3 2.2.3 z80x30 interrupt acknowledge cycle timing .................................................................. 2-4 2.2.4 z80x30 register access .................................................................................................. 2-5 2.2.5 z80c30 register enhancement ....................................................................................... 2-8 2.2.6 z80230 register enhancements ...................................................................................... 2-8 2.2.7 z80x30 reset .................................................................................................................. 2-9 2.3 z85x30 interface timing ............................................................................................................. 2-10 2.3.1 z85x30 read cycle timing ........................................................................................... 2-10 2.3.2 z85x30 write cycle timing ............................................................................................ 2-11 2.3.3 z85x30 interrupt acknowledge cycle timing ................................................................ 2-11 2.3.4 z85x30 register access ................................................................................................ 2-12 2.3.5 Z85C30 register enhancement ..................................................................................... 2-14 2.3.6 Z85C30/z85230 register enhancements ...................................................................... 2-14 2.3.7 z85x30 reset ................................................................................................................ 2-15 2.4 interface programming ................................................................................................................ 2-15 2.4.1 i/o programming introduction ........................................................................................ 2-15 2.4.2 polling ............................................................................................................................ 2-16 2.4.3 interrupts ........................................................................................................................ 2-16 2.4.4 interrupt control ............................................................................................................. 2-17 2.4.5 daisy-chain resolution .................................................................................................. 2-19 2.4.6 interrupt acknowledge ................................................................................................... 2-21 2.4.7 the receiver interrupt ................................................................................................... 2-21 2.4.8 transmit interrupts and transmit buffer empty bit ........................................................ 2-25 2.4.9 external/status interrupts ............................................................................................... 2-31 2.5 block/dma transfer ..................................................................................................................... 2-33 2.5.1 block transfers .............................................................................................................. 2-33 2.5.2 dma requests ............................................................................................................... 2-36 2.6 test functions ............................................................................................................................. 2-41 2.6.1 local loopback .............................................................................................................. 2-41 2.6.2 auto echo ........................................................................................................... ....... ..... 2-41 t able of c ontents scc /escc user? manual table of contents ii chapter 3. scc/escc ancillary support circuitry 3.1 introduction .................................................................................................................................... 3-1 3.2 baud rate generator ..................................................................................................................... 3-1 3.3 data encoding/decoding ............................................................................................................... 3-4 3.4 dpll digital phase-locked loop .................................................................................................. 3-7 3.4.1 dpll operation in the nrzi mode .................................................................................. 3-8 3.4.2 dpll operation in the fm modes .................................................................................... 3-9 3.4.3 dpll operation in the manchester mode ...................................................................... 3-10 3.4.4 transmit clock counter (escc only) ............................................................................. 3-10 3.5 clock selection ........................................................................................................................... 3-11 3.6 crystal oscillator ......................................................................................................................... 3-14 chapter 4. data communication modes 4.1 introduction .................................................................................................................................... 4-1 4.1.1 transmit data path description ....................................................................................... 4-1 4.1.2 receive data path description ....................................................................................... 4-2 4.2 asynchronous mode ...................................................................................................................... 4-3 4.2.1 asynchronous transmit ................................................................................................... 4-4 4.2.2 asynchronous receive .................................................................................................... 4-6 4.2.3 asynchronous initialization ............................................................................................... 4-7 4.3 byte-oriented synchronous mode ................................................................................................. 4-8 4.3.1 byte-oriented synchronous transmit .............................................................................. 4-8 4.3.2 byte-oriented synchronous receive ............................................................................. 4-10 4.3.3 transmitter/receiver synchronization ........................................................................... 4-17 4.4 bit-oriented synchronous (sdlc/hdlc) mode .......................................................................... 4-18 4.4.1 sdlc transmit ............................................................................................................... 4-19 4.4.2 sdlc receive ................................................................................................................ 4-22 4.4.3 sdlc frame status fifo .............................................................................................. 4-27 4.4.4 sdlc loop mode ........................................................................................................... 4-30 chapter 5. register descriptions 5.1 introduction .................................................................................................................................... 5-1 5.2 write registers .............................................................................................................................. 5-2 5.2.1 write register 0 (command register) ............................................................................. 5-2 5.2.2 write register 1 (transmit/receive interrupt and data transfer mode definition) .......... 5-4 5.2.3 write register 2 (interrupt vector) ................................................................................... 5-7 5.2.4 write register 3 (receive parameters and control) ........................................................ 5-7 5.2.5 write register 4 (transmit/receive miscellaneous parameters and modes) .................. 5-8 5.2.6 write register 5 (transmit parameters and controls) ..................................................... 5-9 5.2.7 write register 6 (sync characters or sdlc address field) .......................................... 5-10 5.2.8 write register 7 (sync character or sdlc flag) ........................................................... 5-11 5.2.9 write register 7 prime (escc only) .............................................................................. 5-12 5.2.10 write register 7 prime (85c30 only) .............................................................................. 5-13 5.2.11 write register 8 (transmit buffer) .................................................................................. 5-13 5.2.12 write register 9 (master interrupt control) .................................................................... 5-14 5.2.13 write register 10 (miscellaneous transmitter/receiver control bits) ........................... 5-15 5.2.14 write register 11 (clock mode control) ......................................................................... 5-17 5.2.15 write register 12 (lower byte of baud rate generator time constant) ....................... 5-18 5.2.16 write register 13 (upper byte of baud rate generator time constant) ....................... 5-19 5.2.17 write register 14 (miscellaneous control bits) .............................................................. 5-19 5.2.18 write register 15 (external/status interrupt control) ..................................................... 5-20 5.3 read registers ............................................................................................................................ 5-21 5.3.1 read register 0 (transmit/receive buffer status and external status) ........................ 5-21 5.3.2 read register 1 ............................................................................................................. 5-23 5.3.3 read register 2 ............................................................................................................. 5-24 5.3.4 read register 3 ............................................................................................................. 5-25 5.3.5 read register 4 (escc and 85c30 only) ..................................................................... 5-25 5.3.6 read register 5 (escc and 85c30 only) ..................................................................... 5-25 scc /escc user? manual table of contents iii 5.3.7 read register 6 (not on nmos) ................................................................................... 5-25 5.3.8 read register 7 (not on nmos) ................................................................................... 5-25 5.3.9 read register 8 ............................................................................................................. 5-26 5.3.10 read register 9 (escc and 85c30 only) ..................................................................... 5-26 5.3.11 read register 10 ........................................................................................................... 5-26 5.3.12 read register 11 (escc and 85c30 only) ................................................................... 5-27 5.3.13 read register 12 ........................................................................................................... 5-27 5.3.14 read register 13 ........................................................................................................... 5-27 5.3.15 read register 14 (escc and 85c30 only) ................................................................... 5-27 5.3.16 read register 15 ........................................................................................................... 5-27 chapter 6. application notes interfacing z80 ? cpus to the z8500 peripheral family ......................................................................... 6-1 the z180 interfaced with the scc at mhz........................................................................................ 6-34 the zilog datacom family with the 80186 cpu .................................................................................. 6-59 scc in binary synchronous communications ...................................................................................... 6-79 serial communication controller (scc ): sdlc mode of operation .................................................. 6-93 using scc with z8000 in sdlc protocol6-105 boost your system performance using the zilog escc ................................................................ 6-117 technical considerations when implementing localtalk link access protocol ................................ 6-131 on-chip oscillator design................................................................................................................... 6-151 chapter 7. questions and answers zilog scc z8030/z8530 questions and answers................................................................................... 7-1 zilog escc controller questions and answers ................................................................................. 7-11 iv scc /escc u ser s m anual chapter 1 figure 1-1. scc block diagram .............................................................................................................................. 1-4 figure 1-2. z85x30 pin functions .......................................................................................................................... 1-5 figure 1-3. z80x30 pin functions .......................................................................................................................... 1-6 figure 1-4. z85x30 dip pin assignments .............................................................................................................. 1-6 figure 1-5. z85x30 plcc pin assignments ........................................................................................................... 1-6 figure 1-6. z80x30 dip pin assignments .............................................................................................................. 1-7 figure 1-7. z80x30 plcc pin assignments ........................................................................................................... 1-7 chapter 2 figure 2-1. z80x30 read cycle ............................................................................................................................. 2-2 figure 2-2. z80x30 write cycle .............................................................................................................................. 2-3 figure 2-3. z80x30 interrupt acknowledge cycle .................................................................................................. 2-4 figure 2-4. write register 7 prime (wr7') ............................................................................................................. 2-8 figure 2-5. z85x30 read cycle timing ................................................................................................................ 2-10 figure 2-6. z85x30 write cycle timing ................................................................................................................ 2-11 figure 2-7. z85x30 interrupt acknowledge cycle timing .................................................................................... 2-11 figure 2-8a. write register 7 prime (wr7') for the 85230 ..................................................................................... 2-14 figure 2-8b. write register 7 prime for the 85c30 ................................................................................................. 2-14 figure 2-9. escc interrupt sources ..................................................................................................................... 2-16 figure 2-10. peripheral interrupt structure ............................................................................................................. 2-17 figure 2-11. internal priority resolution ................................................................................................................. 2-17 figure 2-12. rr3 interrupt pending bits ................................................................................................................. 2-18 figure 2-13. interrupt flow chart (for each interrupt source). ................................................................................ 2-20 figure 2-14. write register 1 receive interrupt mode control ............................................................................... 2-22 figure 2-15. special conditions interrupt service flow .......................................................................................... 2-24 figure 2-16. transmit interrupt status when wr7' d5=1 for escc ..................................................................... 2-26 figure 2-17. transmit buffer empty bit status for escc for both wr7' and wr7' d5=0 ................................... 2-27 figure 2-18. transmit interrupt status when wr7' d5=0 for escc ..................................................................... 2-27 figure 2-19. txip latching on the escc ................................................................................................................ 2-27 figure 2-20. operation of tbe, tx underrun/eom and txip on nmos/cmos. .................................................... 2-28 figure 2-21. operation of tbe, tx underrun/eom and txip on escc ................................................................. 2-29 figure 2-22. flowchart example of processing an end of packet ........................................................................... 2-30 figure 2-23. rr0 external/status interrupt operation ............................................................................................ 2-31 figure 2-24. wait on transmit timing .................................................................................................................... 2-34 figure 2-25. wait on transmit timing .................................................................................................................... 2-34 figure 2-26. wait on receive timing ..................................................................................................................... 2-35 l ist of f igures scc /escc user? manual tables of contents v figure 2-27. wait on receive timing ..................................................................................................................... 2-35 figure 2-28. transmit request assertion ............................................................................................................... 2-36 figure 2-29. z80x30 transmit request release ................................................................................................... 2-37 figure 2-30. z85x30 transmit request release ................................................................................................... 2-37 figure 2-31. /dtr//req deassertion timing ......................................................................................................... 2-38 figure 2-32. dma receive request assertion ....................................................................................................... 2-39 figure 2-33. z80x30 receive request release .................................................................................................... 2-40 figure 2-34. z85x30 receive request release .................................................................................................... 2-40 figure 2-35. local loopback .................................................................................................................................. 2-41 figure 2-36. auto echo ........................................................................................................................................... 2-41 chapter 3 figure 3-1. baud rate generator ........................................................................................................................... 3-1 figure 3-2. baud rate generator start up ............................................................................................................. 3-2 figure 3-3. data encoding methods ....................................................................................................................... 3-4 figure 3-4. manchester encoding circuit ................................................................................................................ 3-6 figure 3-5. digital phase-locked loop ................................................................................................................... 3-7 figure 3-6. dpll in nrzi mode ............................................................................................................................. 3-8 figure 3-7. dpll operating example (nrzi mode) ............................................................................................... 3-9 figure 3-8. dpll operation in the fm mode .......................................................................................................... 3-9 figure 3-9. dpll transmit clock counter output (escc only) ........................................................................... 3-11 figure 3-10. clock multiplexer ................................................................................................................................ 3-12 figure 3-11. async clock setup using an external crystal .................................................................................... 3-13 figure 3-12. clock source selection ...................................................................................................................... 3-13 figure 3-13. synchronous transmission, 1x clock rate, fm data encoding, using dpll ................................... 3-14 chapter 4 figure 4-1. transmit data path ............................................................................................................................... 4-1 figure 4-2. receive data path ................................................................................................................................ 4-2 figure 4-3. asynchronous message format ........................................................................................................... 4-3 figure 4-4. monosync data character format ....................................................................................................... 4-8 figure 4-5. sync character programming ............................................................................................................ 4-11 figure 4-6. /sync as an input .............................................................................................................................. 4-11 figure 4-7. /sync as an output ........................................................................................................................... 4-12 figure 4-8. changing character length ............................................................................................................... 4-13 figure 4-9. receive crc data path ..................................................................................................................... 4-14 figure 4-10. transmitter to receiver synchronization ............................................................................................ 4-17 figure 4-11. sdlc message format ...................................................................................................................... 4-18 figure 4-12. /sync as an output ........................................................................................................................... 4-23 figure 4-13. changing character length ............................................................................................................... 4-24 figure 4-14. residue code 101 interpretation ........................................................................................................ 4-25 figure 4-15. sdlc frame status fifo (n/a on nmos) ........................................................................................ 4-28 figure 4-16. sdlc byte counting detail ................................................................................................................ 4-29 chapter 5 figure 5-1. write register 0 in the z85x30 ............................................................................................................ 5-3 figure 5-2. write register 0 in the z80x30 ............................................................................................................ 5-3 figure 5-3. write register 1 .................................................................................................................................... 5-4 figure 5-4. write register 2 .................................................................................................................................... 5-7 figure 5-5. write register 3 .................................................................................................................................... 5-7 scc /escc user? manual tables of contents vi figure 5-6. write register 4 .................................................................................................................................... 5-8 figure 5-7. write register 5 .................................................................................................................................... 5-9 figure 5-8. write register 6 .................................................................................................................................. 5-11 figure 5-9. write register 7 .................................................................................................................................. 5-11 figure 5-10. write register 7 prime ....................................................................................................................... 5-12 figure 5-10a. write register 7 prime (wr7') ........................................................................................................... 5-13 figure 5-11. write register 9 .................................................................................................................................. 5-14 figure 5-12. write register 10 ................................................................................................................................ 5-15 figure 5-13. nrz (nrzi), fm1 (fm0) timing ......................................................................................................... 5-16 figure 5-14. write register 11 ................................................................................................................................ 5-17 figure 5-15. write register 12 ................................................................................................................................ 5-18 figure 5-16. write register 13 ................................................................................................................................ 5-19 figure 5-17. write register 14 ................................................................................................................................ 5-19 figure 5-18. write register 15 ................................................................................................................................ 5-20 figure 5-19. read register 0 .................................................................................................................................. 5-21 figure 5-20. read register 1 .................................................................................................................................. 5-23 figure 5-21. read register 2 .................................................................................................................................. 5-25 figure 5-22. read register 3 .................................................................................................................................. 5-25 figure 5-23. read register 6 (not on nmos) ........................................................................................................ 5-25 figure 5-24. read register 7 (not on nmos) ........................................................................................................ 5-26 figure 5-25. read register 10 ................................................................................................................................ 5-26 figure 5-26. read register 12 ................................................................................................................................ 5-27 figure 5-27. read register 13 ................................................................................................................................ 5-27 figure 5-28. read register 15 ................................................................................................................................ 5-27 vii scc /escc u ser s m anual chapter 2 table 2-1. z80x30 register map (shift left mode) ................................................................................................... 2-6 table 2-2. z80x30 register map (shift right mode) ................................................................................................. 2-7 table 2-3. z80230 sdlc/hdlc enhancement options ........................................................................................... 2-8 table 2-4. z80x30 register reset values ................................................................................................................ 2-9 table 2-5. z85x30 register map ............................................................................................................................. 2-13 table 2-6. Z85C30/z85230 register enhancement options ................................................................................... 2-14 table 2-7. z85x30 register reset value ................................................................................................................ 2-15 table 2-8. interrupt source priority .......................................................................................................................... 2-16 table 2-9. interrupt vector modification ................................................................................................................... 2-19 chapter 3 table 3-1. baud rates for 2.4576 mhz clock and 16x clock factor ........................................................................ 3-3 chapter 4 table 4-1. write register bits ignored in asynchronous mode ................................................................................. 4-4 table 4-2. transmit bits per character ...................................................................................................................... 4-5 table 4-3. initialization sequence asynchronous mode ............................................................................................ 4-7 table 4-4. registers used in character-oriented modes .......................................................................................... 4-9 table 4-5. transmitter initialization in character- oriented mode ........................................................................... 4-10 table 4-6. sync character length selection ........................................................................................................... 4-11 table 4-7. enabling and disabling crc .................................................................................................................. 4-16 table 4-8. initializing the receiver in character-oriented mode ............................................................................. 4-17 table 4-9. escc action taken on tx underrun ...................................................................................................... 4-20 table 4-10. residue codes ....................................................................................................................................... 4-24 table 4-11. initializing in sdlc mode ....................................................................................................................... 4-26 table 4-12. sdlc loop mode initialization ............................................................................................................... 4-32 chapter 5 table 5-1. scc write registers ................................................................................................................................ 5-1 table 5-2. scc read registers ................................................................................................................................ 5-1 table 5-3. z85x30 register map ............................................................................................................................... 5-5 table 5-4. receive bits per character ....................................................................................................................... 5-7 table 5-5. transmit bits per character .................................................................................................................... 5-10 table 5-6. interrupt vector modification ................................................................................................................... 5-14 table 5-7. data encoding ........................................................................................................................................ 5-15 l ist of t ables viii table 5-8. receive clock source ............................................................................................................................ 5-18 table 5-9. transmit clock source ........................................................................................................................... 5-18 table 5-10. transmit external control selection ....................................................................................................... 5-18 table 5-11. i-field bit selection (8 bits only) ............................................................................................................ 5-24 table 5-12. bits per character residue decoding .................................................................................................... 5-24 table 5-13. read register 7 fifo status decoding ................................................................................................ 5-26 1-1 1 u ser s m anual c hapter 1 g eneral d escription 1.1 introduction the zilog scc serial communication controller is a dual channel, multiprotocol data communication peripheral de- signed for use with 8- and 16-bit microprocessors. the scc functions as a serial-to-parallel, parallel-to-serial con- verter/controller. the scc can be software-configured to satisfy a wide variety of serial communications applica- tions. the device contains a variety of new, sophisticated internal functions including on-chip baud rate generators, digital phase-lock loops, and crystal oscillators, which dra- matically reduce the need for external logic. the scc handles asynchronous formats, synchronous byte-oriented protocols such as ibm ? bisync, and syn- chronous bit-oriented protocols such as hdlc and ibm sdlc. this versatile device supports virtually any serial data transfer application (telecommunication, lan, etc.) the device can generate and check crc codes in any synchronous mode and can be programmed to check data integrity in various modes. the scc also has facilities for modem control in both channels. in applications where these controls are not needed, the modem controls can be used for general-purpose i/o. with access to 14 write registers and 7 read registers per channel (the number of the registers varies depending on the version), the user can configure the scc to handle all synchronous formats regardless of data size, number of stop bits, or parity requirements. within each operating mode, the scc also allows for pro- tocol variations by checking odd or even parity bits, char- acter insertion or deletion, crc generation, checking break and abort generation and detection, and many other protocol-dependent features. the scc/escc family consists of the following seven devices; as a convention, use the following words to distinguish the devices throughout this document. the z-bus version has a multiplexed bus interface and is directly compatible with the z8000, z16c00 and 80x86 cpus. the universal version has a non-multiplexed bus interface and easily interfaces with virtually any cpu, in- cluding the 8080, z80, 68x00. z-bus ? universal-bus nmos z8030 z8530 cmos z80c30 Z85C30 escc z80230 z85230 emscc z85233 scc: description applies to all versions. nmos: description applies to nmos version (z8030/z8530) cmos: description applies to cmos version (z80c30/Z85C30) escc: description applies to escc (z80230/z85230) emscc: description applies to emscc (z85233) z80x30: description applies to z-bus version of the device (z8030/z80c30/z80230) z85x3x: description applies to universal version of the device (z8530/Z85C30/z85230/z85233) scc?/escc? users manual general description 1-2 1.2 sccs capabilities the nmos version of the scc is zilogs original device. the design is based on the z80 sio architecture. if you are familiar with the z80 sio, the scc can be treated as an sio with support circuitry such as dpll, brg, etc. its fea- tures include: n two independent full-duplex channels n synchronous/isosynchronous data rates: C up to 1/4 of the pclk using external clock source. up to 5 mbits/sec at 20 mhz pclk (escc) up to 4 mbits/sec at 16 mhz pclk (cmos) up to 2 mbits/sec at 8 mhz pclk (nmos) C up to 1/8 of the pclk (up to 1/16 on nmos) using fm encoding with dpll C up to 1/16 of the pclk (up to 1/32 on nmos) using nrzi encoding with dpll n asynchronous capabilities C 5, 6, 7 or 8 bits/character (capable of handling 4 bits/character or less.) C 1, 1.5, or 2 stop bits C odd or even parity C times 1, 16, 32 or 64 clock modes C break generation and detection C parity, overrun and framing error detection n byte oriented synchronous capabilities: C internal or external character synchronization C one or two sync characters (6 or 8 bits/sync character) in separate registers C automatic cyclic redundancy check (crc) generation/detection n sdlc/hdlc capabilities: C abort sequence generation and checking C automatic zero insertion and detection C automatic ?ag insertion between messages C address ?eld recognition C i-?eld residue handling C crc generation/detection C sdlc loop mode with eop recognition/loop entry and exit n receiver fifo escc: 8 bytes deep nmos/cmos: 3 bytes deep n transmitter fifo escc: 4 bytes deep nmos/cmos: 1 byte deep n nrz, nrzi or fm encoding/decoding. manchester code decoding (encoding with external logic). n baud rate generator in each channel n digital phase locked loop (dpll) for clock recovery n crystal oscillator the cmos version of the scc is 100% plug in compatible to the nmos versions of the device, while providing the following additional features: n status fifo n software interrupt acknowledge feature n enhanced timing specifications n faster system clock speed n designed in zilogs superintegration ? core format n when the dpll clock source is external, it can be up to 2x the pclk, where nmos allows up to pclk (32.3 mhz max with 16/20 mhz version). scc?/escc? users manual general description 1-3 1 the Z85C30 cmos scc has added new features, while maintaining 100% hardware/software compatibility. it has the following new features: n new programmable wr7' (write register 7 prime) to enable new features. n improvements to support sdlc mode of synchronous communication: C improved functionality to ease sending back-to back frames C automatic sdlc opening flag transmission* C automatic tx underrun/eom latch reset in sdlc mode* C automatic /rts deactivation* C txd pin forced h in sdlc nrzi mode after closing ?ag* C complete crc reception* C improved response to abort sequence in status fifo C automatic tx crc generator preset/reset C extended read for write registers* C write data setup timing improvement n improved ac timing: C three to 3.5 pclk access recovery time. C programmable /dtr//req timing* C elimination of write data to falling edge of /wr setup time requirement C reduced /int timing n other features include: C extended read function to read back the written value to the write registers* C latching rr0 during read C rr0, bit d7 and rr10, bit d6 now has reset defaultvalue. some of the features listed above are available by de- fault, and some of them (features with *) are disabled on default. escc (enhanced scc) is pin and software compati- ble to the cmos version, with the following additional enhancements. n deeper transmit fifo (4 bytes) n deeper receive fifo (8 bytes) n programmable fifo interrupt and dma request level n seven enhancements to improve sdlc link layer supports: C automatic transmission of the opening ?ag C automatic reset of tx underrun/eom latch C deactivation of /rts pin after closing ?ag C automatic crc generator preset C complete crc reception C txd pin automatically forced high with nrzi encoding when using mark idle C status fifo handles better frames with an abort C receive fifo automatically unlocked for special receive interrupts when using the sdlc status fifo n delayed bus latching for easier microprocessor interface n new programmable features added with write register 7' (wr seven prime) n write registers 3, 4, 5 and 10 are now readable n read register 0 latched during access n dpll counter output available as jitter-free transmitter clock source n enhanced /dtr, /rts deactivation timing scc?/escc? users manual general description 1-4 1.3 block diagram figure 1-1 has the block diagram of the scc. note that the depth of the fifo differs depending on the version. the 10x19 sdlc frame status fifo is not available on the nmos version of the scc. detailed internal signal path will be discussed in chapter 4. figure 1-1. scc block diagram transmit lo g channel a receive and transmit clock mul t transmit fifo nmos/cmos: 1 b y escc: 4 bytes transmit m u data encoding & c r generation digital phase-lock e loop baud rat e generat o crystal oscillat o amplifi e modem/control l o receive m u crc checke r data decode & sync charac t detection rec. status * fifo rec. data* fifo sdlc frame status f 10 x 19 receive lo g txd a /trxc a /rtxc a /cts a /dcd a /sync a /rts a /dtra//re q rxd a intern a contro logic channel a register channel b register interru p control logic cpu & dm a bus interfa c databu s contr o channel a channel b /in t /inta c ie i ie o interr u contr o exploded vi e ** see n o * nmos/cmos: 3 bytes each escc: 8 bytes ** not available on nmos scc?/escc? users manual general description 1-5 1 1.4 pin descriptions the scc pins are divided into seven functional groups: address/data, bus timing and reset, device control, in- terrupt, serial data (both channels), peripheral control (both channels), and clocks (both channels). figures 1-2 and 1-3 show the pins in each functional group for both z80x30 and z85x30. notice the pin functions unique to each bus interface version in the address/data group, bus timing and reset group, and control groups. the address/data group consists of the bidirectional lines used to transfer data between the cpu and the scc (ad- dresses in the z80x30 are latched by /as). the direction of these lines depends on whether the operation is a read or write. the timing and control groups designate the type of trans- action to occur and when it will occur. the interrupt group provides inputs and outputs to conform to the z-bus ? specifications for handling and prioritizing interrupts. the remaining groups are divided into channel a and channel b groups for serial data (transmit or receive), peripheral control (such as dma or modem), and the input and output lines for the receive and transmit clocks. the signal functionality and pin assignments (figures 1-4 to 1-7) stay constant within the same bus interface group (i.e., z80x30, z85x30), except for some timing and/or dc specification differences. for details, please reference the individual product specifications. figure 1-2. z85x30 pin functions d7 d6 d5 d4 d3 d2 d1 d0 /rd /wr a//b /ce d//c /int /intack iei ieo txda rxda /trxca /rtxca /synca /w//req a /dtr//reqa /rts a /cts a /dcda txdb rxdb /trxcb /rtxcb /syncb serial data channel clocks channel controls for modem, dma and other /w//reqb /dtr//req b /rts b /cts b /dcdb interrup t data bus serial data channel clocks control bus timing and reset channel controls for modem, dma and other z85x30 scc?/escc? users manual general description 1-6 1.4 pin descriptions (continued) figure 1-3. z80x30 pin functions ad7 ad6 ad5 ad4 ad3 ad2 ad1 ad0 /as /ds r//w cs1 /cs0 /int /intack iei ieo txda rxda /trxca /rtxca /synca /w//reqa /dtr//reqa /rtsa /ctsa /dcda txdb rxdb /trxcb /rtxcb /syncb serial data channel clocks channel controls for modem, dma and other /w//reqb /dtr//reqb /rtsb /ctsb /dcdb interrupt address data bus serial data channel clocks control bus timing and reset channel controls for modem, dma and other z80x30 channel a channel b figure 1-4. z85x30 dip pin assignments 1 2 9 3 4 5 6 7 8 4 0 39 3 8 3 7 3 6 35 3 4 3 3 32 d0 d2 d//c d4 d6 /rd /wr a//b /ce d1 31 3 0 29 2 8 2 7 14 10 11 12 13 gnd /w//reqb /syncb /rtxcb rxdb d3 d5 d7 /int ieo iei /intack vcc /w//reqa /synca /rtxca rxda /trxca txda /dtr//reqa /rtsa /ctsa /dcda pcl k 15 16 17 18 19 20 /trxcb txdb /dtr//reqb rtsb /ctsb /dcdb 2 6 25 2 4 2 3 22 21 z85x30 figure 1-5. z85x30 plcc pin assignments scc?/escc? users manual general description 1-7 1 1.4.1 pins common to both z85x30 and z80x30 /ctsa, /ctsb. clear to send (inputs, active low). these pins function as transmitter enables if they are pro- grammed for auto enable (wr3, d5=1). a low on the in- puts enables the respective transmitters. if not pro- grammed as auto enable, they may be used as general- purpose inputs. both inputs are schmitt-trigger buffered to accommodate slow rise-time inputs. the scc detects pulses on these inputs and can interrupt the cpu on both logic level transitions. /dcda, /dcdb. data carrier detect (inputs, active low). these pins function as receiver enables if they are pro- grammed for auto enable (wr3, d5=1); otherwise, they are used as general-purpose input pins. both pins are schmitt-trigger buffered to accommodate slow rise time signals. the scc detects pulses on these pins and can in- terrupt the cpu on both logic level transitions. /rtsa, /rtsb. request to send (outputs, active low). the /rts pins can be used as general-purpose outputs or with the auto enable feature. when used with auto enable on (wr3, d5=1) in asynchronous mode, the /rts pin goes high after the transmitter is empty. when auto en- able is off, the /rts pins are used as general-purpose outputs, and, they strictly follow the inverse state of wr5, bit d1. escc and 85c30: in sdlc mode, the /rts pins can be programmed to be deasserted when the closing flag of the message clears the txd pin, if wr7' d2 is set . /synca, /syncb . synchronization (inputs or outputs, ac- tive low). these pins can act either as inputs, outputs, or part of the crystal oscillator circuit. in the asynchronous receive mode (crystal oscillator option not selected), these pins are inputs similar to cts and dcd. in this mode, transitions on these lines affect the state of the syn- chronous/hunt status bits in read register 0 but have no other function. in external synchronization mode, with the crystal oscilla- tor not selected, these lines also act as inputs. in this mode, /sync is driven low to receive clock cycles after the last bit in the synchronous character is received. char- acter assembly begins on the rising edge of the receive clock immediately preceding the activation of sync. in the internal synchronization mode (monosync and bi- sync) with the crystal oscillator not selected, these pins act as outputs and are active only during the part of the figure 1-6. z80x30 dip pin assignments 1 2 9 3 4 5 6 7 8 40 39 38 37 36 35 34 33 32 ad0 ad2 cs1 ad4 ad6 /ds /as r//w /cs0 ad1 31 30 29 28 27 14 10 11 12 13 gnd /w//reqb /syncb /rtxcb rxdb ad3 ad5 ad7 /int ieo iei /intack vcc /w//reqa /synca /rtxca rxda /trxca txda /dtr//reqa /rtsa /ctsa /dcda pcl k 15 16 17 18 19 20 /trxcb txdb /dtr//reqb rtsb /ctsb /dcdb 26 25 24 23 22 21 z80x30 figure 1-7. z80x30 plcc pin assignments scc?/escc? users manual general description 1-8 1.4 pin descriptions (continued) receive clock cycle in which the synchronous condition is not latched. these outputs are active each time a synchro- nization pattern is recognized (regardless of character boundaries). in sdlc mode, the pins act as outputs and are valid on receipt of a flag. the /sync pins switch from input to output when monosync, bisync, or sdlc is pro- grammed in wr4 and sync modes are enabled. /dtr//reqa, /dtr//reqb. data terminal ready/re- quest (outputs, active low). these pins are programmable (wr14, d2) to serve either as general-purpose outputs or as dma request lines. when programmed for dtr func- tion (wr14 d2=0), these outputs follow the state pro- grammed into the dtr bit of write register 5 (wr5 d7). when programmed for ready mode, these pins serve as dma requests for the transmitter. escc and 85c30: when used as dma request lines (wr14, d2=1), the timing for the deactivation request can be pro- grammed in the added register, write register 7' (wr7') bit d4. if this bit is set, the /dtr//req pin is de- activated with the same timing as the /w/req pin. if wr7' d4 is reset, the deactivation timing of /dtr//req pin is four clock cycles, the same as in the Z85C30. /w//reqa, /w//reqb. wait/request (outputs, open-drain when programmed for wait function, driven high or low when programmed for ready function). these dual-pur- pose outputs may be programmed as request lines for a dma controller or as wait lines to synchronize the cpu to the scc data rate. the reset state is wait. rxda, rxdb. receive data (inputs, active high). these input signals receive serial data at standard ttl levels. /rtxca, /rtxcb. receive/transmit clocks (inputs, active low). these pins can be programmed to several modes of operation. in each channel, /rtxc may supply the receive clock, the transmit clock, the clock for the baud rate gener- ator, or the clock for the digital phase-locked loop. these pins can also be programmed for use with the respective sync pins as a crystal oscillator. the receive clock may be 1, 16, 32, or 64 times the data rate in asynchronous modes. txda, txdb. transmit data (outputs, active high). these output signals transmit serial data at standard ttl levels. /trxca, /trxcb. transmit/receive clocks (inputs or out- puts, active low). these pins can be programmed in sev- eral different modes of operation. /trxc may supply the receive clock or the transmit clock in the input mode or supply the output of the transmit clock counter (which parallels the digital phase-locked loop), the crystal oscil- lator, the baud rate generator, or the transmit clock in the output mode. pclk. clock (input). this is the master scc clock used to synchronize internal signals. pclk is a ttl level signal. pclk is not required to have any phase relationship with the master system clock. iei. interrupt enable in (input, active high). iei is used with ieo to form an interrupt daisy chain when there is more than one interrupt driven device. a high iei indicates that no other higher priority device has an interrupt under ser- vice or is requesting an interrupt. ieo. interrupt enable out (output, active high). ieo is high only if iei is high and the cpu is not servicing the scc in- terrupt or the scc is not requesting an interrupt (interrupt acknowledge cycle only). ieo is connected to the next lower priority devices iei input and thus inhibits interrupts from lower priority devices. /int. interrupt (output, open drain, active low). this signal is activated when the scc requests an interrupt. note that /int is an open-drain output. /intack. interrupt acknowledge (input, active low). this is a strobe which indicates that an interrupt acknowledge cycle is in progress. during this cycle, the scc interrupt daisy chain is resolved. the device is capable of returning an interrupt vector that may be encoded with the type of in- terrupt pending. during the acknowledge cycle, if iei is high, the scc places the interrupt vector on the databus when /rd goes active. /intack is latched by the rising edge of pclk. 1.4.2 pin descriptions, (z85x30 only) d7-d0 . data bus (bidirectional, tri-state). these lines carry data and commands to and from the z85x30. /ce. chip enable (input, active low). this signal selects the z85x30 for a read or write operation. /rd. read (input, active low). this signal indicates a read operation and when the z85x30 is selected, enables the z85x30s bus drivers. during the interrupt acknowledge cy- cle, /rd gates the interrupt vector onto the bus if the z85x30 is the highest priority device requesting an interrupt. /wr. write (input, active low). when the z85x30 is select- ed, this signal indicates a write operation. this indicates that the cpu wants to write command bytes or data to the z85x30 write registers. scc?/escc? users manual general description 1-9 1 a//b. channel a/channel b (input). this signal selects the channel in which the read or write operation occurs. high selects channel a and low selects channel b. d//c. data/control select (input). this signal defines the type of information transferred to or from the z85x30. high means data is being transferred and low indicates a command. 1.4.3 pin descriptions, (z80x30 only) ad7-ad0 . address/data bus (bidirectional, active high, tri-state). these multiplexed lines carry register addresses to the z80x30 as well as data or control information to and from the z80x30. r//w. read//write (input, read active high). this signal specifies whether the operation to be performed is a read or a write. /cs0. chip select 0 (input, active low). this signal is latched concurrently with the addresses on ad7-ad0 and must be active for the intended bus transaction to occur. cs1. chip select 1 (input, active high). this second select signal must also be active before the intended bus trans- action can occur. cs1 must remain active throughout the transaction. /ds. data strobe (input, active low). this signal provides timing for the transfer of data into and out of the z80x30. if /as and /ds are both low, this is interpreted as a reset. /as . address strobe (input, active low). address on ad7- ad0 are latched by the rising edge of this signal. ? 1998 by zilog, inc. all rights reserved. no part of this document may be copied or reproduced in any form or by any means without the prior written consent of zilog, inc. the information in this document is subject to change without notice. devices sold by zilog, inc. are covered by warranty and patent indemnification provisions appearing in zilog, inc. terms and conditions of sale only. zilog, inc. makes no warranty, express, statutory, implied or by description, regarding the information set forth herein or regarding the freedom of the described devices from intellectual property infringement. zilog, inc. makes no warranty of merchantability or fitness for any purpose. zilog, inc. shall not be responsible for any errors that may appear in this document. zilog, inc. makes no commitment to update or keep current the information contained in this document. zilogs products are not authorized for use as critical components in life support devices or systems unless a specific written agreement pertaining to such intended use is executed between the customer and zilog prior to use. life support devices or systems are those which are intended for surgical implantation into the body, or which sustains life whose failure to perform, when properly used in accordance with instructions for use provided in the labeling, can be reasonably expected to result in significant injury to the user. zilog, inc. 210 east hacienda ave. campbell, ca 95008-6600 telephone (408) 370-8000 fax 408 370-8056 internet: http://www.zilog.com 2-1 2 u ser s m anual c hapter 2 i nterfacing the scc/escc 2.1 introduction this chapter covers the system interface requirements with the scc. timing requirements for both devices are described in a general sense here, and the user should re- fer to the scc product specification for detailed ac/dc parametric requirements. the escc and the 85c30 have an additional register, write register seven prime (wr7'). its features include the ability to read wr3, wr4, wr5, wr7', and wr10. both the escc and the 85c30 have the ability to deassert the /dtr//reg pin quickly to ease dma interface design. additionally, the z85230 features a relaxed requirement for a valid data bus when the /wr pin goes low. the effects of the deeper data fifos should be considered when writ- ing the interrupt service routines. the user should read the sections which follow for details on these features. 2.2 z80x30 interface timing the z-bus compatible scc is suited for system applica- tions with multiplexed address/data buses similar to the z8 , z8000 , and z280 . two control signals, /as and /ds, are used by the z80x30 to time bus transactions. in addition, four other control sig- nals (/cs0, cs1, r//w, and /intack) are used to control the type of bus transaction that occurs. a bus transaction is initiated by /as; the rising edge latches the register ad- dress on the address/data bus and the state of /intack and /cs0. in addition to timing bus transactions, /as is used by the interrupt section to set the interrupt pending (ip) bits. because of this, /as must be kept cycling for the inter- rupt section to function properly. the z80x30 generates internal control signals in response to a register access. since /as and /ds have no phase re- lationship with pclk, the circuit generating these internal control signals provides time for metastable conditions to disappear. this results in a recovery time related to pclk. this recovery time applies only to transactions involving the z80x30, and any intervening transactions are ignored. this recovery time is four pclk cycles, measured from the falling edge of /ds of one access to the scc, to the falling edge of /ds for a subsequent access. scc /escc user? manual interfacing the scc/escc 2-2 2.2 z80x30 interface timing (continued) 2.2.1 z80x30 read cycle timing the read cycle timing for the z80x30 is shown in figure 2-1. the register address on ad7-ad0, as well as the state of /cs0 and /intack, are latched by the rising edge of /as. r//w must be high before /ds falls to indicate a read cycle. the z80x30 data bus drivers are enabled while cs1 is high and /ds is low. figure 2-1. z80x30 read cycle /as /cs0 /intack ad7 - ad0 r//w cs1 /ds address data valid scc /escc user? manual interfacing the scc/escc 2-3 2 2.2.2 z80x30 write cycle timing the write cycle timing for the z80x30 is shown in figure 2-2. the register address on ad7-ad0, as well as the state of /cs0 and /intack, are latched by the rising edge of /as. r//w must be low when /ds falls to indicate a write cycle. the leading edge of the coincidence of cs1 high and /ds low latches the write data on ad7-ad0, as well as the state of r//w. figure 2-2. z80x30 write cycle address data valid /as /cs0 /intack ad7 - ad0 r//w cs1 /ds scc /escc user? manual interfacing the scc/escc 2-4 2.2 z80x30 interface timing (continued) 2.2.3 z80x30 interrupt acknowledge cycle timing the interrupt acknowledge cycle timing for the z80x30 is shown in figure 2-3. the address on ad7-ad0 and the state of /cs0 and /intack are latched by the rising edge of /as. however, if /intack is low, the address, /cs0, cs1 and r//w are ignored for the duration of the interrupt acknowledge cycle. figure 2-3. z80x30 interrupt acknowledge cycle /as /cs0 /ds /intack iei ieo vector /int ad7 - ad0 scc /escc user? manual interfacing the scc/escc 2-5 2 the z80x30 samples the state of /intack on the rising edge of /as, and ac parameters #7 and #8 specify the set- up and hold-time requirements. between the rising edge of /as and the falling edge of /ds, the internal and external daisy chains settle (ac parameter #29). a system with no external daisy chain should provide the time specified in spec #29 to settle the interrupt daisy-chain priority internal to the scc. systems using an external daisy chain should refer to note 5 referenced in the z80x30 read/write & in- terrupt acknowledge timing for the time required to settle the daisy chain. note: /intack is sampled on the rising edge of /as. if it does not meet the setup time to the first rising edge of /as of the interrupt acknowledge cycle, it is latched on the next rising edge of /as. therefore, if /intack is asynchronous to /as, it may be necessary to add a pclk cycle to the cal- culation for /intack to /rd delay time. if there is an interrupt pending in the scc, and iei is high when /ds falls, the acknowledge cycle was intended for the scc. this being the case, the z80x30 sets the inter- rupt-under-service (ius) latch for the highest priority pending interrupt, as well as placing an interrupt vector on ad7-ad0. the placing of a vector on the bus can be dis- abled by setting wr9, d1=1. the /int pin also goes inac- tive in response to the falling edge of /ds. note that there should be only one /ds per acknowledge cycle. another important fact is that the ip bits in the z80x30 are updated by /as, which may delay interrupt requests if the processor does not supply /as strobes during the time between ac- cesses of the z80x30. 2.2.4 z80x30 register access the registers in the z80x30 are addressed via the address on ad7-ad0 and are latched by the rising edge of /as. the shift right/shift left bit in the channel b wr0 controls which bits are decoded to form the register address. it is placed in this register to simplify programming when the current state of the shift right/shift left bit is not known. a hardware reset forces shift left mode where the address is decoded from ad5-ad1. in shift right mode, the ad- dress is decoded from ad4-ad0. the shift right/shift left bit is written via a command to make the software writing to wr0 independent of the state of the shift right/shift left bit. while in the shift left mode, the register address is placed on ad4-ad1 and the channel select bit, a/b, is decoded from ad5. the register map for this case is shown in table 2-1. in shift right mode, the register ad- dress is again placed on ad4-ad1 but the channel select a/b is decoded from ad0. the register map for this case is shown in table 2-2. because the z80x30 does not contain 16 read registers, the decoding of the read registers is not complete; this is indicated in table 2-1 and table 2-2 by parentheses around the register name. these addresses may also be used to access the read registers. also, note that the z80x30 contains only one wr2 and wr9; these registers may be written from either channel. shift left mode is used when channel a and b are to be programmed differently. this allows the software to se- quence through the registers of one channel at a time. the shift right mode is used when the channels are pro- grammed the same. by incrementing the address, the user can program the same data value into both the channel a and channel b register. scc /escc user? manual interfacing the scc/escc 2-6 2.2 z80x30 interface timing (continued) table 2-1. z80x30 register map (shift left mode) ad5 ad4 ad3 ad2 ad1 write read 8030 80c30/230* wr15 d2 = 0 80c30/230 wr15 d2=1 80230 wr15 d2=1 wr7' d6=1 00000 wr0b rr0b rr0b rr0b 00001 wr1b rr1b rr1b rr1b 00010 wr2 rr2b rr2b rr2b 00011 wr3b rr3b rr3b rr3b 00100 wr4b (rr0b) (rr0b) (wr4b) 00101 wr5b (rr1b) (rr1b) (wr5b) 00110 wr6b (rr2b) rr6b rr6b 00111 wr7b (rr3b) rr7b rr7b 01000 wr8b rr8b rr8b rr8b 01001 wr9 (rr13b) (rr13b) (wr3b) 01010 wr10b rr10b rr10b rr10b 01011 wr11b (rr15b) (rr15b) (wr10b) 01100 wr12b rr12b rr12b rr12b 01101 wr13b rr13b rr13b rr13b 01110 wr14b rr14b rr14b (wr7?) 01111 wr15b rr15b rr15b rr15b 10000 wr0a rr0a rr0a rr0a 10001 wr1a rr1a rr1a rr1a 10010 wr2 rr2a rr2a rr2a 10011 wr3a rr3a rr3a rr3a 10100 wr4a (rr0a) (rr0a) (wr4a) 10101 wr5a (rr1a) (rr1a) (wr5a) 10110 wr6a (rr2a) rr6a rr6a 10111 wr7a (rr3a) rr7a rr7a 11000 wr8a rr8a rr8a rr8a 11001 wr9 (rr13a) (rr13a) (wr3a) 11010 wr10a rr10a rr10a rr10a 11011 wr11a (rr15a) (rr15a) (wr10a) 11100 wr12a rr12a rr12a rr12a 11101 wr13a rr13a rr13a rr13a 11110 wr14a rr14a rr14a (wr7?) 11111 wr15a rr15a rr15a rr15a notes: the register names in ( ) are the values read out from that register location. wr15, bit d2 enables status fifo function (not available on nmos). wr7' bit d6 enables extend read function (only on escc). * includes 80c30/230 when wr15 d2=0. scc /escc user? manual interfacing the scc/escc 2-7 2 table 2-2. z80x30 register map (shift right mode) ad4 ad3 ad2 ad1 ad0 write read 8030 80c30/230* wr15 d2 = 0 80c30/230 wr15 d2=1 80230 wr15 d2=1 wr7' d6=1 00000 wr0b rr0b rr0b rr0b 00001 wr0a rr0a rr0a rr0a 00010 wr1b rr1b rr1b rr1b 00011 wr1a rr1a rr1a rr1a 00100 wr2 rr2b rr2b rr2b 00101 wr2 rr2a rr2a rr2a 00110 wr3b rr3b rr3b rr3b 00111 wr3a rr3a rr3a rr3a 01000 wr4b (rr0b) (rr0b) (wr4b) 01001 wr4a (rr0a) (rr0a) (wr4a) 01010 wr5b (rr1b) (rr1b) (wr5b) 01011 wr5a (rr1a) (rr1a) (wr5a) 01100 wr6b (rr2b) rr6b rr6b 01101 wr6a (rr2a) rr6a rr6a 01110 wr7b (rr3b) rr7b rr7b 01111 wr7a (rr3a) rr7a rr7a 10000 wr8b rr8b rr8b rr8b 10001 wr8a rr8a rr8a rr8a 10010 wr9 (rr13b) (rr13b) (wr3b) 10011 wr9 (rr13a) (rr13a) (wr3a) 10100 wr10b rr10b rr10b rr10b 10101 wr10a rr10a rr10a rr10a 10110 wr11b (rr15b) (rr15b) (wr10b) 10111 wr11a (rr15a) (rr15a) (wr10a) 11000 wr12b rr12b rr12b rr12b 11001 wr12a rr12a rr12a rr12a 11010 wr13b rr13b rr13b rr13b 11011 wr13a rr13a rr13a rr13a 11100 wr14b rr14b rr14b (wr7?) 11101 wr14a rr14a rr14a (wr7?) 11110 wr15b rr15b rr15b rr15b 11111 wr15a rr15a rr15a rr15a notes: the register names in ( ) are the values read out from that register location. wr15 bit d2 enables status fifo function (not available on nmos). wr7' bit d6 enables extend read function (only on escc). * includes 80c30/230 when wr15 d2=0. scc /escc user? manual interfacing the scc/escc 2-8 2.2 z80x30 interface timing (continued) 2.2.5 z80c30 register enhancement the z80c30 has an enhancement to the nmos z8030 register set, which is the addition of a 10x19 sdlc frame status fifo. when wr15 bit d2=1, the sdlc frame sta- tus fifo is enabled, and it changes the functionality of rr6 and rr7. see section 4.4.3 for more details on this feature. 2.2.6 z80230 register enhancements in addition to the z80c30 enhancements, the 80230 has several enhancements to the scc register set. these in- clude the addition of write register 7 prime (wr7'), and the ability to read registers that are read only in the 8030. write register 7' is addressed by setting wr15 bit, d0=1 and then addressing wr7. figure 2-4 shows the register bit location of the six features enabled through this register. all writes to address seven are to wr7' when wr15, d0=1. refer to chapter 5 for detailed information on wr7'. wr7' bit d6=1, enables the extended read register capa- bility. this allows the user to read the contents of wr3, wr4, wr5, wr7' and wr10 by reading rr9, rr4, rr5, rr14 and rr11, respectively. when wr7' d6=0, these write registers are write only. table 2-3 shows what functions are enabled for the various combinations of register bit enables. see table 2-1 (shift left) and table 2-2 (shift right) for the register address map with the sdlc fifo enabled only and the map with both the extended read and sdlc fifo features enabled. figure 2-4. write register 7 prime (wr7') d7 d6 d5 d4 d3 d2 d1 d0 wr7' auto tx flag auto eom reset auto rts turnoff rx fifo half full dtr/req timing m tx fifo empty external read ena b 0 table 2-3. z80230 sdlc/hdlc enhancement options wr15 wr7' bit d2 bit d0 bit d6 functions enabled 0 1 0 wr7' enabled only 0 1 1 wr7' with extended read enabled 1 0 x 10x19 sdlc fifo enhancement enabled only 1 1 0 10x19 sdlc fifo and wr7' 10x19 sdlc fifo and wr7' 111 with extended read enabled scc /escc user? manual interfacing the scc/escc 2-9 2 2.2.7 z80x30 reset the z80x30 may be reset by either a hardware or software reset. hardware reset occurs when /as and /ds are both low at the same time, which is normally an illegal condi- tion. as long as both /as and /ds are low, the z80x30 recognizes the reset condition. however, once this condi- tion is removed, the reset condition is asserted internally for an additional four to five pclk cycles. during this time, any attempt to access is ignored. the z80x30 has three software resets that are encoded into two command bits in wr9. there are two channel re- sets, which only affect one channel in the device and some bits of the write registers. the command forces the same result as the hardware reset, the z80x30 stretches the reset signal an additional four to five pclk cycles be- yond the ordinary valid access recovery time. the bits in wr9 may be written at the same time as the reset com- mand because these bits are affected only by a hardware reset. the reset values of the various registers are shown in table 2-4. table 2-4. z80x30 register reset values hardware reset channel reset 76543210 76543210 wr0 00000000 00000000 wr1 00x00x00 00x00x00 wr2 xxxxxxxx xxxxxxxx wr3 xxxxxxx0 xxxxxxx0 wr4 xxxxx1xx xxxxx1xx wr5 0xx0000x 0xx0000x wr6 xxxxxxxx xxxxxxxx wr7 xxxxxxxx xxxxxxxx wr7'* 00100000 00100000 wr9 110000xx xx0 xxxxx wr10 00000000 0xx00000 wr11 00001000 xxxxxxxx wr12 xxxxxxxx xxxxxxxx wr13 xxxxxxxx xxxxxxxx wr14 x x 110000 xx1000xx wr15 11111000 11111000 rr0 x1xxx1 0 0 x1xxx1 0 0 rr1 0000011x 0000011x rr3 00000000 00000000 rr10 0 x 000000 0x000000 notes: *wr7' is available only on the z80230. scc /escc user? manual interfacing the scc/escc 2-10 2.3 z85x30 interface timing two control signals, /rd and /wr, are used by the z85x30 to time bus transactions. in addition, four other control signals, /ce, d//c, a//b and /intack, are used to control the type of bus transaction that occurs. a bus trans- action starts when the addresses on d//c and a//b are as- serted before /rd or /wr fall (ac spec #6 and #8). the coincidence of /ce and /rd or /ce and /wr latches the state of d//c and a//b and starts the internal operation. the /intack signal must have been previously sampled high by a rising edge of pclk for a read or write cycle to occur. in addition to sampling /intack, pclk is used by the interrupt section to set the ip bits. the z85x30 generates internal control signals in response to a register access. since /rd and /wr have no phase re- lationship with pclk, the circuitry generating these inter- nal control signals provides time for metastable conditions to disappear. this results in a recovery time related to pclk. this recovery time applies only between transactions in- volving the z85x30, and any intervening transactions are ignored. this recovery time is four pclk cycles (ac spec #49), measured from the falling edge of /rd or /wr in the case of a read or write of any register. 2.3.1 z85x30 read cycle timing the read cycle timing for the z85x30 is shown in figure 2-5. the address on a//b and d//c is latched by the coincidence of /rd and /ce active. /ce must remain low and /intack must remain high throughout the cycle. the z85x30 bus drivers are enabled while /ce and /rd are both low. a read with d//c high does not disturb the state of the pointers and a read cycle with d//c low resets the pointers to zero after the internal operation is complete . figure 2-5. z85x30 read cycle timing a//b, d//c /intack /ce /rd d7-d0 address valid data valid scc /escc user? manual interfacing the scc/escc 2-11 2 2.3.2 z85x30 write cycle timing the write cycle timing for the z85x30 is shown in figure 2- 6. the address on a//b and d//c, as well as the data on d7-d0, is latched by the coincidence of /wr and /ce ac- tive. /ce must remain low and /intack must remain high throughout the cycle. a write cycle with d//c high does not disturb the state of the pointers and a write cycle with d//c low resets the pointers to zero after the internal operation is complete. historically, the nmos/cmos version latched the data bus on the falling edge of /wr. however, many cpus do not guarantee that the data bus is valid at the time when the /wr pin goes low, so the data bus timing was modified to allow a maximum delay from the falling edge of /wr to the latching of the data bus. on the z85230, the ac timing parameter #29 tsdw(wr), write data to /wr falling min- imum, has been changed to: /wr falling to write data val- id maximum. refer to the ac timing characteristic section of the z85230 product specification for more information regarding this change. 2.3.3 z85x30 interrupt acknowledge cycle timing the interrupt acknowledge cycle timing for the z85x30 is shown in figure 2-7. the state of /intack is latched by the rising edge of pclk (ac spec #10). while /intack is low, the state of a//b, /ce, d//c, and /wr are ignored. figure 2-6. z85x30 write cycle timing a//b, d//c /intack /ce /wr d7-d0 address valid data valid see note note: dotted line is escc only. figure 2-7. z85x30 interrupt acknowledge cycle timing /intack /rd d7-d0 vector scc /escc user? manual interfacing the scc/escc 2-12 2.3 z85x30 interface timing (continued) between the time /intack is first sampled low and the time /rd falls, the internal and external iei/ieo daisy chain settles (ac parameter #38 tdiai(rd) note 5). a system with no external daisy chain must provide the time speci- fied in ac spec #38 to settle the interrupt daisy chain pri- ority internal to the scc. systems using the external iei/ieo daisy chain should refer to note 5 referenced in the z85x30 read/write and interrupt acknowledge timing for the time required to settle the daisy chain. note: /intack is sampled on the rising edge of pclk. if it does not meet the setup time to the first rising edge of pclk of the interrupt acknowledge cycle, it is latched on the next rising edge of pclk. therefore, if /intack is asynchronous to pclk, it may be necessary to add a pclk cycle to the calculation for /intack to /rd delay time. if there is an interrupt pending in the z85x30, and iei is high when /rd falls, the interrupt acknowledge cycle was intended for the z85x30. in this case, the z85x30 sets the appropriate interrupt-under-service latch, and places an interrupt vector on d7-d0. if the falling edge of /rd sets an ius bit in the z85x30, the /int pin goes inactive in response to the falling edge. note that there should be only one /rd per acknowledge cycle. note 1: the ip bits in the z85x30 are updated by pclk. however, when the register pointer is pointing to rr2 and rr3, the ip bits are prevented from changing. this pre- vents data changing during a read, but will delay interrupt requests if the pointers are left pointing at these registers. note 2: the scc should only receive one intack signal per acknowledge cycle. therefore, if the cpu generates more than one (as is common for the 80x86 family), an ex- ternal circuit should be used to convert this into a single pulse or does not use interrupt acknowledge. 2.3.4 z85x30 register access the registers in the z85x30 are accessed in a two step process, using a register pointer to perform the address- ing. to access a particular register, the pointer bits are set by writing to wr0. the pointer bits may be written in either channel because only one set exists in the z85x30. after the pointer bits are set, the next read or write cycle of the z85x30 having d//c low will access the desired register. at the conclusion of this read or write cycle the pointer bits are reset to 0s, so that the next control write is to the point- ers in wr0. a read to rr8 (the receive data fifo) or a write to wr8 (the transmit data fifo) is either done in this fashion or by accessing the z85x30 having d//c pin high. a read or write with d//c high accesses the data registers directly, and independently of the state of the pointer bits. this al- lows single-cycle access to the data registers and does not disturb the pointer bits. the fact that the pointer bits are reset to 0, unless explicitly set otherwise, means that wr0 and rr0 may also be ac- cessed in a single cycle. that is, it is not necessary to write the pointer bits with 0 before accessing wr0 or rr0. there are three pointer bits in wr0, and these allow ac- cess to the registers with addresses 7 through 0. note that a command may be written to wr0 at the same time that the pointer bits are written. to access the registers with ad- dresses 15 through 8, the point high command must ac- company the pointer bits. this precludes concurrently is- suing a command when pointing to these registers. the register map for the z85x30 is shown in table 2-5. if, for some reason, the state of the pointer bits is unknown they may be reset to 0 by performing a read cycle with the d//c pin held low. once the pointer bits have been set, the desired channel is selected by the state of the a//b pin dur- ing the actual read or write of the desired register. scc /escc user? manual interfacing the scc/escc 2-13 2 table 2-5. z85x30 register map a//b pnt2 pnt1 pnt0 write read 8530 85c30/230 wr15 d2 = 0 85c30/230 wr15 d2=1 wr15 d2=1 wr7' d6=1 0000 wr0b rr0b rr0b rr0b 0001 wr1b rr1b rr1b rr1b 0010 wr2 rr2b rr2b rr2b 0011 wr3b rr3b rr3b rr3b 0100 wr4b (rr0b) (rr0b) (wr4b) 0101 wr5b (rr1b) (rr1b) (wr5b) 0110 wr6b (rr2b) rr6b rr6b 0111 wr7b (rr3b) rr7b rr7b 1000 wr0a rr0a rr0a rr0a 1001 wr1a rr1a rr1a rr1a 1010 wr2 rr2a rr2a rr2a 1011 wr3a rr3a rr3a rr3a 1100 wr4a (rr0a) (rr0a) (wr4a) 1101 wr5a (rr1a) (rr1a) (wr5a) 1110 wr6a (rr2a) rr6a rr6a 1111 wr7a (rr3a) rr7a rr7a with point high command 0000 wr8b rr8b rr8b rr8b 0001 wr9 (rr13b) (rr13b) (wr3b) 0010 wr10b rr10b rr10b rr10b 0011 wr11b (rr15b) (rr15b) (wr10b) 0100 wr12b rr12b rr12b rr12b 0101 wr13b rr13b rr13b rr13b 0110 wr14b rr14b rr14b (wr7?) 0111 wr15b rr15b rr15b rr15b 1000 wr8a rr8a rr8a rr8a 1001 wr9 (rr13a) (rr13a) (wr3a) 1010 wr10a rr10a rr10a rr10a 1011 wr11a (rr15a) (rr15a) (wr10a) 1100 wr12a rr12a rr12a rr12a 1101 wr13a rr13a rr13a rr13a 1110 wr14a rr14a rr14a (wr7?) 1111 wr15a rr15a rr15a rr15a notes: wr15 bit d2 enables status fifo function. (not available on nmos) wr7' bit d6 enables extend read function. (only on escc and 85c30) scc /escc user? manual interfacing the scc/escc 2-14 2.3 z85x30 interface timing (continued) 2.3.5 Z85C30 register enhancement the Z85C30 has an enhancement to the nmos z8530 register set, which is the addition of a 10x19 sdlc frame status fifo. when wr15 bit d2=1, the sdlc frame sta- tus fifo is enabled, and it changes the functionality of rr6 and rr7. see section 4.4.3 for more details on this feature. 2.3.6 Z85C30/z85230 register enhancements in addition to the enhancements mentioned in 2.3.5, the 85c30/85230 provides several enhancements to the scc register set. these include the addition of write register 7 prime (wr7'), the ability to read registers that are write- only in the scc. write register 7' is addressed by setting wr15, d0=1 and then addressing wr7. figure 2-8 shows the register bit lo- cation of the six features enabled through this register for the 85230, while figure 2-7 shows the register bit location for the 85c30. note that the difference between the two wr7' registers for the 85230 and the 85c30 is bit d5 and bit d4. all writes to address seven are to wr7' when wr15 d0=1. refer to chapter 5 for detailed information on wr7'. setting wr7' bit d6=1 enables the extended read register capability. this allows the user to read the contents of wr3, wr4, wr5, wr7' and wr10 by reading rr9, rr4, rr5, rr14 and rr11, respectively. when wr7' d6=0, these write registers are write-only. table 2-6 shows what functions are enabled for the vari- ous combinations of register bit enables. see table 2-5 for the register address map with only the sdlc fifo en- abled and with both the extended read and sdlc fifo features enabled. figure 2-8a. write register 7 prime (wr7') for the 85230 d7 d6 d5 d4 d3 d2 d1 d0 wr7' auto tx flag auto eom reset auto/rts deactivation rx fifo half full dtr/req timing mode tx fifo empty extended read enable reserved (must be 0) figure 2-8b. write register 7 prime for the 85c30 table 2-6. Z85C30/z85230 register enhancement options wr15 wr7' bit d2 bit d0 bit d6 functions enabled 0 1 0 wr7' enabled only 0 1 1 wr7' with extended read enabled 1 0 x 10x19 sdlc fifo enhancement enabled only 1 1 0 10x19 sdlc fifo and wr7' 1 1 1 10x19 sdlc fifo and wr7' with extended read enabled d7 d6 d5 d4 d3 d2 d1 d0 wr7' prime auto tx flag auto eom reset auto/rts deactivation force txd high /dtr//req fast mode complete crc reception extended read enable reserved (program as 0) scc /escc user? manual interfacing the scc/escc 2-15 2 2.3.7 z85x30 reset the z85x30 may be reset by either a hardware or software reset. hardware reset occurs when /wr and /rd are both low at the same time, which is normally an illegal condi- tion. as long as both /wr and /rd are low, the z85x30 recognizes the reset condition. however, once this condi- tion is removed, the reset condition is asserted internally for an additional four to five pclk cycles. during this time any attempt to access is ignored. the z85x30 has three software resets that are encoded into the command bits in wr9. there are two channel re- sets which only affect one channel in the device and some bits of the write registers. the command forces the same result as the hardware reset, the z85x30 stretches the reset signal an additional four to five pclk cycles be- yond the ordinary valid access recovery time. the bits in wr9 may be written at the same time as the reset com- mand because these bits are affected only by a hardware reset. the reset values of the various registers are shown in table 2-7. 2.4 interface programming the following subsections explain and illustrate all areas of interface programming. 2.4.1 i/o programming introduction the scc can work with three basic forms of i/o opera- tions: polling, interrupts, and block transfer. all three i/o types involve register manipulation during initialization and data transfer. however, the interrupt mode also incorpo- rates z-bus interrupt protocol for a fast and efficient data transfer. regardless of the version of the scc, all communication modes can use a choice of polling, interrupt and block transfer. these modes are selected by the user to deter- mine the proper hardware and software required to supply data at the rate required. note to escc users: those familiar with the nmos/cmos version will find the escc i/o operations very similar but should note the following differences: the addition of soft- ware acknowledge (which is available in the current version of the cmos scc, but not in nmos); the /dtr//req pin can be programmed to be deasserted faster; and the pro- grammability of the data interrupts to the fifo fill level. table 2-7. z85x30 register reset value hardware reset channel reset 76543210 76543210 wr000000000 00000000 wr100x00x00 00x00x00 wr2xxxxxxxx xxxxxxxx wr3xxxxxxx0 xxxxxxx0 wr4xxxxx1xx xxxxx1xx wr50xx0000x 0xx0000x wr6xxxxxxxx xxxxxxxx wr7xxxxxxxx xxxxxxxx wr7'* 00100000 00100000 wr9110000xx xx0 xxxxx wr10 00000000 0xx00000 wr11 00001000 xxxxxxxx wr12 xxxxxxxx xxxxxxxx wr13 xxxxxxxx xxxxxxxx wr14 x x 110000 xx1000xx wr15 11111000 11111000 rr0x1xxx1 0 0 x1xxx1 0 0 rr10000011x 0000011x rr300000000 00000000 rr10 0 x 000000 0x000000 notes: *wr7' is only available on the 85c30 and the escc. scc /escc user? manual interfacing the scc/escc 2-16 2.4 interface programming (continued) 2.4.2 polling this is the simplest mode to implement. the software must poll the scc to determine when data is to be input or out- put from the scc. in this mode, mie (wr9, bit 3), and wait/dma request enable (wr1, bit 7) are both reset to 0 to disable any interrupt or dma requests. the software must then poll rr0 to determine the status of the receive buffer, transmit buffer and external status. during a polling sequence, the status of read register 0 is examined in each channel. this register indicates whether or not a receive or transmit data transfer is need- ed and whether or not any special conditions are present, e.g., errors. this method of i/o transfer avoids interrupts and, conse- quently, all interrupt functions should be disabled. with no interrupts enabled, this mode of operation must initiate a read cycle of read register 0 to detect an incoming char- acter before jumping to a data handler routine. 2.4.3 interrupts each of the scc? two channels contain three sources of interrupts, making a total of six interrupt sources. these three sources of interrupts are: 1) receiver, 2) transmit- ter, and 3) external/status conditions. in addition, there are several conditions that may cause these interrupts. figure 2-9 shows the different conditions for each interrupt source and each is enabled under program control. chan- nel a has a higher priority than channel b with receive, transmit, and external/status interrupts prioritized, re- spectively, within each channel as shown in table 2-8. the scc internally updates the interrupt status on every pclk cycle in the z85x30 and on /as in the z80x30. table 2-8. interrupt source priority receive channel a highest transmit channel a external/status channel a receive channel b transmit channel b external/status channel b lowest figure 2-9. escc interrupt sources scc interrupt receiver interrupt sources zero count transmit buffer empty parity error (if enabled) end of frame (sdlc) framing error receive overrun dcd sync/hunt cts tx underrun/eom break/abort transmitter interrupt source external/status interrupt sources int on all rx character or special condition rx interrupt on special condition only int on first rx character or special condition receive character available scc /escc user? manual interfacing the scc/escc 2-17 2 escc: the receive interrupt request is either caused by a re- ceive character available or a special condition. when the receive character available interrupt is generated, it is dependent on wr7' bit d3. if wr7' d3=0, the re- ceive character available interrupt is generated when one character is loaded into the fifo and is ready to be read. if wr7' d3=1, the receive character available interrupt is generated when four bytes are available to be read in the receive data fifo. the programmed val- ue of wr7' d5 also affects how dma requests are gen- erated. see section 2.5 for details. note: if the escc is used in sdlc mode, it enables the sdlc status fifo to affect how receive interrupts are generated. if this feature is used, read section 4.4.3 on the sdlc anti-lock feature. the special conditions are receive fifo overrun, crc/framing error, end of frame, and parity. if parity is in- cluded as a special condition, it is dependent on wr1 d2. the special condition status can be read from rr1. on the nmos/cmos versions, set the ip bit whenever the transmit buffer becomes empty. this means that the trans- mit buffer was full before the transmit ip can be set. escc: the transmit interrupt request has only one source and is dependent on wr7' d5. if the ip bit wr7' d5=0, it is set when the transmit buffer becomes completely empty. if ip bit wr7' d5=1, the transmit interrupt is generated when the entry location of the fifo is emp- ty. note that in both cases the transmit interrupt is not set until after the first character is written to the escc. for more information on transmit interrupts, see section 2.4.8 for details. the external/status interrupts have several sources which may be individually enabled in wr15. the sources are zero count, /dcd, sync/hunt, /cts, transmitter under- run/eom and break/abort. 2.4.4 interrupt control in addition to the mie bit that enables or disables all scc interrupts, each source of interrupt in the scc has three control/status bits associated with it. they are the interrupt enable (ie), interrupt pending (ip), and interrupt-under- service (ius). figure 2-10 shows the scc interrupt structure. figure 2-11 shows the internal priority resolution method to allow the highest priority interrupt to be serviced first. lower priority devices on the external daisy chain can be prevented from requesting interrupts via the disable lower chain bit in wr9 d2. figure 2-10. peripheral interrupt structure ie interrupt vector from cpu status decoder mie dlc ip ius iei /int ieo /intack from pullup resistor or ieo line of highe r priority device to cpu to iei input of lower priority device figure 2-11. internal priority resolution ie channel a receiver (highest priority) from iei pin ius ip ie channel a transmitter ius ip iei ieo iei ieo ie channel a external/status conditions ius ip iei ieo ie channel b receiver ius ip ie channel b transmitter ius ip iei ieo iei ieo ie channel b external/status conditions (lowest priority) ius ip iei ieo to ieo pin scc /escc user? manual interfacing the scc/escc 2-18 2.4 interface programming (continued) 2.4.4.1 master interrupt enable bit the master interrupt enable (mie) bit, wr9 d3, must be set to enable the scc to generate interrupts. the mie bit should be set after initializing the scc registers and en- abling the individual interrupt enables. the scc requests an interrupt by asserting the /int pin low from its open- drain state only upon detection that one of the enabled in- terrupt conditions has been detected. 2.4.4.2 interrupt enable bit the interrupt enable (ie) bits control interrupt requests from each interrupt source on the scc. if the ie bit is set to 1 for an interrupt source, that source may generate an interrupt request, providing all of the necessary conditions are met. if the ie bit is reset, no interrupt request is gener- ated by that source. the transmit interrupt ie bit is wr1 d1. the receive interrupt ie bits are wr1 d3 and d4. the external status interrupts are individually enabled in wr15 with the master external status interrupt enable in wr1 d0. reminder: the mie bit, wr9 d3, must be set for any interrupt to occur. 2.4.4.3 interrupt pending bit the interrupt pending (ip) bit for a given source of interrupt is set by the presence of an interrupt condition in the scc. it is reset directly by the processor, or indirectly by some action that the processor may take. if the corresponding ie bit is not set, the ip for that source of interrupt will never be set. the ip bits in the scc are read only via rr3 as shown in figure 2-12. 2.4.4.4 interrupt-under-service bit the interrupt-under-service (ius) bits are completely hid- den from the processor. an ius bit is set during an inter- rupt acknowledge cycle for the highest priority ip. on the cmos or escc, the ius bits can be set by either a hard- ware acknowledge cycle with the /intack pin or through software if wr9 d5=1 and then reading rr2. the ius bits control the operation of internal and external daisy-chain interrupts. the internal daisy chain links the six sources of interrupt in a fixed order, chaining the ius bit of each source. if an internal ius bit is set, all lower pri- ority interrupt requests are masked off; during an interrupt acknowledge cycle the ip bits are also gated into the daisy chain. this ensures that the highest priority ip selected has its ius bit set. at the end of an interrupt service rou- tine, the processor must issue a reset highest ius com- mand in wr0 to re-enable lower priority interrupts. this is the only way, short of a software or hardware reset, that an ius bit may be reset. note: it is not necessary to issue the reset highest ius command in the interrupt service routine, since the ius bits can only be set by an interrupt acknowledge if no hard- ware acknowledge or software acknowledge cycle (not with nmos) is executed. the only exception is when the sdlc frame status fifo (not with nmos) is enabled and ?eceive interrupt on special condition only?is used. see section 4.4.3 for more details on this mode. 2.4.4.5 disable lower chain bit the disable lower chain (dlc) bit in wr9 (d2) is used to disable all peripherals in a lower position on the external daisy chain. if wr9 d2=1, the ieo pin is driven low and prevents lower priority devices from generating an inter- rupt request. note that the ius bit, when set, will have the same effect, but is not controllable through software. figure 2-12. rr3 interrupt pending bits d7 d6 d5 d4 d3 d2 d1 d0 channel b ext/stat read register 3 channel b tx ip channel b rx ip channel a ext/stat channel a tx ip channel a rx ip 0 0 * always 0 in b channel scc /escc user? manual interfacing the scc/escc 2-19 2 2.4.5 daisy-chain resolution the six sources of interrupt in the scc are prioritized in a fixed order via a daisy chain; provision is made, via the iei and ieo pins, for use of an external daisy chain as well. all channel a interrupts are higher priority than any channel b interrupts, with the receiver, transmitter, and external/status interrupts prioritized in that order within each channel. the scc requests an interrupt by pulling the /int pin low from its open-drain state. this is con- trolled by the ip bits and the iei input, among other things. a flowchart of the interrupt sequence for the scc is shown in figure 2-13. the internal daisy chain links the six sources of interrupt in a fixed order, chaining the ius bits for each source. while an ius bit is set, all lower priority interrupt requests are masked off, thus preventing lower priority interrupts, but still allowing higher priority interrupts to occur. also, during an interrupt acknowledge cycle the ip bits are gated into the daisy chain. this insures that the highest priority ip is selected to set ius. the internal daisy chain may be con- trolled by the mie bit in wr9. this bit, when reset, has the same effect as pulling the iei pin low, thus disabling all in- terrupt requests. 2.4.5.1 external daisy-chain operations the scc generates an interrupt request by pulling /int low, but only if such interrupt requests are enabled (ie is 1, mie is 1) and all of the following conditions occur: n ip is set without a higher priority ius being set n no higher priority ius is being set n no higher priority interrupt is being serviced (iei is high) n no interrupt acknowledge transaction is taking place ieo is not pulled low by the scc at this time, but instead continues to follow iei until an interrupt acknowledge transaction occurs. some time after /int has been pulled low, the processor initiates an interrupt acknowledge transaction. between the time the scc recognizes that an interrupt acknowledge cycle is in progress and the time during the acknowledge that the processor requests an in- terrupt vector, the iei/ieo daisy chain settles. any periph- eral in the daisy chain having an interrupt pending (ip is 1) or an interrupt-under-service (ius is 1) holds its ieo line low and all others make ieo follow iei. when the processor requests an interrupt vector, only the highest priority interrupt source with a pending interrupt (ip is 1) has its iei input high, its ie bit set to 1, and its ius bit set to 0. this is the interrupt source being acknowl- edged, and at this point it sets its ius bit to 1. if its nv bit is 0, the scc identifies itself by placing the interrupt vector from wr2 on the data bus. if the nv bit is 1, the scc data bus remains floating, allowing external logic to supply a vector. if the vis bit in the scc is 1, the vector also con- tains status information, encoded as shown in table 2-9, which further describes the nature of the scc interrupt. if the vis bit is 0, the vector held in wr2 is returned without modification. if the scc is programmed to include status information in the vector, this status may be encoded and placed in either bits 1-3 or in bits 4-6. this operation is selected by programming the status high/status low bit in wr9. at the end of the interrupt service routine, the processor should issue the reset highest ius command to unlock the daisy chain and allow lower priority interrupt requests. the ip is reset during the interrupt service routine, either directly by command or indirectly through some action taken by the processor. the external daisy chain may be controlled by the dlc bit in wr9. this bit, when set, forces ieo low, disabling all lower priority devices. table 2-9. interrupt vector modi?ation v3 v2 v1 status high/status low = 0 v4 v5 v6 status high/status low = 1 0 0 0 ch b transmit buffer empty 0 0 1 ch b external/status change 0 1 0 ch b receive character avail 0 1 1 ch b special receive condition 1 0 0 ch a transmit buffer empty 1 0 1 ch a external/status change 1 1 0 ch a receive character avail 1 1 1 ch a special receive condition scc /escc user? manual interfacing the scc/escc 2-20 2.4 interface programming (continued) figure 2-13. interrupt flow chart (for each interrupt source). start interrupt pendi set (ip=1) master interrupt enabl e (mie=1)? is peripheral enable pin ac t (iei=h)? ye s unit selected for cp u service (ius=1) interrupt condition exits? specific interrupt enabl e (iex=1)? peripheral request interrupt (int=l) iei/ieo daisy chai n settles (wait for d s cpu initiates statu decode (intack= l has higher priority periphera disabled unit? (iei=l) yes cpu services high e priority peripher a priority service complete? interrupt still pending (ip=1) ? service routine compl e ? ye s (option) check oth e internal ip, bits, reset ius and ex n o ye s ye s no no n o ye s ye s n o n o n o n o ye s scc /escc user? manual interfacing the scc/escc 2-21 2 2.4.6 interrupt acknowledge the scc is flexible with its interrupt method. the interrupt may be acknowledged with a vector transferred, acknowl- edged without a vector, or not acknowledged at all. 2.4.6.1 interrupt without acknowledge in this mode, the interrupt acknowledge signal does not have to be generated. this allows a simpler hardware de- sign that does not have to meet the interrupt acknowledge timing. soon after the int goes active, the interrupt con- troller jumps to the interrupt routine. in the interrupt routine, the code must read rr2 from channel b to read the vector including status. when the vector is read from channel b, it always includes the status regardless of the vis bit (wr9 bit 0). the status given will decode the highest priority in- terrupt pending at the time it is read. the vector is not latched so that the next read could produce a different vec- tor if another interrupt occurs. the register is disabled from change during the read operation to prevent an error if a higher interrupt occurs exactly during the read operation. once the status is read, the interrupt routine must decode the interrupt pending, and clear the condition. removing the interrupt condition clears the ip and brings /int inac- tive (open-drain), as long as there are no other ip bits set. for example, writing a character to the transmit buffer clears the transmit buffer empty ip. when the interrupt ip, decoded from the status, is cleared, rr2 can be read again. this allows the interrupt routine to clear all of the ip? within one interrupt request to the cpu. 2.4.6.2 interrupt with acknowledge after the scc brings /int active, the cpu can respond with a hardware acknowledge cycle by bringing /intack active. after enough time has elapsed to allow the daisy chain to settle (see ac spec #38), the scc sets the ius bit for the highest priority ip. if the no vector bit is reset (wr9 d1=0), the scc then places the interrupt vector on the data bus during a read. to speed the interrupt re- sponse time, the scc can modify 3 bits in the vector to in- dicate the source of the interrupt. to include the status, the vis bit, wr9 d0, is set. the service routine must then clear the interrupting condition. for example, writing a character to the transmit buffer clears the transmit buffer empty ip. after the interrupting condition is cleared, the routine can read rr3 to determine if any other ip? are set and take the appropriate action to clear them. at the end of the interrupt routine, a reset ius command (wr0) is is- sued to unlock the daisy chain and allow lower-priority in- terrupt requests. this is the only way, short of a software or hardware reset, that an ius bit is reset. if the no vector bit is set (wr9 d1=1), the scc will not place the vector on the data bus. an interrupt controller must then vector the code to the interrupt routine. the in- terrupt routine reads rr2 from channel b to read the sta- tus. this is similar to an interrupt without an acknowledge, except the ius is set and the vector will not change until the reset ius command in rr0 is issued. 2.4.6.3 software interrupt acknowledge (cmos/escc) an interrupt acknowledge cycle can be done in software for those applications which use an external interrupt con- troller or which cannot generate the /intack signal with the required timing. if wr9 d5 is set, reading register two, rr2, results in an interrupt acknowledge cycle to be exe- cuted internally. like a hardware intack cycle, a software acknowledge causes the /int pin to return high, the ieo pin to go low and the ius latch to be set for the highest priority interrupt pending. as when the hardware /intack signal is used, a software acknowledge cycle requires that a reset highest ius command be issued in the interrupt service routine. if rr2 is read from channel a, the unmodified vector is returned. if rr2 is read from channel b, then the vector is modified to indicate the source of the interrupt. the vector includes status (vis) and no vector (nv) bits in wr9 are ignored when bit d5 is set to 1. 2.4.7 the receiver interrupt the sources of receive interrupts consist of receive char- acter available and special receive condition. the spe- cial receive condition can be subdivided into receive overrun, framing error (asynchronous) or end of frame (sdlc). in addition, a parity error can be a special receive condition by programming. as shown in figure 2-14, receive interrupt mode is controlled by three bits in wr1. two of these bits, d4 and d3, select the interrupt mode; the third bit, d2, is a modifier for the various modes. on the escc, wr7' bit d2 affects the receiver interrupt operation mode as well. if the interrupt capability of the receiver in the scc is not required, polling may be used. this is selected by disabling receive interrupts and polling the receiver character available bit in rr0. when this bit indicates that a received character has reached the exit location (cpu side) of the fifo, the status in rr1 should be checked and then the data should be read. if status is checked, it must be done before the data is read, because the act of reading the data pops both the data and error fifos. another way of polling scc is to enable one of the interrupt modes and then reset the mie bit in wr9. the processor may then poll the ip bits in rr3a to determine when receive characters are available. scc /escc user? manual interfacing the scc/escc 2-22 2.4 interface programming (continued) 2.4.7.1 receive interrupt on the escc on the escc, one other bit, wr7' bit d2, also affects the interrupt operation. wr7' d3=0, a receive interrupt is generated when one byte is available in the fifo. this mode is selected after reset and maintains compatibility with the scc. systems with a long interrupt response time can use this mode to generate an interrupt when one byte is received, but still al- low up to seven more bytes to be received without an over- run error. by polling the receive character available bit, rr0 d0, and reading all available data to empty the fifo before exiting the interrupt service routine, the frequency of interrupts can be minimized. wr7' d3=1, the escc generates an interrupt when there are four bytes in the receive fifo or when a special con- dition is received. by setting this bit, the escc generates a receive interrupt when four bytes are available to read from the fifo. this allows the cpu not to be interrupted until at least four bytes can be read from the fifo, thereby minimizing the frequency of receive interrupts. if four or more bytes remain in the fifo when the reset highest ius command is issued at the end of the service routine, another receive interrupt is generated. when a special receive condition is detected in the top four bytes, a special receive condition interrupt is generated immediately. this feature is intended to be used with the interrupt on all receive characters and special condition mode. this is especially useful in sdlc mode because the characters are contiguous and the reception of the closing flag immediately generates a special receive interrupt. the generation of receive interrupts is described in the follow- ing two cases: case 1: four bytes received with no errors. a receive character available interrupt is triggered when the four bytes in receive data fifo (from the exit side) are full and no special conditions have been detected. there- fore, the interrupt service routine can read four bytes from the data fifo without having to read rr1 to check for error conditions. case 2: data received with error conditions. when any of the four bytes from the exit side in the receive error fifo indicate an error has been detected, a special receive condition interrupt is triggered without waiting for the byte to reach the top of the fifo. in this case, the interrupt ser- vice routine must read rr1 first before reading each data byte to determine which byte has the special receive con- dition and then take the appropriate action. since, in this mode, the status must be checked before the data is read, the data fifo is not locked and the error reset command is not necessary. note: the above cases assume that the receive ius bit is reset to zero in order for an interrupt to be generated. wr7' d3 should be written zero when using interrupt on first character and special condition or interrupt on spe- cial condition only. see the description for interrupt on all characters or special condition mode for more details on this feature. note: the receive character available status bit, rr0 d0, indicates if at least one byte is available in the receive fifo, independent of wr7' d3. therefore, this bit can be polled at any time for status if there is data in the receive fifo. 2.4.7.2 receive interrupts disabled this mode prevents the receiver from requesting an inter- rupt. it is used in a polled environment where either the status bits in rr0 or the modified vector in rr2 (channel b) is read. although the receiver interrupts are disabled, the interrupt logic can still be used to provide status. figure 2-14. write register 1 receive interrupt mode control d4 d3 wr1 00 receive interrupt disabled 01 rx int on first character or special condition 10 rx int on all receive characters or special condition 11 rx int on special condition only d2 parity is special condition scc /escc user? manual interfacing the scc/escc 2-23 2 when these bits indicate that a received character has reached the exit location of the fifo, the status in rr1 should be checked and then the data should be read. if status is to be checked, it must be done before the data is read, because the act of reading the data pops both the data and error fifos. 2.4.7.3 receive interrupt on first character or special condition this mode is designed for use with dma transfers of the receive characters. the processor is interrupted when the scc receives the first character of a block of data. it reads the character and then turns control over to a dma device to transfer the remaining characters. after this mode is se- lected, the first character received, or the first character al- ready stored in the fifo, sets the receiver ip. this ip is re- set when this character is removed from the scc. no further receive interrupts occur until the processor is- sues an enable interrupt on next receive character com- mand in wr0 or until a special receive condition occurs. the correct sequence of events when using this mode is to first select the mode and wait for the receive character available interrupt. when the interrupt occurs, the proces- sor should read the character and then enable the dma to transfer the remaining characters. escc: wr7' bit d3 should be reset to zero in this mode. a special receive condition interrupt may occur any time after the first character is received, but is guaranteed to oc- cur after the character having the special condition has been read. the status is not lost in this case, however, be- cause the fifo is locked by the special condition. in the in- terrupt service routine, the processor should read rr1 to obtain the status, and may read the data again if neces- sary. the fifo is unlocked by issuing an error reset com- mand in wr0. if the special condition was end-of-frame, the processor should now issue the enable interrupt on next receive character command to prepare for the next frame. the first character interrupt and special condition interrupt are distinguished by the status included in the in- terrupt vector. in all other respects they are identical, in- cluding sharing the ip and ius bits. 2.4.7.4 interrupt on all receive characters or special condition this mode is designed for an interrupt driven system. in this mode, the nmos/cmos version and the escc with wr7' d3=0 sets the receive ip when a received character is shifted into the exit location of the fifo. this occurs whether or not it has a special receive condition. this in- cludes characters already in the fifo when this mode is selected. in this mode of operation the ip is reset when the character is removed from the fifo, so if the processor re- quires status for any characters, this status must be read before the data is removed from the fifo. on the escc with d3=1, four bytes are accumulated in the receive fifo before an interrupt is generated (ip is set), and reset when the number of the characters in the fifo is less than four. the special receive conditions are identical to those previ- ously mentioned, and as before, the only difference be- tween a ?eceive character available?interrupt and a ?pe- cial receive condition?interrupt is the status encoded in the vector. in this mode a special receive condition does not lock the receive data fifo so that the service routine must read the status in rr1 before reading the data. at moderate to high data rates where the interrupt over- head is significant, time can usually be saved by checking for another character before exiting the service routine. this technique eliminates the interrupt acknowledge and the status processing, saving time, but care must be exer- cised because this receive character must be checked for special receive conditions before it is removed from the scc. 2.4.7.5 receive interrupt on special conditions this mode is designed for use when a dma transfers all receive characters between memory and the scc. in this mode, only receive characters with special conditions will cause the receive ip to be set. all other characters are as- sumed to be transferred via dma. no special initialization sequence is needed in this mode. usually, the dma is ini- tialized and enabled, then this mode is selected in the scc. a special receive condition interrupt may occur at any time after this mode is selected, but the logic guaran- tees that the interrupt will not occur until after the character with the special condition has been read from the scc. the special condition locks the fifo so that the status is valid when read in the interrupt service routine, and it guar- antees that the dma will not transfer any characters until the special condition has been serviced. in the service routine, the processor should read rr1 to obtain the status and unlock the fifo by issuing an error reset command. dma transfer of the receive characters then resumes. figure 2-15 shows the special conditions interrupt service routine. note: on the cmos and escc, if the sdlc frame status fifo is being used, please refer to section 4.4.3 on the fifo anti-lock feature. note: special receive condition interrupts are generated after the character is read from the fifo, not when the special condition is first detected. this is done so that when using receive interrupt on first or special condition or special condition only, data is directly read out of the data fifo without checking the status first. if a special condition interrupted the cpu when first detected, it would be necessary to read rr1 before each byte in the fifo to determine which byte had the special condition. therefore, scc /escc user? manual interfacing the scc/escc 2-24 2.4 interface programming (continued) by not generating the interrupt until after the byte has been read and then locking the fifo, only one status read is necessary. a dma can be used to do all data transfers (otherwise, it would be necessary to disable the dma to allow the cpu to read the status on each byte). consequently, since the special condition locks the fifo to preserve the status, it is necessary to issue the error reset command to unlock it. only the exit location of the fifo is locked allowing more data to be received into the other bytes of the receive fifo. figure 2-15. special conditions interrupt service flow special conditio n error handli n is it parity (rr1 bit 4) ? is it overrun (rr1 bit 5)? reads da t characte re t reset highest i u (wr0 - 38) no ye s ye s is it eof (rr1 bit 7 is it framing (rr1 bit 6) error handli n ye s error handli n good messa g ye s is it crc error (rr1 bit 6) ? 1 error handli n no no 1 1 1 1 no no scc /escc user? manual interfacing the scc/escc 2-25 2 2.4.8 transmit interrupts and transmit buffer empty bit transmit interrupts are controlled by transmit interrupt enable bit (d1) in wr1. if the interrupt capabilities of the scc are not required, polling may be used. this is select- ed by disabling transmit interrupts and polling the transmit buffer empty bit (tbe) in rr0. when the tbe bit is set, a character may be written to the scc without fear of writing over previous data. another way of polling the scc is to enable transmit interrupts and then reset master interrupt enable bit (mie) in wr9. the processor may then poll the ip bits in rr3a to determine when the transmit buffer is empty. transmit interrupts should also be disabled in the case of dma transfer of the transmitted data. because the depth of the transmitter buffer is different be- tween the nmos/cmos version of the scc and escc, generation of the transmit interrupt is slightly different. the following subsections describe transmit interrupts. note: for all interrupt sources, the master interrupt enable (mie) bit, wr9 bit d3, must be set for the device to gener- ate a transmit interrupt. 2.4.8.1 transmit interrupts and transmit buffer empty bit on the nmos/cmos the nmos/cmos version of the scc only has a one byte deep transmit buffer. the status of the transmit buffer can be determined through tbe bit in rr0, bit d2, which shows whether the transmit buffer is empty or not. after a hardware reset (including a hardware reset by software), or a channel reset, this bit is set to 1. while transmit interrupts are enabled, the nmos/cmos version sets the transmit interrupt pending (txip) bit whenever the transmit buffer becomes empty. this means that the transmit buffer must be full before the txip can be set. thus, when transmit interrupts are first enabled, the txip will not be set until after the first character is written to the nmos/cmos. in synchronous modes, one other condition can cause the txip to be set. this occurs at the end of a transmission after the crc is sent. when the last bit of the crc has cleared the transmit shift register and the flag or sync character is loaded into the transmit shift register, the nmos/cmos version sets the txip and tbe bit. data for a second frame or block transmission may be written at this time. the txip is reset either by writing data to the transmit buff- er or by issuing the reset tx int command in wr0. ordi- narily, the response to a transmit interrupt is to write more data to the device; however, the reset tx int command should be issued in lieu of data at the end of a frame or a block of data where the crc is to be sent next. note: a transmit interrupt may indicate that the packet has terminated illegally, with the crc byte(s) overwritten by the data. if the transmit interrupt occurs after the first crc byte is loaded into the transmit shift register, but before the last bit of the second crc byte has cleared the trans- mit shift register, then data was written while the crc was being sent. 2.4.8.2 transmit interrupt and transmit buffer empty bit on the escc the escc has a 4-byte deep transmit fifo, while the nmos/cmos scc is just 1-byte deep. for this reason, the generation of transmit interrupts is slightly different from that of the nmos/cmos scc version. the escc has two modes of transmit interrupt generation, which are programmed by bit d5 of wr7'. one transmit mode gener- ates interrupts when the entry location (the location the cpu writes data) of the transmit fifo is empty. this al- lows the escc response to be tailored to system require- ments for the frequency of interrupts and the interrupt re- sponse time. on the other hand, the transmit buffer empty (tbe) bit on the escc will respond the same way in each mode, in which the bit will become set when the entry location of the transmit fifo is empty. the tbe bit is not directly related to the transmit interrupt status nor the state of wr7' bit d5. when wr7' d5=1 (the default case), the escc will gener- ate a transmit interrupt when the transmit fifo becomes completely empty. the transmit interrupt occurs when the data in the exit location of the transmit fifo loads into the transmit shift register and the transmit fifo becomes completely empty. this mode minimizes the frequency of transmit interrupts by writing 4 bytes to the transmit fifo upon each entry to the interrupt will become set when wr7' d5=1. the tbe bit rr0 bit d2 will become set when- ever the entry location of the transmit fifo becomes empty. the tbe bit will reset when the entry location be- comes full. the tbe bit in a sense translates to meaning ?ransmit buffer not full?for the escc only, as the tbe bit will become set whenever the entry location of the transmit fifo becomes empty. this bit may be polled at any time to determine if a byte can be written to the fifo. figure 2-17 illustrates when the tbe bit will become set. wr7' bit d5 is set to one by a hardware or channel reset. when wr7' d5=0, the txip bit is set when the entry lo- cation of the transmit fifo becomes empty. in this mode, only one byte is written to the transmit fifo at a time for each transmit interrupt. the escc will generate transmit interrupts when there are 3 or fewer bytes in the fifo, and will continue to do so until the fifo is filled. when wr7' d5=0, the transmit interrupt is reset momen- tarily when data is loaded into the entry location of the transmit fifo. transmit interrupt is not generated when the entry location of the transmit fifo is filled. the trans- mit interrupt is generated when the data is pushed down the fifo and the entry location becomes empty (approx- imately one pclk time). figure 2-18 illustrates when the transmit interrupts will become set when wr7' d5=0. again, the tbe bit is not dependent on the state of wr7' scc /escc user? manual interfacing the scc/escc 2-26 2.4 interface programming (continued) bit d5 nor the transmit interrupt status, and will respond exactly the same way as mentioned above. figure 2-17 il- lustrates when the tbe bit will become set. note: when wr7' d5=0. only one byte is written to the fifo at a time, when there are three or fewer bytes in fifo. thus, for the escc multiple interrupts are generat- ed to fill the fifo. to avoid multiple interrupts, one can poll the tbe bit (rr0 d2) after writing each byte. while transmit interrupts are enabled, the escc sets the txip when the transmit buffer reaches the condition pro- grammed in wr7' bit d5. this means that the transmit buffer must have been written to before the txip is set. thus, when transmit interrupts are first enabled, the trans- mit ip is not set until the programmed interrupting condition is met. the txip is reset either by writing data to the transmit buff- er or by issuing the reset tx int pending command in wr0. ordinarily, the response to a transmit interrupt is to write more data to the escc; however, if there is no more data to be transmitted at that time, it is the end of the frame. the reset tx int command is used to reset the txip and clear the interrupt. for example, at the end of a frame or block of data where the crc is to be sent next, the re- set tx int pending command should be issued after the last byte of data has been written to the escc. in synchronous modes, one other condition can cause the txip to be set. this occurs at the end of a transmission af- ter the crc is sent. when the last bit of the crc has cleared the transmit shift register and the flag or sync character is loaded into the transmit shift register, the escc sets the txip. data for the new frame or block to be transmitted may be written at this time. in this particular case, the transmit buffer empty bit in rr0 and the txip are set. an enhancement to the escc from the nmos/cmos ver- sion is that the crc has priority over the data, where on the nmos/cmos version data has priority over the crs. this means that on the escc the crc bytes are guaran- teed to be sent, even if the data for the next packet has written before the second transmit interrupt, but after the eom/underrun condition exists. this helps to increase the system throughput because there is not waiting for the second transmit interrupt. on the nmos/cmos version, if the data is written while the crc is sent, crc byte(s) are replaced with the flag/sync pattern followed by the data. another enhancement of the escc is that it latches the transmit interrupt because the crc is loaded into the transmit shift register even if the transmit interrupt, due to the last data byte, is not yet reset. therefore, the end of a synchronous frame is guaranteed to generate two transmit interrupts even if a reset tx int pending command for the data created interrupt is issued after (time ??in figure 2-16) the crc interrupt had occurred. in this case, two reset tx int pending commands are required. the txip is latched if the eom latch has been reset before the end of the frame. figure 2-16. transmit interrupt status when wr7' d5=1 for escc 01 txfifo tx shift register no transmit interrupt txip=0 04 03 02 transmit interrupt txip=1 04 03 02 no transmit interrupt txip=0 scc /escc user? manual interfacing the scc/escc 2-27 2 . figure 2-17. transmit buffer empty bit status for escc for both wr7' and wr7' d5=0 01 txfifo tx shift register tbe=0 04 03 02 tbe=1 04 03 02 tbe=1 opening flag 01 04 03 02 figure 2-18. transmit interrupt status when wr7' d5=0 for escc 01 txfifo tx shift register no transmit interrupt txip = 0 04 03 02 04 03 02 transmit interrupt txip = 1 opening flag 01 figure 2-19. txip latching on the escc txbe txip bit data data crc1 crc2 flag txip 1 txip 2 time "a" scc /escc user? manual interfacing the scc/escc 2-28 2.4 interface programming (continued) 2.4.8.3 transmit interrupt and tx underrun/eom bit in synchronous modes as described in the section above, the behavior of the nmos/cmos version and the escc is slightly different, particularly at the end of packet sending. on the nmos/cmos version, the data has higher priority over crc data; writing data before this interrupt would terminate the packet illegally. in this case, the crc byte(s) are replaced with a flag or sync pattern, followed by the data written. on the escc, the crc has priority over the data. that means after the reception of the underrun/eom (end of message) interrupt, it accepts the data for the next packet without collapsing the packet. on the escc, if data was written during the time period described above, the tbe bit (bit d2 of rr0) will not be set even if the second txip is guaranteed to set when the flag/sync pattern was loaded into the transmit shift register, as mentioned above (figures 2-17 and 18). hence, on the escc, there is no need to wait for the second txip bit to set before writing data for the next packet and reducing the overhead. figure 2-20. operation of tbe, tx underrun/eom and txip on nmos/cmos. tbe (rr0, d2) tx underrun /eom last data -1 last data crc1 crc2 flag txip can not write data indicating crc get loaded reset tx underrun/eom command if txip reset command not issued txip reset command to clear interrupt indicating 1st byte of next packet can be written this time scc /escc user? manual interfacing the scc/escc 2-29 2 an example flowchart for processing an end of packet is shown in figure 2-22. the chart includes the differences in processing between the escc and nmos/cmos version. in this chart, tx ip and underrun/eom int can be processed by interrupts or by polling the registers. note that this flowchart does not have the procedures for interrupt handling, such as saving/restoring of registers to be used in the isr (interrupt service routine), reset ius command, or return from interrupt sequence. figure 2-21. operation of tbe, tx underrun/eom and txip on escc tbe tx underrun /eom last data -1 last data crc1 crc2 flag txip indicating crc get loaded reset tx underrun/eom latch command if txip reset command not issued txip reset command to clear tx interrupt data can be written to tx fifo after this point when auto eom reset has enabled set if tx fifo is empty scc /escc user? manual interfacing the scc/escc 2-30 2.4 interface programming (continued) figure 2-22. flowchart example of processing an end of packet start write last data txip=1 ? (tbe=1) issue reset tx ip command yes no underrun/eom int? issue ext/stat int cmd (to clear ext/stat int) yes no escc or nmos/cmos escc nmos/cmos write 1st byte of next packet (1 byte) yes no write data for next packet (max. 4 bytes) end txip=1 ? (tbe=1) scc /escc user? manual interfacing the scc/escc 2-31 2 2.4.9 external/status interrupts each channel has six external/status interrupt conditions: brg zero count, data carrier detect, sync/hunt, clear to send, tx underrun/eom, and break/abort. the master enable for external/status interrupts is d0 of wr1, and the individual enable bits are in wr15. individual enable bits control whether or not a latch is present in the path from the source of the interrupt to the corresponding status bit in rr0. if the individual enable is set to 0, then rr0 re- flects the current unlatched status, and if the individual en- able is set to 1, then rr0 reflects the latched status. the latches for the external/status interrupts are not inde- pendent. rather, they all close at the same time as a result of a state change in one of the sources of enabled exter- nal/status interrupts. this is shown schematically in figure 2-23. the external/status ip is set by the closing of the latches and remains set as long as they are closed. in order to de- termine which condition(s) require service when an exter- nal/status interrupt is received, the processor should keep an image of rr0 in memory and update this image each time it executes the external/status service routine. thus, a read of rr0 returns the current status for any bits whose individual enable is 0, and either the current state or the latched state of the remainder of the bits. to guarantee the current status, the processor should issue a reset external/status interrupts command in wr0 to open the latches. the external/status ip is set by the closing of the latches and remains set as long as they are closed. if the master enable for the external/status interrupts is not set, the ip is never set, even though the latches may be present in the signal paths and working as described. figure 2-23. rr0 external/status interrupt operation external/s t conditio n wit h ie = 0 latc h change detect o external/s t conditio n wit h ie = 1 to ip to rr 0 scc /escc user? manual interfacing the scc/escc 2-32 2.4 interface programming (continued) because the latches close on the current status, but give no indication of change, the processor must maintain a copy of rr0 in memory. when the scc generates an ex- ternal/status interrupt, the processor should read rr0 and determine which condition changed state and take appro- priate action. the copy of rr0 in memory is then updated and the reset external/status interrupt command issued. care must be taken in writing the interrupt service routine for the external/status interrupts because it is possible for more than one status condition to change state at the same time. all of the latch bits in rr0 should be compared to the copy of rr0 in memory. if none have changed and the zc interrupt is enabled, the zero count condition caused the interrupt. on the escc, the contents of rr0 are latched while read- ing this register. the escc prevents the contents of rr0 from changing while the read cycle is active. on the nmos/cmos version, it is possible for the status of rr0 to change while a read is in progress, so it is necessary to read rr0 twice to detect changes that otherwise may be missed. the contents of rr0 are latched on the falling edge of /rd and are updated after the rising edge of /rd. the operation of the individual enable bits in wr15 for each of the six sources of external/status interrupts is identical, but subtle differences exist in the operation of each source of interrupt. the six sources are break/abort, underrun/eom, cts, dcd, sync/hunt and zero count. the break/abort, underrun/eom, and zero count condi- tions are internal to the scc, while sync/hunt may be in- ternal or external, and cts and dcd are purely external signals. in the following discussions, each source is as- sumed to be enabled so that the latches are present and the external/status interrupts are enabled as a whole. re- call that the external/status ip is set while the latches are closed and that the state of the signal is reflected immedi- ately in rr0 if the latches are not present. 2.4.9.1 break/abort the break/abort status is used in asynchronous and sdlc modes, but is always 0 in synchronous modes other than sdlc. in asynchronous modes, this bit is set when a break sequence (null character plus framing error) is de- tected in the receive data stream, and remains set as long as 0s continue to be received. this bit is reset when a 1 is received. a single null character is left in the receive fifo each time that the break condition is terminated. this char- acter should be read and discarded. in sdlc mode, this bit is set by the detection of an abort se- quence which is seven or more contiguous 1s in the receive data stream. the bit is reset when a 0 is received. a re- ceived abort forces the receiver into hunt, which is also an external/status condition. though these two bits change state at roughly the same time, one or two external/status interrupts may be generated as a result. the break/abort bit is unique in that both transitions are guaranteed to cause the latches to close, even if another external/status inter- rupt is pending at the time these transitions occur. this guarantees that a break or abort will be caught. this bit is undetermined after reset. 2.4.9.2 transmit underrun/eom the transmit underrun/eom bit is used in synchronous modes to control the transmission of the crc. this bit is reset by issuing the reset transmit underrun/eom com- mand in wr0. however, this transition does not cause the latches to close; this occurs only when the bit is set. to in- form the processor of this fact, the scc sets this bit when the crc is loaded into the transmit shift register. this bit is also set if the processor issues the send abort com- mand in wr0. this bit is always set in asynchronous mode. escc: the escc has been modified so that in sdlc mode this interrupt indicates when more data can be written to the transmit fifo. when this interrupt is used in this way, the automatic sdlc flag transmission fea- ture must be enabled (wr7' d0=1). on the escc, the transmit underrun/eom interrupt can be used to sig- nal when data for a subsequent frame can be written to the transmit fifo which more easily supports the transmission of back to back frames. 2.4.9.3 cts/dcd the cts bit reports the state of the /cts input, and the dcd bit reports the status of the /dcd input. both bits latch on either input transition. in both cases, after the re- set external/status interrupt command is issued, if the latches are closed, they remain closed if there is any odd number of transitions on an input; they open if there is an even number of transitions on the input. 2.4.9.4 zero count the zero count bit is set when the counter in the baud rate generator reaches a count of 0 and is reset when the counter is reloaded. the latches are closed only when this bit is set to 1. the status in rr0 always reflects the current status. while the zero count ie bit in wr15 is reset, this bit is forced to 0. 2.4.9.5 sync/hunt there are a variety of ways in which the sync/hunt may be set and reset, depending on the scc? mode of operation. in the asynchronous mode this bit reports the state of the /sync pin, latching on both input transitions. the same is true of external sync mode. however, if the crystal oscilla- tor is enabled while in asynchronous mode, this bit will be forced to 0 and the latches will not be closed. selecting the scc /escc user? manual interfacing the scc/escc 2-33 2 crystal option in external sync mode is illegal, but the re- sult will be the same. in synchronous modes other than sdlc, the sync/hunt reports the hunt state of the receiver. hunt mode is en- tered when the processor issues the enter hunt command in wr3. this forces the receiver to search for a sync char- acter match in the receive data stream. because both tran- sitions of the hunt bit close the latches, issuing this com- mand will cause an external/status interrupt. the scc resets this bit when character synchronization has been achieved, causing the latches to again be closed. in these synchronous modes, the scc will not re-enter the hunt mode automatically; only the enter hunt command will set this bit. in sdlc mode this bit is also set by the enter hunt command, but the receiver automatically enters the hunt mode if an abort sequence is received. the receiver leaves hunt upon receipt of a flag sequence. both transi- tions of the hunt bit will cause the latches to be closed. in sdlc mode, the receiver automatically synchronizes on flag characters. the receiver is in hunt mode when it is en- abled, so the enter hunt command is never needed. 2.4.9.6 external/status interrupt handling if careful attention is paid to details, the interrupt service routine for external/status interrupts is straightforward. to determine which bit or bits changed state, the routine should first read rr0 and compare it to a copy from mem- ory. for each changed bit, the appropriate action should be taken and the copy in memory updated. the service routine should close with two reset external/status inter- rupt commands to reopen the latches. the copy of rr0 in memory should always have the zero count bit set to 0, since this is the state of the bit after the reset exter- nal/status interrupts command at the end of the service routine. when the processor issues the reset transmit underrun/eom latch command in wr0, the transmit un- derrun/eom bit in the copy of rr0 in memory should be reset because this transition does not cause an interrupt. 2.5 block/dma transfer the scc provides a block transfer mode to accommo- date cpu block transfer functions and dma controllers. the block transfer mode uses the /w//req output in con- junction with the wait/request bits in write register 1. the /w//req output can be defined by software as a /wait line in the cpu block transfer mode or as a /req line in the dma block transfer mode. the /dtr//req pin can also be programmed through wr14 bit d2 to function as a dma request for the transmitter. to a dma controller, the scc's /req outputs indicate that the scc is ready to transfer data to or from memory. to the cpu, the /wait output indicates that the scc is not ready to transfer data, thereby requesting the cpu to ex- tend the i/o cycle. 2.5.1 block transfers the scc offers several alternatives for the block transfer of data. the various options are selected by wr1 (bits d7 through d5) and wr14 (bit d2). each channel in the scc has two pins which are used to control the block transfer of data. both pins in each channel may be programmed to act as dma request signals. the /w//req pin in each chan- nel may be programmed to act as a wait signal for the cpu. in either mode, it is advisable to select and enable the mode in two separate accesses of the appropriate reg- ister. the first access should select the mode and the sec- ond access should enable the function. this procedure prevents glitches on the output pins. reset forces wait mode, with /w//req open-drain. 2.5.1.1 wait on transmit the wait on transmit function is selected by setting both d6 and d5 to 0 and then enabling the function by setting d7 of wr1 to 1. in this mode the /w//req pin carries the /wait signal, and is open-drain when inactive and low when active. when the processor attempts to write to the transmit buffer when it is full, the scc asserts /wait until the byte is written (figure 2-24). scc /escc user? manual interfacing the scc/escc 2-34 2.5 block/dma transfer (continued) this allows the use of a block move instruction to transfer the transmit data. in the case of the z80x30, /wait will go active in response to /ds going active, but only if wr8 is being accessed and a write is attempted. in all other cas- es, /wait remains open-drain. in the case of the z85x30, /wait goes active in response to /wr going active, but only if the data buffer is being accessed, either directly or via the pointers. the /wait pin is released in response to the falling edge of pclk. details of the timing are shown in figure 2-25. care must be taken when using this function, particularly at slow transmission speed. the /wait pin stays active as long as the transmit buffer stays full, so there is a possibil- ity that the cpu may be kept waiting for a long period. figure 2-24. wait on transmit timing /ds or /wr to tx buffer tx buffer empty /w//req (=wait) empty full figure 2-25. wait on transmit timing /trxc /wait sync modes pclk async modes scc /escc user? manual interfacing the scc/escc 2-35 2 2.5.1.2 wait on receive the wait on receive function is selected by setting d6 or wr1 to 0, d5 of wr1 to 1, and then enabling the function by setting d7 of wr1 to 1. in this mode, the /w//req pin carries the /wait signal, and is open-drain when inactive and low when active. when the processor attempts to read data from the receive fifo when it is empty, the scc asserts /wait until a character has reached the exit location of the fifo (figure 2-26). this allows the use of a block move instruction to trans- fer the receive data. in the case of the z80x30, /wait goes active in response to /ds going active, but only if rr8 is being accessed and a read is attempted. in all other cases, /wait remains open-drain. in the case of the z85x30, /wait goes active in response to /rd go- ing active, but only if the receive data fifo is being ac- cessed, either directly or via the pointers. the /wait pin is released in response to the falling edge of pclk. de- tails of the timing are shown in figure 2-27. care must be taken when this mode is used. the /wait pin stays active as long as the receive fifo remains emp- ty. when the cpu access the scc, the cpu remains in the wait state until data gets into the receive fifo, freez- ing the system. figure 2-26. wait on receive timing /ds or /rd (from rx fifo) rx character available /w//req (=wait) character available fifo empty figure 2-27. wait on receive timing /rtxc /wait sync modes pclk 12 34 5? 9 10111213 async modes scc /escc user? manual interfacing the scc/escc 2-36 2.5 block/dma transfer (continued) 2.5.2 dma requests the two dma request pins /w//req and /dtr//req can be programmed for dma requests. the /w//req pin is used as either a transmit or a receive request, and the /dtr//req pin can be used as a transmit request only. for full-duplex operation, the /w//req is used for receive, and the /dtr//req is used for transmit. these modes are de- scribed below. 2.5.2.1 dma request on escc transmit dma request is also affected by wr7' bit d5. as noted earlier, wr7' d5 affects both the transmit interrupt and dma request generation similarly. note: wr7' d3 is ignored by the receive request function. this allows a dma to transfer all bytes out of the receive fifo and still maintain the full advantage of the fifo when the dma has a long latency response acquiring the data bus. bit d5 of wr7' is set to 1 after reset to maintain maximum compatibility with scc designs. this is necessary because if wr7' d5=0 when the request function is enabled, re- quests are made in rapid succession to fill the fifo. conse- quently, some designs which require an edge to be detected for each data transfer may not recover fast enough to detect the edges. this is handled by programming wr7' d5=1, or changing the dma to be level sensitive instead of edge sen- sitive. programming wr7' d5=0 has the advantage of the dma requesting to keep the fifo full. therefore, if the cpu is busy, a significantly longer latency can be tolerated with- out the transmitter under-running. 2.5.2.2 dma request on transmit (using /w//req) the request on transmit function is selected by setting d6 of wr1 to 1, d5 of wr1 to 0, and then enabling the function by setting d7 of wr1 to 1. in this mode, the /w//req pin carries the /req signal, which is active low. when this mode is selected but not yet enabled, the /w//req is driven high. the /req pin generates a falling edge for each byte writ- ten to the transmit buffer when the dma controller is to write new data. for the z80x30, the /req pin then goes inactive on the falling edge of the ds that writes the new data (see ac spec #26, tddsf(req)) for the z85x30, the /req pin then goes inactive on the falling edge of the wr strobe that writes the new data (see ac spec #33, td- wrf(req)) this is shown in figure 2-28. note: the /req pin follows the state of the transmit buffer even though the transmitter is disabled. thus, if the /req is enabled, the dma writes data to the scc before the transmitter is enabled. this will not cause a problem in asynchronous mode, but it may cause problems in synchronous mode because the scc sends data in preference to flags or sync characters. it may also complicate the crc initialization, which cannot be done until after the transmitter is enabled. on the escc, this complication can be avoided in sdlc mode by using the automatic sdlc opening flag trans- mission feature and the auto eom reset feature, which also resets the transmit crc (see section 4.4.1 for de- tails). applications using other synchronous modes should enable the transmitter before enabling the /req function. figure 2-28. transmit request assertion /trxc /req (/dtr//req) async modes sync modes pclk /req (/w//req) scc /escc user? manual interfacing the scc/escc 2-37 2 with only one exception, the /req pin directly follows the state of the transmit buffer (for the escc as programmed by wr7' d5) in this mode. the scc generates only one falling edge on /req per character requested and the tim- ing for this is shown in figure 2-29. the one exception occurs in synchronous modes at the end of a crc transmission. at the end of a crc transmis- sion, when the closing flag or sync character is loaded into the transmit shift register, /req is pulsed high for one pclk cycle. the dma uses this falling edge on /req to write the first character of the next frame to the scc. in the case of the z80x30, /req goes high in response to the falling edge of ds, but only if the appropriate channel transmit buffer in the scc is accessed. this is shown in figure 2-25. in the case of the z85x30, /req goes high in response to the falling edge of /wr, but only when the ap- propriate channel transmit buffer in the scc is accessed. this is shown in figure 2-30. figure 2-29. z80x30 transmit request release /ds /req (/dtr//req) pcl k /req (/w//req) /as ad7-ad 0 transmit data wr8 figure 2-30. z85x30 transmit request release /req (/dtr//req) pclk /req (/w//req) d7-d0 transmit data /wr scc /escc user? manual interfacing the scc/escc 2-38 2.5 block/dma transfer (continued) 2.5.2.3 dma request on transmit (using /dtr//req) a second request on transmit function is available on the /dtr//req pin. this mode is selected by setting d2 of wr14 to 1. /req goes low when the transmit fifo is empty if wr7' d5=1, or when the exit location of the trans- mit fifo is empty if wr7' d5=0. in the request mode, /req follows the state of the transmit fifo even though the transmitter is disabled. while d2 of wr14 is set to 0, the /dtr//req pin is /dtr and follows the inverted state of d7 in wr5. this pin is high after a channel or hardware reset and in the dtr mode. the /dtr//req pin goes inactive high between each transfer for a minimum of one pclk cycle (figure 2-31). escc: the timing of deactivation of this pin is programmable through wr7' bit d4. the /dtr//req waits until the write operation has been completed before going in- active. refer to z85230 ac spec #35a tdwrr(req) and z80230 ac spec #27a tddsr(req). this mode is compatible with the scc and guarantees that any sub- sequent access to the escc does not violate the valid access recovery time requirement. if wr7' d4=1, the /dtr//req is deactivated with iden- tical timing as the /w/req pin. refer to z85230 ac spec #35b tdwrr(req) and z80230 ac spec #27b tddsr(req). this feature is beneficial to applications needing the dma request to be deasserted quickly. it prevents a full transmit fifo from being overwritten due to the assertion of request being too long and being recognized as a request for more data. note: if wr7' d4=1, analysis should be done to verify that the escc is not repeatedly accessed in less than four pclks. however, since many dmas require four clock cycles to transfer data, this typically is not a problem. figure 2-31. /dtr//req deassertion timing /dtr//req /wait//req /ds or /wr d7-d0 transmit data escc wr7' d4 =1 escc wr7' d4 =0, or cmos/nmos version scc /escc user? manual interfacing the scc/escc 2-39 2 in the request mode, /req will follow the state of the transmit buffer even though the transmitter is disabled. thus, if /req is enabled before the transmitter is enabled, the dma may write data to the scc before the transmitter is enabled. this does not cause a problem in asynchro- nous mode, but may cause problems in synchronous modes because the scc sends data in preference to flags or sync characters. it may also complicate the crc initial- ization, which cannot be done until after the transmitter is enabled. on the escc, this complication can be avoided in sdlc mode by using the automatic sdlc opening flag transmission feature and auto eom reset feature which also resets the transmit crc. (see section 4.4.1.2 for de- tails). applications using other synchronous modes should enable the transmitter before enabling the /req function. with only one exception, the /req pin directly follows the state of the transmit fifo (for escc, as programmed by wr7' d5) in this mode. the one exception occurs in syn- chronous modes at the end of a crc transmission. at the end of a crc transmission, when the closing flag or sync character is loaded into the transmit shift register, /req is pulsed high for one pclk cycle. the dma uses this fall- ing edge on /req to write the first character of the next frame to the scc. 2.5.2.4 dma request on receive the request on receive function is selected by setting d6 and d5 of wr1 to 1 and then enabling the function by set- ting d7 of wr1 to 1. in this mode, the /w//req pin carries the /req signal, which is active low. when req on re- ceive is selected, but not yet enabled (wr1 d7=0), the /w//req pin is driven high. when the enable bit is set, /req goes low if the receive fifo contains a character at the time, or will remain high until a character enters the receive fifo. note that the /req pin follows the state of the receive fifo even though the receiver is disabled. thus, if the receiver is disabled and /req is still enabled, the dma transfers the previously received data correctly. in this mode, the /req pin directly follows the state of the receive fifo with only one exception. /req goes low when a character enters the receive fifo and remains low until this character is removed from the receive fifo. the scc generates only one falling edge on /req per character transfer requested (figure 2-32). the one ex- ception occurs in the case of a special receive condition in the receive interrupt on first character or special condi- tion mode, or the receive interrupt on special condition only mode. in these two interrupt modes, any receive character with a special receive condition is locked at the top of the fifo until an error reset command is issued. this character in the receive fifo would ordinarily cause additional dma requests after the first time it is read. however, the logic in the scc guarantees only one falling edge on /req by holding /req high from the time the character with the special receive condition is read, and the fifo locked, until after the error reset command has been issued. figure 2-32. dma receive request assertion read strobe to fifo rx character available w/req (=req) character available fifo empty scc /escc user? manual interfacing the scc/escc 2-40 2.5 block/dma transfer (continued) once the fifo is locked, it allows the checking of the re- ceive error fifo (rr1) to find the cause of the error. lock- ing the data fifo, therefore, stops the error status from popping out of the receive error fifo. also, since the dma request becomes inactive, the interrupt (special condition) is serviced. once the fifo is unlocked by the error reset command, /req again follows the state of the receive buffer. in the case of the z80x30, /req goes high in response to the falling edge of /ds, but only if the appropriate receive buffer in the scc is accessed (figure 2-33). in the case of the z85x30, /req goes high in response to the falling edge of /rd, but only when the appropriate receive buffer in the scc is accessed (figure 2-34). figure 2-33. z80x30 receive request release /ds pclk /as ad7-ad0 receive data wr8 /req figure 2-34. z85x30 receive request release pcl k /req /rd d7- d0 receive data scc /escc user? manual interfacing the scc/escc 2-41 2 2.6 test functions the scc contains two other features useful for diagnostic purposes, controlled by bits in wr14. they are local loopback and auto echo. 2.6.1 local loopback local loopback is selected when wr14 bit d4 is set to 1. in this mode, the output of the transmitter is internally con- nected to the input of the receiver. at the same time, the txd pin remains connected to the transmitter. in this mode, the /dcd pin is ignored as a receive enable and the /cts pin is ignored as a transmitter enable even if the auto enable mode has been selected. note that the dpll input is connected to the rxd pin, not to the input of the receiver. this precludes the use of the dpll in local loopback. lo- cal loopback is shown schematically in figure 2-35. 2.6.2 auto echo auto echo is selected when bit d3 of wr14 is set to 1. in this mode, the txd pin is connected directly to the rxd pin, and the receiver input is connected to the rxd pin. in this mode, the /cts pin is ignored as a transmitter enable and the output of the transmitter does not connect to anything. if both the local loopback and auto echo bits are set to 1, the auto echo mode is selected, but both the /cts pin and /dcd pin are ignored as auto enables. this should not be considered a normal operating mode (figure 2-36). figure 2-35. local loopback transmitter receiver receiver rxd /dcd /cts txd tx enable rx enable local loop back nc figure 2-36. auto echo transmitter receiver rxd /dcd /cts txd tx enable rx enable auto echo nc 2-42 3-1 3 u ser s m anual c hapter 3 scc/escc a ncillary s upport c ircuitry 3.1 introduction the serial channels of the scc are supported by ancillary circuitry for generating clocks and performing data encod- ing and decoding. this chapter presents a description of these functional blocks. note to escc/cmos users: the maximum input fre- quency to the dpll has been specified as two times the pclk frequency (spec #16b txrx(dpll)). there are no changes to the baud rate generators from the nmos to the cmos/escc. note to scc users: the ancillary circuitry in the escc is the same as in the scc with the following noted changes. the dpll (dual phased-locked loop) output, when used as the transmit clock source, has been changed to be free of jitter. consequently, this only affects the use of the dpll as the transmit clock source (it is typically used for the re- ceive clock source), this has no effect on using the dpll as the receive clock source. 3.2 baud rate generator the baud rate generator (brg) is essential for asynchronous communications. each channel in the scc contains a programmable baud rate generator. each generator consists of two 8-bit, time-constant registers forming a16-bit time constant, a 16-bit down counter, and a flip-flop on the output so that it outputs a square wave. on start-up, the flip-flop on the output is set high, so that it starts in a known state, the value in the time-constant register is loaded into the counter, and the counter begins counting down. when a count of zero is reached, the output of the baud rate generator toggles, the value in the time-constant register is loaded into the counter, and the process starts over. the programmed time constant is read from rr12 and rr13. a block diagram of the baud rate generator is shown in figure 3-1. figure 3-1. baud rate generator zero count (gives one transition each time the counter counts to zero) output (may provide higher resolution to sample data) desired baud (asynchronous mode) baud rate generator clock (takes one more clock to load time constant value to counter /rtxc pin pclk pin 16-bit counter wr 13 wr12 ? 2 ? clock mode scc /escc user? manual scc/escc ancillary support circuitry 3-2 3.2 baud rate generator (continued) the time-constant can be changed at any time, but the new value does not take effect until the next load of the counter (i.e., after zero count is reached). no attempt is made to synchronize the loading of a new time-constant with the clock used to drive the generator. when the time-constant is to be changed, the generator should be stopped first by writing wr14 d0=0. after loading the new time constant, the brg can be started again. this ensures the loading of a correct time constant, but loading does not take place until zero count or a reset occurs. if neither the transmit clock nor the receive clock are pro- grammed to come from the /trxc pin, the output of the baud rate generator may be made available for external use on the /trxc pin. note: this feature is very useful for diagnostic purposes. by programming the output of the baud rate generator as output on the /trxc pin, the brg is source and time test- ed, and the programmed time constant verified. the clock source for the baud rate generator is selected by bit d1 of wr14. when this bit is set to 0, the brg uses the signal on the /rtxc pin as its clock, independent of wheth- er the /rtxc pin is a simple input or part of the crystal os- cillator circuit. when this bit is set to 1, the brg is clocked by the pclk. to avoid metastable problems in the counter, this bit should be changed only while the baud rate generator is disabled, since arbitrarily narrow pulses can be generated at the output of the multiplexer when it changes status. the brg is enabled while bit d0 of wr14 is set to 1. it is disabled while wr14 d0=0 and after a hardware reset (but not a software reset). to prevent metastable problems when the baud rate generator is first enabled, the enable bit is synchronized to the baud rate generator clock. this introduces an additional delay when the baud rate generator is first enabled (figure 3-2). the baud rate generator is disabled immediately when bit d0 of wr14 is set to 0, because the delay is only necessary on start-up. the baud rate generator is enabled and disabled on the fly, but this delay on start-up must be taken into consideration. figure 3-2. baud rate generator start up scc /escc user? manual scc/escc ancillary support circuitry 3-3 3 the formulas relating the baud rate to the time-constant and vice versa are shown below. in these formulas, the brg clock frequency (pclk or /rtxc) is in hertz, the desired baud rate in bits/sec, clock mode is 1 in sync modes, 1, 16, 32 or 64 in async mode and the time constant is dimensionless. the example in table 3-1 assumes a 2.4576 mhz clock (from /rtxc) fac- tor of 16 and shows the time constant for a number of pop- ular baud rates. for example: . other commonly used clock frequencies include 3.6846, 4.6080, 4.91520, 6.144, 7.3728, 9.216, 9.8304, 12.288, 14.7456, 19.6608 (units in mhz). initializing the brg is done in three steps. first, the time- constant is determined and loaded into wr12 and wr13. next, the processor must select the clock source for the brg by setting bit d1 of wr14. finally, the brg is en- abled by setting bit d0 of wr14 to 1. note: the first write to wr14 is not necessary after a hard- ware reset if the clock source is the /rtxc pin. this is be- cause a hardware reset automatically selects the /rtxc pin as the brg clock source. baud rate = clock frequency 2 x (clock mode) x (time constant+ 2) time constant = - 2 clock frequency 2 x (clock mode) x (baud rate) tc = 2.4576 x 10 (2 x 16) x 150 = 510 6 -2 10 6 table 3-1. baud rates for 2.4576 mhz clock and 16x clock factor baud rate time constant decimal hex 38400 0 0000 19200 2 0002 9600 6 0006 4800 14 000e 2400 30 001e 1200 62 003e 600 126 007e 300 254 00fe 150 510 01fe scc /escc user? manual scc/escc ancillary support circuitry 3-4 3.3 data encoding/decoding data encoding is utilized to allow the transmission of clock and data information over the same medium. this saves the need to transmit clock and data over separate medium as would normally be required for synchronous data. the scc provides four different data encoding methods, selected by bits d6 and d5 in wr10. an example of these four encoding methods is shown in figure 3-3. any encoding method is used in any x1 mode in the scc, asynchronous or synchronous. the data encoding selected is active even though the transmitter or receiver is idling or disabled. figure 3-3. data encoding methods data nrz 1 1 0 0 1 0 nrzi fm1 (biphase mark) fm0 (biphase space) manchester bit cell level: high = 1 low = 0 no change = 1 change = 0 bit center transition: transition = 1 no transition = 0 no transition = 1 transition = 0 high ? low = 1 low ? high = 0 scc /escc user? manual scc/escc ancillary support circuitry 3-5 3 nrz (non-return to zero). in nrz, encoding a 1 is rep- resented by a high level and a 0 is represented by a low level. in this encoding method, only a minimal amount of clocking information is available in the data stream in the form of transitions on bit-cell boundaries. in an arbitrary data pattern, this may not be sufficient to generate a clock for the data from the data itself. nrzi (non-return to zero inverted). in nrzi, encoding a 1 is represented by no change in the level and a 0 is rep- resented by a change in the level. as in nrz, only a mini- mal amount of clocking information is available in the data stream, in the form of transitions on bit cell boundaries. in an arbitrary data pattern this may not be sufficient to gen- erate a clock for the data from the data itself. in the case of sdlc, where the number of consecutive 1s in the data stream is limited, a minimum number of transitions to gen- erate a clock are guaranteed. escc: txd pin forced high in sdlc feature. when the escc is programmed for sdlc mode with nrzi data encod- ing and mark idle (wr10 d6=0, d5=1, d3=1), the txd pin is automatically forced high when the transmitter goes to the mark idle state. there are several different ways for the transmitter to go into the idle state. in each of the following cases the txd pin is forced high when the mark idle condition is reached: data, crc, flag and idle; data, flag and idle; data, abort (on under- run) and idle; data, abort (command) and idle; idle flag and command to idle mark. the force high feature is disabled when the mark idle bit is reset. the txd pin is forced high on the falling edge of the txc cycle after the falling edge of the last bit of the closing flag. using sdlc loop mode is independent of this feature. this feature is used in combination with the automatic sdlc opening flag transmission feature, wr7' d0=1, to assure that data packets are properly formatted. therefore, when these features are used together, it is not necessary for the cpu to issue any commands when using the force idle mode in combination with nrzi data encoding. if wr7' d0 is reset, like the scc, it is necessary to reset the mark idle bit (wr10 d2) to enable flag transmission before an sdlc packet is transmitted. fm1 (bi-phase mark). in fm1 encoding, also known as bi- phase mark, a transition is present on every bit cell bound- ary, and an additional transition may be present in the mid- dle of the bit cell. in fm1, a 0 is sent as no transition in the center of the bit cell and a 1 is sent as a transition in the center of the bit cell. fm1 encoded data contains sufficient information to recover a clock from the data. fm0 (bi-phase space). in fm0 encoding, also known as bi-phase space, a transition is present on every bit cell boundary and an additional transition may be present in the middle of the bit cell. in fm0, a 1 is sent as no transition in the center of the bit cell and a 0 is sent as a transition in the center of the bit cell. fm0 encoded data contains suffi- cient information to recover a clock from the data. manchester (bi-phase level). manchester (bi-phase lev- el) encoding always produces a transition at the center of the bit cell. if the transition is low to high, the bit is 0. if the transition is high to low, the bit is 1. encoding of manches- ter format requires an external circuit consisting of a ? flip-flop and four gates (figure 3-4). the scc is used to decode manchester data by using the dpll in the fm mode and programming the receiver for nrz data (see section 3.1.3). data encoding initialization. the data encoding method is selected in the initialization procedure before the transmitter and receiver are enabled, but no other restrictions apply. note that in nrz and nrzi, the receiver samples the data only on one edge, as shown in figure 3-3. however, in fm1 and fm0, the receiver samples the data on both edges. also, as shown in figure 3-3, the transmitter defines bit cell boundaries by one edge in all cases and uses the other edge in fm1 and fm0 to create the mid-bit transition. scc /escc user? manual scc/escc ancillary support circuitry 3-6 3.3 data encoding/decoding (continued) figure 3-4. manchester encoding circuit 1 3 2 manchester nrz transmit clock 1 2 3 4 5 a b 5 4 transmit clock nrz scc /escc user? manual scc/escc ancillary support circuitry 3-7 3 3.4 dpll digital phase-locked loop each channel of the scc contains a digital phase-locked loop that can be used to recover clock information from a data stream with nrzi, fm, nrz, or manchester encod- ing. the dpll is driven by a clock nominally at 32 (nrzi) or 16 (fm) times the data rate. the dpll uses this clock, along with the data stream, to construct a receive clock for the data. this clock can then be used as the scc receive clock, the transmit clock, or both. figure 3-5 shows a block diagram of the digital phase- locked loop. it consists of a 5-bit counter, an edge detector, and a pair of output decoders. the clock for the dpll comes from the output of a two-input multiplexer, and the two outputs go to the transmitter and receive clock multiplexers. the dpll is controlled by seven commands encoded in wr14 bits d7, d6 and d5. the clock source for the dpll is selected issuing one of the two commands in wr14, that is: wr14 (7-5) = 100 selects the brg wr14 (7-5) = 101 selects the /rtxc pin the first command selects the baud rate generator as the clock source. the other command selects the /rtxc pin as the clock source, independent of whether the /rtxc pin is a simple input or part of the crystal oscillator circuit. initialization of the dpll is done at any time during the ini- tialization sequence, but should be done after the clock modes have been selected in wr11, and before the re- ceiver and transmitter are enabled. when initializing the dpll, the clock source should be selected first, followed by the selection of the operating mode. to avoid metastable problems in the counter, the clock source selection is made only while dpll is disabled, since arbitrarily narrow pulses are generated at the output of the multiplexer when it changes status. the dpll is programmed to operate in one of two modes, as selected by commands in wr14. wr14 (7-5) = 111 selects nrzi mode wr14 (7-5) = 110 selects fm mode note: a channel or hardware reset disables the dpll, se- lects the /rtxc pin as the clock source for the dpll, and places it in the nrzi mode. as in the case of the clock source selection, the mode of operation is only changed while the dpll is disabled to prevent unpredictable results. in the nrzi mode, the dpll clock must be 32 times the data rate. in this mode, the transmit and receive clock out- puts of the dpll are identical, and the clocks are phased so that the receiver samples the data in the middle of the bit cell. in nrzi mode, the dpll does not require a transi- tion in every bit cell, so this mode is useful for recovering the clocking information from nrz and nrzi data streams. in the fm mode, the dpll clock must be 16 times the data rate. in this mode, the transmit clock output of the dpll lags the receive clock outputs by 90 degrees to make the transmit and receive bit cell boundaries the same, be- cause the receiver must sample fm data at one-quarter and three-quarters bit time. the dpll is enabled by issuing the enter search mode command in wr14; that is wr14 (7-5) = 001. the enter search mode command unlocks the counter, which is held while the dpll is disabled, and enables the edge detector. if the dpll is already enabled when this command is is- sued, the dpll also enters search mode. figure 3-5. digital phase-locked loop edge detector rxd count modifier decode receive clock 5-bit counter decode transmit clock scc /escc user? manual scc/escc ancillary support circuitry 3-8 3.4 dpll digital phase-locked loop (continued) 3.4.1 dpll operation in the nrzi mode to operate in nrzi mode, the dpll must be supplied with a clock that is 32 times the data rate. the dpll uses this clock, along with the receive data, to construct receive and transmit clock outputs that are phased to properly receive and transmit data. to do this, the dpll divides each bit cell into four regions, and makes an adjustment to the count cycle of the 5-bit counter dependent upon the region a transition on the re- ceive data input occurred (figure 3-6). ordinarily, a bit-cell boundary occurs between count 15 and count 16, and the dpll output causes the data to be sampled in the middle of the bit cell. however, four differ- ent situations can occur: if the bit-cell boundary (from space to mark) occurs any- where during the second half of count 15 or the first half of count 16, the dpll allows the transition without making a correction to its count cycle. if the bit cell boundary (from space to mark) occurs be- tween the middle of count 16 and count 31, the dpll is sampling the data too early in the bit cell. in response to this, the dpll extends its count by one during the next 0 to 31 counting cycle, which effectively moves the edge of the clock that samples the receive data closer to the center of the bit cell. if the transition occurs between count 0 and the middle of count 15, the output of the dpll is sampling the data too late in the bit cell. to correct this, the dpll shortens its count by one during the next 0 to 31 counting cycle, which effectively moves the edge of the clock that samples the receive data closer to the center of the bit cell. if the dpll does not see any transition during a counting cy- cle, no adjustment is made in the following counting cycle. if an adjustment to the counting cycle is necessary, the dpll modifies count 5, either deleting it or doubling it. thus, only the low time of the dpll output is lengthened or shortened. while the dpll is in search mode, the counter remains at count 16, where the dpll outputs are both high. the missing clock latches in the dpll, which may be accessed in rr10, are not used in nrzi mode. an example of the dpll in operation is shown in figure 3-7. figure 3-6. dpll in nrzi mode 1 18 19 20 17 16 2122232425262728293031 2345 789 121314 11 10 15 0 no change no change bit cell count correction dpll out add one count subtract one count 6 scc /escc user? manual scc/escc ancillary support circuitry 3-9 3 3.4.2 dpll operation in the fm modes to operate in fm mode, the dpll must be supplied with a clock that is 16 times the data rate. the dpll uses this clock, along with the receive data, to construct, receive, and transmit clock outputs that are phased to receive and transmit data properly. in fm mode, the counter in the dpll counts from 0 to 31, but now each cycle corresponds to 2-bit cells. to make adjustments to remain in phase with the receive data, the dpll divides a pair of bit cells into five regions, making the adjustment to the counter dependent upon which region the transition on the receive data input occurred (figure 3-8). figure 3-7. dpll operating example (nrzi mode) receive data dpll outpu t correction windows count lengt h 32 32 32 31 31 31 33 33 33 +1 -1 +1 -1 +1 -1 +1 -1 +1 -1 +1 -1 +1 -1 +1 -1 +1 figure 3-8. dpll operation in the fm mode 1 18 19 20 17 16 21 22 23 24 25 26 27 28 29 30 31 2 3 4 5 7 8 9 12 13 14 11 10 15 0 no change no change bit cell count correction rx dpll out +1 ignored 6 +1 tx dpll out scc /escc user? manual scc/escc ancillary support circuitry 3-10 3.4 dpll digital phase-locked loop (continued) in fm mode, the transmit clock and receive clock outputs from the dpll are not in phase. this is necessary to make the transmit and receive bit cell boundaries coincide, since the receive clock must sample the data one-fourth and three-fourths of the way through the bit cell. ordinarily, a bit cell boundary occurs between count 15 or count 16, and the dpll receive output causes the data to be sampled at one-fourth and three-fourths of the way through the bit cell. however, four variations can occur: if the bit-cell boundary (from space to mark) occurs any- where during the second half of count 15 or the first half of count 16, the dpll allows the transition without making a correction to its count cycle. if the bit-cell boundary (from space to mark) occurs be- tween the middle of count 16 and the middle of count 19, the dpll is sampling the data too early in the bit cell. in response to this, the dpll extends its count by one during the next 0 to 31 counting cycle, which effectively moves the receive clock edges closer to where they should be. any transitions occurring between the middle of count 19 in one cycle and the middle of count 12 during the next cy- cle are ignored by the dpll. this guarantees that any data transitions in the bit cells do not cause an adjustment to the counting cycle. if no transition occurs between the middle of count 12 and the middle of count 19, the dpll is probably not locked onto the data properly. when the dpll misses an edge, the one clock missing bit is rr10, it is set to 1 and latched. it will hold this value until a reset missing clock command is issued in wr14, or until the dpll is disabled or programmed to enter the search mode. upon missing this one edge, the dpll takes no other action and does not modify its count during the next counting cycle. if the dpll does not see an edge between the middle of count 12 and the middle of count 19 in two successive 0 to 31 count cycles, a line error condition is assumed. if this occurs, the two clocks missing bit in rr10 is set to 1 and latched. at the same time, the dpll enters the search mode. the dpll makes the decision to enter the search mode during count 2, where both the receive clock and transmit clock outputs are low. this prevents any glitches on the clock outputs when the search mode is entered. while in the search mode, no clock outputs are provided by the dpll. the two clocks missing bit in rr10 is latched until a reset missing clock command is issued in wr14, or until the dpll is disabled or programmed to en- ter the search mode. while the dpll is disabled, the transmit clock output of the dpll may be toggled by alternately selecting fm and nrzi mode in the dpll. the same is true of the receive clock. while the dpll is in the search mode, the counter re- mains at count 16 where the receive output is low and the transmit output is low. this fact is used to provide a trans- mit clock under software control since the dpll is in the search mode while it is disabled. as in nrzi mode, if an adjustment to the counting cycle is necessary, the dpll modifies count 5, either deleting it or doubling it. if no adjustment is necessary, the count se- quence proceeds normally. when the dpll is programmed to enter search mode, only clock transitions should exist on the receive data pin. if this is not the case, the dpll may attempt to lock on to the data transitions. if the dpll does lock on to the data transitions, then the missing clock condition will inevitably occur because data transitions are not guaranteed every bit cell. to lock in the dpll properly, fm0 encoding requires con- tinuous 1s received when leaving the search mode. in fm1 encoding, continuous 0s are required; with manches- ter encoded data this means alternating 1s and 0s. with all three of these data encoding methods there is always at least one transition in every bit cell, and in fm mode the dpll is designed to expect this transition. 3.4.3 dpll operation in the manchester mode the scc can be used to decode manchester data by us- ing the dpll in the fm mode and programming the receiv- er for nrz data. manchester encoded data contains a transition at the center of every bit cell; it is the direction of this transition that distinguishes a 1 from a 0. hence, for manchester data, the dpll should be in fm mode (wr14 command d7=1, d6=1, d5=0), but the receiver should be set up to accept nrz data (wr10 d6=0, d5=0). 3.4.4 transmit clock counter (escc only) the escc includes a transmit clock counter which par- allels the dpll. this counter provides a jitter-free clock source to the transmitter by dividing the dpll clock source by the appropriate value for the programmed data encod- ing format as shown in figure 3-9. therefore, in fm mode (fm0 or fm1), the counter output is the input frequency di- vided by 16. in nrzi mode, the counter frequency is the in- put divided by 32. the counter output replaces the dpll transmit clock output, available as the transmit clock source. this has no effect on the use of the dpll as the receive clock source. scc /escc user? manual scc/escc ancillary support circuitry 3-11 3 the output of the transmit clock derived from this counter is available to the /trxc pin when the dpll output is selected as the transmit clock source. care must be taken using escc in sdlc loop mode with the dpll. the sdlc loop mode requires synchronized tx and rx clocks, but the escc? dpll might be off-sync because of this transmit clock counter. in sdlc loop, one should instead echo the signal of the rxdpll out to clock the receiver and transmitter to achieve synchronization. this can be programmed via bits d1-d0 in wr11. 3.5 clock selection the scc can select several clock sources for internal and external use. write register 11 is the clock mode control register for both the receive and transmit clocks. it deter- mines the type of signal on the /sync and /rtxc pins and the direction of the /trxc pin. the scc is programmed to select one of several sources to provide the transmit and receive clocks. the source of the receive clock is controlled by bits d6 and d5 of wr11. the receive clock may be programmed to come from the /rtxc pin, the /trxc pin, the output of the baud rate generator, or the receive output of the dpll. the source of the transmit clock is controlled by bits d4 and d3 of wr11. the transmit clock may be programmed to come from the /rtxc pin, the /trxc pin, the output of the baud rate generator, or the transmit output of the dpll. ordinarily, the /trxc pin is an input, but it can become an output if this pin has not been selected as the source for the transmitter or the receiver, and bit d2 of wr11 is set to 1. the selection of the signal provided on the /trxc out- put pin is controlled by bits d1 and d0 of wr11. the /trxc pin is programmed to provide the output of the crys- tal oscillator, the output of the baud rate generator, the re- ceive output of the dpll or the actual transmit clock. if the output of the crystal oscillator is selected, but the crystal oscillator has not been enabled, the /trxc pin is driven high. the option of placing the transmit clock signal on the /trxc pin when it is an output allows access to the trans- mit output of the dpll. figure 3-10 shows a simplified schematic diagram of the circuitry used in the clock multiplexing. it shows the inputs to the multiplexer section, as well as the various signal in- versions that occur in the paths to the outputs. selection of the clocking options may be done anywhere in the initialization sequence, but the final values must be se- lected before the receiver, transmitter, baud rate genera- tor, or dpll are enabled to prevent problems from arbi- trarily narrow clock signals out of the multiplexers. the same is true of the crystal oscillator, in that the output should be allowed to stabilize before it is used as a clock source. also shown are the edges used by the receiver, transmit- ter, baud rate generator and dpll to sample or send data or otherwise change state. for example, the receiver sam- ples data on the falling edge, but since there is an inver- sion in the clock path between the /rtxc pin and the re- ceiver, a rising edge of the /rtxc pin samples the data for the receiver. the following shows three examples for selecting different clocking options. figure 3-11 shows the clock set up for asynchronous transmission, 16x clock mode using the on- chip oscillator with an external crystal. this example uses the oscillator as the input to the baud rate generator, al- though it can be used directly as the transmit or receive clock source. the registers involved are wr11 through wr14 and the figure shows the programming in these registers. an example of asynchronous communication where a 1x clock is obtained from an external modem is shown in figure 3-12. the data encoding is nrz. note that: 1. the brg is not used under this configuration. figure 3-9. dpll transmit clock counter output (escc only) dpll dpll counter input divided by 16 (fm0 or fm1) input divided by 32 for nrzi dpll output to receiver dpll output to transmitter dpll clk input scc /escc user? manual scc/escc ancillary support circuitry 3-12 3.5 clock selection (continued) 2. the x1 mode in asynchronous mode is a combination of both synchronous and asynchronous transmission. the data is clocked by a common timing base, but characters are still framed with start and stop bits. because the receiver waits for one clock period after detecting the first high-to-low transition before beginning to assemble characters, the data and clock is synchronized externally. the x1 mode is the only mode in which a data encoding method other than nrz is used. figure 3-10. clock multiplexer osc /sync /rtxc osc receiver rx tx dpll brg /trxc baud rate generator out tx dpll out rx dpll out pcl k echo baud rate generator dpll transmitter echo scc /escc user? manual scc/escc ancillary support circuitry 3-13 3 figure 3-11. async clock setup using an external crystal scc b r g 16x output txc rxc /trxc pin /rtxc pin /sync pin external crystal figure 3-12. clock source selection 0 wr14 brg clock source = /rtxc or xtal oscillator d1 d7 d0 wr11 /trxc out = brg output /trxc pin = output pin tx clock = brg output rx clock = brg output using external crystal 1 101 0110 scc nrz data rxd pin sync modem /rtxc pin rxc txc 1x scc /escc user? manual scc/escc ancillary support circuitry 3-14 3.6 crystal oscillator (continued) figure 3-13 shows the use of the dpll to derive a 1x clock from the data. in this example: the dpll clock input = brg output (x16 the data rate) wr14. the dpll clock output = rxc (receiver clock) wr11. set fm mode wr14. set fm mode wr10. 3.6 crystal oscillator each channel contains a high gain oscillator amplifier for use with an external crystal circuit. the amplifier is avail- able between the /rtxc pin (crystal input) and the /sync pin (crystal output) for each channel. the oscillator amplifier is enabled by writing wr11 d7=1. while the crystal oscillator is enabled, anything that has selected the /rtxc pin as its clock source automatically connects to the output of the crystal oscillator. note: the output of the oscillator amplifier can be pro- grammed to output on the /trxc pin, which is particularly valuable for diagnostic purposes. because amplifier char- acteristics can be affected by the impedance of measure- ment equipment applied directly to the crystal circuit, using the /trxc pin allows the oscillation to be tested without af- fecting the circuit. of course, since the oscillator uses the /rtxc and /sync pins, this precludes the use of these pins for other func- tions. in synchronous modes, no sync pulse is output, and the external sync mode cannot be selected. in asynchro- nous modes, the state of the sync/hunt bit in rr0 is no longer controlled by the /sync pin. instead, the sync/hunt bit is forced to 0. the crystal oscillator requires some finite time to stabilize and must be allowed to stabilize before it is used as a clock source. this stabilization time is dependent on the external circuit impedance and 20 ms is a suggested minimum. the external crystal should operate in parallel resonance. for further details on designing with the crystal, refer to appen- dix a, ?n-chip oscillator design? figure 3-13. synchronous transmission, 1x clock rate, fm data encoding, using dpll rxc b r g 16x data rate /rtxc pin /sync pin d p l l txc rxd pin rxd external crystal 4-1 4 u ser s m anual c hapter 4 d ata c ommunication m odes 4.1 introduction the scc provides two independent, full-duplex channels programmable for use in any common asynchronous or synchronous data communication protocol. the data com- munication protocols handled by the scc are: n asynchronous mode: asynchronous (x16, x32, or x64 clock isochronous (x1 clock) n character-oriented mode: monosynchronous bisynchronous external synchronous n bit-oriented mode sdlc/hdlc sdlc/hdlc loop 4.1.1 transmit data path description a diagram of the transmit data path is shown in figure 4-1. the transmitter has a transmit data buffer (a 4-byte deep fifo on the escc, a one byte deep buffer on the nmos/cmos version) which is addressed through wr8. it is not necessary to enable the transmit buffer. it is available in all modes of operation. the transmit shift register is loaded from either wr6, wr7, or the transmit data buffer. in synchronous modes, wr6 and wr7 are programmed with the sync characters. in monosync mode, an 8-bit or 6-bit sync character is used (wr6), whereas a 16-bit sync character is used in the bisynchronous mode (wr6 and wr7). in bit-oriented synchronous modes, the sdlc flag character (7e hex) is programmed in wr7 and is loaded into the transmit shift register at the beginning and end of each message. figure 4-1. transmit data path to other channel tx buffer (1-byte; nmos/cmos) tx fifo (4 byte; escc) wr8 wr6 wr7 20-bit tx shift register final tx mux zero insert 5-bit delay crc-gen nrzi encode transmit mux & 2-bit delay async sync sdlc crc-sdlc transmit clock internal txd txd from receiver internal data bus sync sync register register scc /escc user? manual data communication modes 4-2 4.1 introduction (continued) for asynchronous data, the transmit shift register is for- matted with start and stop bits along with the data; option- ally with parity information bit. the formatted character is shifted out to the transmit multiplexer at the selected clock rate. wr6 & wr7 are not used in asynchronous mode. synchronous data (except sdlc/hdlc) is shifted to the crc generator as well as to the transmit multiplexer. sdlc/hdlc data is shifted to the crc generator and out through the zero insertion logic (which is disabled while the flags are being sent). a 0 is inserted in all address, control, information, and frame check fields following five contigu- ous 1s in the data stream. the result of the crc generator for sdlc data is also routed through the zero insertion log- ic and then to the transmit multiplexer. 4.1.2 receive data path description on the escc, the receiver has an 8-byte deep, 8-bit wide data fifo, while the nmos/cmos version receiver has a 3-byte deep, 8-bit wide data buffer. in both cases, the data buffer is paired with an 8-bit error fifo and an 8-bit shift register. the receive data path is shown in figure 4-2. this arrangement creates a 8-character buffer, allowing time for the cpu to service an interrupt or for the dma to acquire the bus at the beginning of a block of high-speed data. it is not necessary to enable the receive fifo, since it is available in all modes of operation. for each data byte in the receive fifo, a byte is loaded into the error fifo to store parity, framing, and other status information. the error fifo is addressed through read register 1. figure 4-2. receive data path upper byte (wr13) time constant lower byte (wr12) time constant 16-bit down counter div 2 status fifo 10 x 19 frame* brg output rec. data fifo** rec. error fifo** 14-bit counter dpll dpll out hunt mode (bisync) rec. error logic sync register & zero delete receive shift register 3-bit dpll in crc delay register (8 bits) crc checker mux sync crc nrzi decode 1-bit mux to transmit section sdlc-crc internal txd rxd crc result i/o data buffer cpu i/o internal data bus brg input see note see note see note notes: * not with nmos. ** rec. data fifo and rec. error fifo are 8 bytes deep (escc), 3 bytes deep (nmos/cmos). scc /escc user? manual data communication modes 4-3 4 incoming data is routed through one of several paths de- pending on the mode and character length. in asynchro- nous mode, serial data enters the 3-bit delay if a character length of seven or eight bits is selected. if a character length of five or six bits is selected, data enters the receive shift register directly. in synchronous modes, the data path is determined by the phase of the receive process currently in operation. a syn- chronous receive operation begins with a hunt phase in which a bit pattern that matches the programmed sync characters (6-,8-, or 16-bit) is searched. the incoming data then passes through the sync register and is compared to a sync character stored in wr6 or wr7 (depending on which mode it is in). the monosync mode matches the sync character programmed in wr7 and the character assembled in the receive sync register to establish synchronization. synchronization is achieved differently in the bisync mode. incoming data is shifted to the receive shift register while the next eight bits of the message are assembled in the receive sync register. if these two characters match the programmed characters in wr6 and wr7, synchroni- zation is established. incoming data can then bypass the receive sync register and enter the 3-bit delay directly. the sdlc mode of operation uses the receive sync regis- ter to monitor the receive data stream and to perform zero deletion when necessary; i.e., when five continuous 1s are received, the sixth bit is inspected and deleted from the data stream if it is 0. the seventh bit is inspected only if the sixth bit equals one. if the seventh bit is 0, a flag sequence has been received and the receiver is synchronized to that flag. if the seventh bit is a 1, an abort or an eop (end of poll) is recognized, depending upon the selection of either the nor- mal sdlc mode or sdlcloop mode. note: the insertion and deletion of the zero in the sdlc data stream is transparent to the user, as it is done after the data is written to the transmit fifo and before data is read from the receive fifo. this feature of the sdlc/hdlc protocol is to prevent the inadvertent sending of an abort sequence as part of the data stream. it is also valuable to applications using encoded data to insure a sufficient number of edges on the line to keep a dpll synchronized on a receive data stream. the same path is taken by incoming data for both sdlc and sdlc loop modes. the reformatted data enters the 3-bit delay and is transferred to the receive shift register. the sdlc receive operation begins in the hunt phase by attempting to match the assembled character in the re- ceive shift register with the flag pattern in wr7. when the flag character is recognized, subsequent data is routed through the same path, regardless of character length. either the crc-16 or crc-sdlc (cyclic redundancy check or crc) polynomial can be used for both monosync and bisync modes, but only the crc-sdlc polynomial is used for sdlc operation. the data path taken for each mode is also different. bisync protocol is a byte-oriented operation that requires the cpu to decide whether or not a data character is to be included in crc calculation. an 8- bit delay in all synchronous modes except sdlc is al- lowed for this process. in sdlc mode, all bytes are includ- ed in the crc calculation. 4.2 asynchronous mode in asynchronous communications, data is transferred in the format shown in figure 4-3. figure 4-3. asynchronous message format idle state of line lsb 1 0 start bit parity bit data field stop bit(s) 1.5 1 2 scc /escc user? manual data communication modes 4-4 4.2 asynchronous mode (continued) the transmission of a character begins when the line makes a transition from the 1 state (or mark condition) to the 0 state (or space condition). this transition is the ref- erence by which the character? bit cell boundaries are de- fined. though the transmitter and receiver have no com- mon clock signal, they must be at the same data rate so that the receiver can sample the data in the center of the bit cell. the scc also supports isochronous mode, which is the same as asynchronous except that the clock is the same rate as the data. this mode is selected by selecting x1 clock mode in wr4 (d7 & d6=0). using this mode typ- ically requires that the transmit clock source be transmitted along with the data, or that the clock be synchronized with the data. the character can be broken up into four fields: n start bit - signals the beginning of a character frame. n data field - typically 5-8 bits wide. n parity bit - optional error checking mechanism. n stop bit(s) - provides a minimum interval between the end of one character and the beginning of the next. generation and checking of parity is optional and is con- trolled by wr4 d1 & d0. wr4 bit d0 is used to enable par- ity. if wr4 bit d1 is set, even parity is selected and if d1 is reset, odd parity is selected. for even parity, the parity bit is set/reset so that the data byte plus the parity bit contains an even number of 1s. for odd parity, the parity bit is set/reset such that the data byte plus the parity bit contains an odd number of 1s. the scc supports asynchronous mode with a number of programmable options including the number of bits per character, the number of stop bits, the clock factor, modem interface signals, and break detect and generation. asynchronous mode is selected by programming the de- sired number of stop bits in d3 and d2 of wr4. program- ming these two bits with other than 00 places both the re- ceiver and transmitter in asynchronous mode. in this mode, the scc ignores the state of bits d4, d3, and d2 of wr3, bits d5 and d4 of wr4, bits d2 and d0 of wr5, all of wr6 and wr7, and all of wr10 except d6 and d5. ig- nored bits are programmed with 1 or 0 (table 4-1). 4.2.1 asynchronous transmit asynchronous mode is selected by specifying the number of stop bits per character in bits d3 and d2 of wr4. the three options available are one, one-and-a-half, and two stop bits per character. these two bits select only the num- ber of stop bits for the transmitter, as the receiver always checks for one stop bit. the number of bits per transmitted character is controlled both by bits d6 and d5 in wr5 and the way the data is for- matted within the transmit buffer (in the case of the escc, transmit fifo). the bits in wr5 allow the option of five, six, seven, or eight bits per character. in all cases the data must be right-justified, with the unused bits being ignored except in the case of five bits per character. when the five bits per character option is selected, the data may be for- matted before being written to the transmit buffer. this al- lows transmission of from one to five bits per character. the formatting is shown in table 4-2. table 4-1. write register bits ignored in asynchronous mode register d7 d6 d5 d4 d3 d2 d1 d0 wr3 x x x 0 wr4 x x wr5 x x wr6 xxxxxxxx wr7 xxxxxxxx wr10 x xxxxx note: if wr3 d1 is set (enabling the sync character load inhibit feature), any character matching the value in wr6 is stripped out of the incoming data stream and not put into the receive fifo. therefore, as this feature is typically only desired in synchronous formats, this bit should reset in asynchronous mode. scc /escc user? manual data communication modes 4-5 4 an additional bit, carrying parity information, may be auto- matically appended to every transmitted character by set- ting bit d0 of wr4 to 1. this bit is sent in addition to the number of bits specified in wr4 or by bit d1 of wr4. if this bit is set to 1, the transmitter sends even parity and, if set to 0, the parity is odd. the transmitter may be programmed to send a break by setting bit d4 of wr5 to 1. the transmitter will send con- tiguous 0s from the first transmit clock edge after this com- mand is issued, until the first transmit clock edge after this bit is reset. the transmit clock edges referred to here are those that defined transmitted bit cell boundaries. care must be taken when break is sent. as mentioned above, the scc initiates the break sequence regardless of the character boundaries. typically, the break sequence is de- fined as ?ull character (all 0 data) with framing error? the other party may not be able to recognize it as a break se- quence if the send break bit has been set in the middle of sending a non-zero character. an additional status bit for use in asynchronous mode is available in bit d0 of rr1. this bit, called all sent, is set when the transmitter is completely empty and any previous data or stop bits have reached the txd pin. the all sent bit can be used by the processor as an indication that the transmitter may be safely disabled, or indication to change the modem status signal. the scc may be programmed to accept a transmit clock that is one, sixteen, thirty-two, or sixty-four times the data rate. this is selected by bits d7 and d6 in wr4, in com- mon with the clock factor for the receiver. note: when using isosynchronous (x1 clock) mode, one- and-a-half stop bits are not allowed. only one or two stop bits should be selected. if some length other than one stop bit is desired in the times one mode, only two stop bits may be used. also, in this mode, the transmitter usually needs to send clocking information (transmit clock) along with the data in order to receive data correctly. there are two modem control signals associated with the transmitter provided by the scc; /rts and /cts. the /rts pin is a simple output that carries the inverted state of the rts bit (d1) in wr5, unless the auto enables mode bit (d5) is set in wr3. when auto enables is set, the /rts pin immediately goes low when the rts bit is set. however, when the rts bit is reset, the /rts pin remains low until the transmitter is completely empty and the last stop bit has left the txd pin. thus, the /rts pin may be used to disable external drivers for the transmit data. the /cts pin is ordinarily a simple input to the cts bit in rr0. however, if auto enables mode is selected, this pin be- comes an enable for the transmitter. that is, if auto en- ables is on and the /cts pin is high, the transmitter is dis- abled; the transmitter is enabled while the /cts pin is low. the initialization sequence for the transmitter in asynchro- nous mode is wr4 first to select the mode, then wr3 and wr5 to select the various options. at this point the other registers should be initialized as necessary. when all of this is complete, the transmitter may be enabled by setting bit d3 of wr5 to 1. note that the transmitter and receiver may be initialized at the same time. 4.2.1.1 asynchronous transmit on the nmos/cmos on the nmos/cmos version of the scc, characters are loaded from the transmit buffer to the shift register where they are given a start bit and a parity bit (as programmed), and are shifted out to the txd pin. the transmit buffer empty interrupt and the dma request (either /w//req or /dtr//req pin) are asserted when the transmit buffer is empty, if these are enabled. at this time, the cpu or the dma is able to write one byte of transmit data. the trans- mit buffer empty (tbe) bit (rr0, bit d2) also follows the state of the transmit buffer. the all sent bit, rr1, bit d0, can be polled to determine when the last bit of transmit data has cleared the txd pin. for details about the trans- mit dma and transmit interrupts, refer to section 2.4.8 ?ransmit interrupt and transmit buffer empty bit. 4.2.1.2 asynchronous transmit on the escc on the escc, characters are loaded from the transmit fifo to the shift register where they are given a start bit and a parity bit (as programmed), and are shifted out to the txd pin. the escc can generate an interrupt or dma re- quest depending on the status of the transmit fifo. if wr7' d5 is reset, the transmit buffer empty interrupt and dma request (either /w//req or /dtr//req pin) are as- serted when the entry location of the transmit fifo is empty (one byte can be written). if wr7' d5 is set, the transmit interrupt and dma request is generated when the transmit fifo is completely empty (four bytes can be writ- ten). the transmit buffer empty (tbe) bit in rr0, bit d2 also is affected by the state of wr7' bit d5. the all sent table 4-2. transmit bits per character bit 7 bit 6 0 0 1 1 0 1 0 1 5 or less bits/character 7 bits/character 6 bits/character 8 bits/character note: for five or less bits per character selection in wr5, the following encoding is used in the data sent to the transmitter. d is the data bit(s) to be sent. d7 d6 d5 d4 d3 d2 d1 d0 1111000d sends one data bit 111000dd sends two data bits 11000ddd sends three data bits 1000 dddd sends four data bits 0 0 0ddddd sends ?e data bits scc /escc user? manual data communication modes 4-6 4.2 asynchronous mode (continued) bit, bit d0 of rr1, can be polled to determine when the last bit of transmit data has cleared the txd pin. the number of transmit interrupts can be minimized by set- ting bit d5 of wr7' to one and writing four bytes to the transmitter for each transmit interrupt. this requires that the system response to interrupt is less than the time it takes to transmit one byte at the programmed baud rate. if the system? interrupt response time is too long to use this feature, bit d5 of wr7' should be reset to 0. then, poll the tbe bit and poll after each data write to test if there is space in the transmit fifo for more data. for details about the transmit dma and transmit interrupts, refer to section 2.4.8 ?ransmit interrupt and transmit buffer empty bit? 4.2.2 asynchronous receive asynchronous mode is selected by specifying the number of stop bits per character in bits d3 and d2 of wr4. this selection applies only to the transmitter, however, as the receiver always checks for one stop bit. if after character assembly the receiver finds this stop bit to be a 0, the framing error bit in the receive error fifo is set at the same time that the character is transferred to the receive data fifo. this error bit accompanies the data to the exit location (cpu side) of the receive fifo, where it is a spe- cial receive condition. the framing error bit is not latched, so it must be read in rr1 before the accompanying data is read. the number of bits per character is controlled by bits d7 and d6 of wr3. five, six, seven or eight bits per character may be selected via these two bits. data is right justified with the unused bits set to 1s. an additional bit, carrying parity information, may be selected by setting bit d0 of wr4 to 1. note that this also enables parity for the trans- mitter. the parity sense is selected by bit d1 of wr4. if this bit is set to 1, the received character is checked for even parity, and if set to 0, the received character is checked for odd parity. the additional bit per character that is parity is transferred to the receive data fifo along with the data, if the data plus parity is eight bits or less. the parity error bit in the receive error fifo may be programmed to cause special receive interrupts by setting bit d2 of wr1 to 1. once set, this error bit is latched and remains active until an error reset command has been issued. since errors apply to specific characters, it is necessary that error information moves alongside the data that it re- fers to. this is implemented in the scc with an error fifo in parallel with the data fifo. the three error conditions that the receiver checks for in asynchronous mode are: n framing errors?hen a character? stop bit is a 0. n parity errors?he parity bit of a character disagrees with the sense programmed in wr4. n overrun errors?hen the receive fifo overflows. if interrupts are not used to transfer data, the parity error, framing error, and overrun error bits in rr1 should be checked before the data is removed from the receive data fifo, because reading data pops up the error information stored in the error fifo. the scc may be programmed to accept a receive clock that is one, sixteen, thirty-two, or sixty-four times the data rate. this is selected by bits d7 and d6 in wr4. the 1x mode is used when bit synchronization external to the re- ceived clock is present (i.e., the clock recovery circuit, or active receive clock from the sender side). the 1x mode is the only mode in which a data encoding method other than nrz may be used. the clock factor is common to the re- ceiver and transmitter. the break condition is continuous 0s, as opposed to the usual continuous ones during an idle condition. the scc recognizes the break condition upon seeing a null charac- ter (all 0s) plus a framing error. upon recognizing this se- quence, the break bit in rr0 is set and remains set until a 1 is received. at this point, the break condition is no longer present. at the termination of a break, the receive data fifo contains a single null character, which should be read and discarded. the framing error bit will not be set for this character, but if odd parity has been selected, the par- ity error bit is set. note: caution should be exercised if the receive data line contains a switch that is not debounced to generate breaks. if this is the case, switch bounce may cause multi- ple breaks to be recognized by the scc, with additional characters assembled in the receive data fifo and the possibility of a receive overrun condition being latched. the scc provides up to three modem control signals as- sociated with the receiver; /sync, /dtr//req, and /dcd. the /sync pin is a general purpose input whose state is reported in the sync/hunt bit in rr0. if the crystal oscillator is enabled, this pin is not available and the sync/hunt bit is forced to 0. otherwise, the /sync pin may be used to carry the ring indicator signal. the /dtr//req pin carries the inverted state of the dtr bit (d7) in wr5 unless this pin has been programmed to carry a dma request signal. the /dcd pin is ordinarily a simple input to the dcd bit in rr0. however, if the auto enables mode is selected by setting d5 of wr3 to 1, this pin becomes an enable for the scc /escc user? manual data communication modes 4-7 4 receiver. that is, if auto enables is on and the /dcd pin is high, the receiver is disabled; while the /dcd pin is low, the receiver is enabled. received characters are assembled, checked for errors, and moved to the receive data fifo (eight bytes on escc, three bytes on nmos/cmos). the user can program the scc to generate an interrupt to the cpu or to request a data read from a dma when data is received. on the nmos/cmos version, it generates the receive character available interrupt and dma request on re- ceive (if enabled). the receive interrupt and dma request is generated when there is at least one character in the fifo. the rx character available (rca) bit is set if there is at least one byte available. the escc generates the receive character available inter- rupt and dma request on receive (if enabled) and is de- pendent on wr7' bit d3. if this bit is reset to 0 (this mode is comparable to the nmos/cmos version), the receive interrupt and dma request is generated when there is at least one character in the fifo. if wr7' bit d3 is set to 1, the receive interrupt and dma request are generated when there are four bytes available in the receive fifo. the rca bit in rr0 follows the state of wr7' d3. the rca bit is set if there is at least one byte available, regardless of the status of wr7' bit d3. this is the initialization sequence for the receiver in asyn- chronous mode. first, wr4 selects the mode, then wr3 and wr5 select the various options. at this point, the other registers should be initialized as necessary. when all of this is complete, the receiver may be enabled by setting bit d0 of wr3 to 1. see section 2.4.7 ?he receive interrupt?for more details on receive interrupts. 4.2.3 asynchronous initialization the initialization sequence for asynchronous mode is shown in table 4-3. all of the scc? registers should be re- initialized after a channel or hardware reset. also, wr4 should be programmed first after a reset. at this point, the other registers should be initialized ac- cording to the hardware design such as clocking, i/o mode, etc. when this is completed, the transmitter is enabled by setting wr5 bit d3 to 1 and the receiver is en- abled by setting wr3 bit d0 to 1. table 4-3. initialization sequence asynchronous mode reg bit no description wr9 6, 7 hardware or channel reset wr4 3, 2 select async mode and the number of stop bits* 0, 1 select parity* 6, 7 select clock mode* wr3 7, 6 select number of receive bits per character 5 select auto enables mode* wr5 6, 5 select number of bits/char for transmitter 1 select modem control (rts) note: * initializes transmitter and receiver simultaneously. scc /escc user? manual data communication modes 4-8 4.3 byte-oriented synchronous mode the scc supports three byte-oriented synchronous proto- cols. they are: monosynchronous, bisynchronous, and ex- ternal synchronous. in synchronous communications, the bit cell boundaries are referenced to a clock signal common to both the trans- mitter and receiver. consequently, they operate in a fixed- phase relationship. this eliminates the need for the receiv- er to locate the bit cell boundaries with a clock 16, 32, or 64 times the receive data rate, allowing for higher speed communication links. some applications may encode (i.e., nrzi or fm coding) the clock information on the same line as the data. therefore, these applications require that the receiver use a high speed clock to find the bit cell bound- aries (decoding is typically done with the pll?hase- locked loop; the scc has on-chip digital pll). data en- coding eliminates the need to transmit the synchronous clock on a separate wire from the data. synchronous data does not use start and stop bits to de- lineate the boundaries for each character. this eliminates the overhead associated with every character and increas- es the line efficiency. because of the phase relationship of synchronous data to a clock, data is transferred in blocks with no gaps between characters. this requires that there be an agreement as to the location of the character boundaries so that the characters can be properly framed. this is normally accomplished by defining spe- cial synchronization patterns, or sync characters. the synchronization pattern serves as a reference; it signals the receiver that a character boundary occurs immediate- ly after the last bit of the pattern. for example monosync protocol usually uses 16 hex as this special character, and the sdlc protocol uses 0, six 1s, followed by a 0 (7e hex; usually referred to as flag pattern) to mark the be- ginning and end of a block of data. another way of iden- tifying the character boundaries (i.e., achieving synchro- nization) is with a logic signal that goes active just as the first character is about to enter the receiver. this method is referred to as external synchronization. figure 4-4 shows the character format for synchronous transmission. for example, bits 1-8 might be one charac- ter and bits 9-13 part of another character; or, bit 1 might be part of a second character, and bits 10-13 part of a third character. this is accomplished by defining a synchroniza- tion character, commonly called a sync character. 4.3.1 byte-oriented synchronous transmit once synchronous mode has been selected, any of three of the following sync character lengths may be selected: n 6-bit n 8-bit n 16-bit the 6-bit option sync character is selected by setting bits 4 and 5 of wr4 to zeros and bit 0 of wr10 to one. only the least significant six bits of wr6 are transmitted. the 8-bit sync character is selected by setting bits 4 and 5 of wr4 to zeros and bit 0 of wr10 to zeros. with this op- tion selected, the transmitter sends the contents of wr6 when it has no data to send. for a 16-bit sync character, set bit d4 of wr4 to 1 and bit d5 of wr4 and bit d0 of wr10 to 0. in this mode, the transmitter sends the concatenation of wr6 and wr7 for the idle line condition. because the receiver requires that sync characters be left- justified in the registers, while the transmitter requires them to be right justified, only the receiver works with a 12- bit sync character. while the receiver is in external sync figure 4-4. monosync data character format modem clock bit bit state data lsb sync character data character 1 bit time 1 2 3 4 5 6 7 8 9 10 11 12 13 . . . 0 1 1 0 1 0 0 0 1 1 0 1 0 1 0 1 scc /escc user? manual data communication modes 4-9 4 mode, the transmitter sync length may be six or eight bits, as selected by bit d0 of wr10. monosync and bisync modes require clocking information to be transmitted along with the data either by a method of encoding data that contains clocking information, or by a modem that encodes or decodes clock information in the modulation process. refer to the monosync message for- mat shown in figure 4-4. the bisync mode of operation is similar to the monosync mode, except that two sync characters are provided in- stead of one. bisync attempts a more structured approach to synchronization through the use of special characters as message headers or trailers. character-oriented mode is selected by programming bits d3 and d2 of wr4 with zeros. this selects synchronous mode, as opposed to asynchronous mode, but this selec- tion is further modified by bits 5 and 7 of wr4 as well as bits 1 and 0 of wr10. during the sync character-oriented modes, except in external sync mode, the state of bits 7 and 6 of wr4 are always forced internally to zeros. in ex- ternal sync mode, these two bits must be programmed with zeros (table 4-4.). the combination, other than 00 in ex- ternal sync mode, puts the scc in special synchronization modes. in character-oriented modes, a special bit pattern is used to provide character synchronization. the scc offers sev- eral options to support synchronous mode including vari- ous sync generation and checking, crc generation and checking, as well as modem controls and a transmitter to receiver synchronization function. the number of bits per transmitted character is controlled by d6 and d5 of wr5 plus the way the data is formatted within the transmit buffer. the bits in wr5 select the option of five, six, seven, or eight bits per character. in all cases, the data must be right-justified, with the unused bits being ignored except in the case of five bits per character. when the five bits per character option is selected, the data must be formatted before being written to the transmit buffer to allow transmission of from one to five bits per character. this formatting is shown in table 4-2. an additional bit, carrying parity information, may be auto- matically appended to every transmitted character by set- ting bit d0 of wr4 to 1. this parity bit is sent in addition to the number of bits specified in wr4 or by the data format. if this bit is set to 1, the transmitter sends even parity; if set to 0, the transmitted parity is odd. parity is not typically used in synchronous applications because the crc pro- vides a more reliable method for detecting errors. either of two crc polynomials are used in synchronous modes, selected by bit d2 in wr5. if this bit is set to 1, the crc-16 polynomial is used and, if this bit is set to 0, the crc-ccitt polynomial is used. this bit controls the se- lection for both the transmitter and receiver. the initial state of the generator and checker is controlled by bit d7 of wr10. when this bit is set to 1, both the generator and checker have an initial value of all ones; if this bit is set to 0, the initial values are all zeros. the scc does not automatically preset the crc genera- tor in byte synchronous modes, so this must be done in software. this is accomplished by issuing the reset tx crc generator command, which is encoded in bits d7 and d6 of wr0. for proper results, this command is is- sued while the transmitter is enabled and sending sync characters. if the crc is to be used, the transmit crc generator must be enabled by setting bit d0 of wr5 to 1. this bit may also be used to exclude certain characters from the crc calcu- lation. sync characters (from sync registers) are automat- ically excluded from the crc calculation, and any charac- ters written as data are excluded from the calculation by using bit d0 of wr5. internally, enabling or disabling the crc for a particular character happens at the same time the character is loaded from the transmit data buffer (on the escc, the transmit fifo) to the transmit shift regis- ter. thus, to exclude a character from the crc calculation bit, d0 of wr5 is set to 0 before the character is written to the transmit buffer (on the escc, the transmit fifo). escc: since the escc has a four-byte fifo, if a character is to be excluded from the crc calculation, it is recom- mended that only one byte be written to the escc at that time. if wr7' d5 is reset, the transmit interrupt is generated when the fifo is completely empty. this can be used as a signal to reset wr5 bit d0, and then the character can be written to the transmit fifo. this guarantees that the internal disable occurs when the character moves from the buffer to the shift register. table 4-4. registers used in character-oriented modes reg bit no description wr4 3 (=0) select sync mode 2 (=0) 4 (=0) select monosync mode 5 (=0) (8-bit sync character) 4 (=1) select bisync mode 5 (=0) (16-bit sync character) 4 (=1) select external sync mode 5 (=1) (external sync signal required) 6 (=0) select 1x clock mode 7 (=0) wr6 7-0 sync character (low byte) wr7 7-0 sync character (high byte) wr10 1 select sync character length scc /escc user? manual data communication modes 4-10 4.3 byte-oriented synchronous mode (continued) once the buffer becomes empty, the tx crc enable bit is written for the next character. enabling the crc generator is not sufficient to control the transmission of the crc. in the scc, this function is con- trolled by the tx underrun/eom bit, which is reset by the processor and set by the scc. when the transmitter un- derruns (both the transmit buffer and transmit shift regis- ter are empty) the state of the tx underrun/eom bit deter- mines the action taken by the scc. if the tx underrun/eom bit is reset when the underrun occurs, the transmitter sends the accumulated crc and sets the tx underrun/eom bit to indicate this. this transition is pro- grammed to cause an external/status interrupt, or the tx underrun/eom is available in rr0. the reset tx underrun/eom latch command is encoded in bits d7 and d6 of wr0. for correct transmission of the crc at the end of a block of data, this command is issued after the first character is written to the scc but before the transmitter underruns. the command is usually issued im- mediately after the first character is written to the scc so that the crc is sent if an underrun occurs inadvertently during the block of data. 85x30 if wr7' bit d1 is set, the reset transmit underrun/eom latch is automatically reset after the first byte is writ- ten to the transmitter. this eliminates the need for the cpu to issue this command. this feature can be par- ticularly useful to applications using a dma to write data to the transmitter since there is no longer a need to interrupt the data transfers to issue this command. if the transmitter is disabled during the transmission of a character, that character is sent completely. this applies to both data and sync characters. however, if the transmit- ter is disabled during the transmission of the crc, the 16-bit transmission is completed, but the remaining bits will come from the sync registers rather than the remain- der of the crc. there are two modem control signals associated with the transmitter provided by the scc: /rts and /cts. the /rts pin is a simple output that carries the inverted state of the rts bit (d1) in wr5. the /cts pin is ordinarily a simple input to the cts bit in rr0. however, if auto enables mode is selected, this pin becomes an enable for the transmitter. that is, if auto en- ables is on and the /cts pin is high, the transmitter is dis- abled. while the /cts pin is low, the transmitter is enabled. the initialization sequence for the transmitter in character- oriented mode is shown in table 4-5. at this point, the other registers should be initialized as nec- essary. when all of this is completed, the transmitter is en- abled by setting bit 3 of wr5 to one. now that the transmit- ter is enabled, the crc generator is initialized by issuing the reset tx crc generator command in wr0, bits 6-7. 4.3.2 byte-oriented synchronous receive the receiver in the scc searches for character synchroni- zation only while it is in hunt mode. in this mode the receiv- er is idle except that it is searching the incoming data stream for a sync character match. in hunt mode, the receiver shifts for each bit into the re- ceive shift register. the contents of the receive shift reg- ister are compared with the sync character (stored in an- other register), repeating the process until a match occurs. when a match occurs, the receiver begins transferring bytes to the receive fifo. the receiver is in hunt mode when it is first enabled, and it may be placed in hunt mode by the processor issuing the enter hunt mode command in wr3. this bit (d4) is a com- mand, so writing a 0 to it has no effect. the hunt status of the receiver is reported by the sync/hunt bit in rr0. sync/hunt is one of the possible sources of external/status interrupts, with both transitions causing an interrupt. this is true even if the sync/hunt bit is set as a result of the pro- cessor issuing the enter hunt mode command. once the sync character-oriented mode has been select- ed, any of the four sync character lengths may be selected: 6 bits, 8 bits, 12 bits, or 16 bits. the table 4-6 shows the write register bit setting for se- lecting sync character length. table 4-5. transmitter initialization in character- oriented mode reg bit no description wr4 0,1 selects parity (not typically used insync modes) wr5 1 rts 2 selects crc generator 5,6 selects number of bits per character wr10 7 crc preset value scc /escc user? manual data communication modes 4-11 4 the arrangement of the sync character in wr6 and wr7 is shown in figure 4-5. for those applications requiring any other sync character length, the scc makes provision for an external circuit to provide a character synchronization signal on the /sync pin. this mode is selected by setting bits d5 and d4 of wr4 to 1. in this mode, the sync/hunt bit in rr0 reports the state of the /sync pin, but the receiver is still placed in hunt mode when the external logic is searching for a sync character match. two receive clock cycles after the last bit of the sync character is received, the receiver is in hunt mode and the /sync pin is driven low, then character as- sembly begins on the rising edge of the receive clock. this immediately precedes the activation of /sync (figure 4- 6). the receiver leaves hunt mode when /sync is driven low. table 4-6. sync character length selection sync length wr4,d5 wr4,d4 wr10,d0 6 bits 0 0 1 8 bits 0 0 0 12 bits 0 1 1 16 bits 0 1 0 figure 4-5. sync character programming d6 d7 d5 d4 d3 d2 d1 d0 sync7 sync1 sync7 sync3 adr7 adr7 sync6 sync0 sync6 sync2 adr6 adr6 sync5 sync5 sync5 sync1 adr5 adr5 sync4 sync4 sync4 sync0 adr4 adr4 sync3 sync3 sync3 1 adr3 x sync2 sync2 sync2 1 adr2 x sync1 sync1 sync1 1 adr1 x sync0 sync0 sync0 1 adr0 x monosync, 8 bits monosync, 6 bits bisync, 16 bits bisync, 12 bits sdlc sdlc (address range) write register 6 d6 d7 d5 d4 d3 d2 d1 d0 sync7 sync5 sync15 sync11 0 sync6 sync4 sync14 sync10 1 sync5 sync3 sync13 sync9 1 sync4 sync2 sync12 sync8 1 sync3 sync1 sync11 sync7 1 sync2 sync0 sync10 sync6 1 sync1 x sync9 sync5 1 sync0 x sync8 sync4 0 monosync, 8 bits monosync, 6 bits bisync, 16 bits bisync, 12 bits sdlc write register 7 figure 4-6. /sync as an input /rtxc /sync sync last-1 rxd sync last data 2 data 1 data 0 scc /escc user? manual data communication modes 4-12 4.3 byte-oriented synchronous mode (continued) in all cases except external sync mode, the /sync pin is an output that is driven low by the scc to signal that a sync character has been received. the /sync pin is activated regardless of character boundaries, so any external circuitry using it should only respond to the /sync pulse that occurs while the receiver is in hunt mode. the timing for the /sync signal is shown in figure 4-7. to prevent sync characters from entering the receive data fifo, set the sync character load inhibit bit (d1) in wr3 to 1. while this bit is set to 1, characters about to be loaded into the receive data fifo are compared with the contents of wr6. if all eight bits match the character, it is not loaded into the receive data fifo. because the comparison is across eight bits, this function should only be used with 8- bit sync characters. it cannot be used with 12- or 16-bit sync characters. both leading sync characters are re- moved in the case of a 6-bit sync character. care must be exercised in using this feature because sync characters which are not transferred to the receive data fifo will au- tomatically be excluded from crc calculation. this works properly only in the 8-bit case. the number of bits per character is controlled by bits d7 and d6 of wr3. five, six, seven, or eight bits per character may be selected via these two bits. the data is right-justi- fied in the receive data buffer. the scc merely takes a snapshot of the receive data stream at the appropriate times, so the ?nused?bits in the receive buffer are only the bits following the character in the data stream. an additional bit carrying parity information is selected by setting bit d0 of wr4 to 1. note that this also enables par- ity for the transmitter. the bit d1 of wr4 selects parity sense. if this bit is set to 1, the received character is checked for even parity. if wr4 d1 is reset to 0, the re- ceived character is checked for odd parity. the additional bit per character is transferred to the fifo as a part of data when the data plus parity is less than 8 bits per character. the parity error bit in the receive error fifo may be pro- grammed to cause a special receive condition interrupt by setting bit d2 of wr1 to 1. once set, this error bit is latched and remains active until an error reset command has been issued. if interrupts are not used to transfer data, the parity error, crc error, and overrun error bits in rr1 should be checked before the data is removed from the re- ceive data fifo. the character length can be changed at any time before the new number of bits has been assembled by the receiver, but, care should be exercised as unexpected results may occur. a representative example would be switching from five bits to eight bits and back to five bits (figure 4-8). figure 4-7. /sync as an output state changes in one /rtxc clock cycle /rtxc pclk /sync scc /escc user? manual data communication modes 4-13 4 either of two crc polynomials are used in synchronous modes, selected by bit d2 in wr5. if this bit is set to 1, the crc-16 polynomial is used, if this bit is set to 0, the crc- ccitt polynomial is used. this bit controls the polynomial selection for both the receiver and transmitter. the initial state of the generator and checker is controlled by bit d7 of wr10. when this bit is set to 1, both the gen- erator and checker have initial values of all ones; if this bit is set to 0, the initial values are all 0. the scc presets the checker whenever the receiver is in hunt mode so a crc reset command is not necessary. however, there is a re- set crc checker command in wr0. this command is en- coded in bits d7 and d6 of wr0. if the crc is used, the crc checker is enabled by setting bit d0 of wr3 to 1. sync characters can be stripped from the data stream any time before the first non-sync character is received. if the sync strip feature is not being used, the crc is not en- abled until after the first data character has been trans- ferred to the receive data fifo. as previously mentioned, 8-bit sync characters stripped from the data stream are au- tomatically excluded from crc calculation. some synchronous protocols require that certain charac- ters be excluded from crc calculation. this is possible in the scc because crc calculations are enabled and dis- abled on the fly. to give the processor sufficient time to de- cide whether or not a particular character should be includ- ed in the crc calculation, the scc contains an 8-bit time delay between the receive shift register and the crc checker. the logic also guarantees that the calculation only starts or stops on a character boundary by delaying the enable or disable until the next character is loaded into the receive data fifo. because the nature of the protocol requires that crc calculation disable/enable be selected before the next character gets loaded into the receive fifo, users cannot take advantage of the fifo. to understand how this works refer to figure 4-9 and the following explanation. consider a case where the scc receives a sequence of eight bytes, called a, b, c, d, e, f, g and h, with a received first. now suppose that a is the sync character, the crc is calculated on b, c, e, and f, and that f is the last byte of this message. this process is used to control the scc. figure 4-8. changing character length 654321 receive data buffer 7 8 11109876 12 13 19 18 17 16 15 14 20 21 27 26 25 24 23 22 28 29 32 31 30 29 28 27 33 34 37 36 35 34 33 32 38 39 time change from five to eight change from eight to five 5 bits 5 bits 5 bits 8 bits 8 bits scc /escc user? manual data communication modes 4-14 4.3 byte-oriented synchronous mode (continued) before a is received, the receiver is in hunt mode and the crc is disabled. when a is in the receive shift register, it is compared with the contents of wr7. since a is the sync character, the bit patterns match and receive leaves hunt mode, but character a is not transferred to the receive data fifo. after eight-bit times, b is loaded into the receive data fifo. the crc remains disabled even though some- where during the next eight bit times the processor reads b and enables the crc. at the end of this eight-bit time, b is in the 8-bit delay and c is in the receive shift register. character c is loaded into the receive data fifo and at the same time the crc checker becomes enabled. during the next eight-bit time, the processor reads c and since the crc is enabled within this period, the scc has calculated the crc on b, character c is the 8-bit delay, and d is in the receive shift register. d is then loaded into the receive data fifo and at some point during the next eight-bit time the processor reads d and disables the crc. at the end of these eight-bit times, the crc has been calculated on c, character d is in the 8-bit delay, and e is in the receive shift register. now e is loaded into the receive data fifo. during the next eight-bit time, the processor reads e and enables the crc. during this time e shifts into the 8-bit delay, f enters the receive shift register and the crc is not being calcu- lated on d. after these eight-bit times have elapsed, e is in the 8-bit delay, and f is in the receive shift register. now f is transferred to the receive data fifo and the crc is enabled. during the next eight-bit times, the processor reads f and leaves the crc enabled. the processor de- tects that this is the last character in the message and pre- pares to check the result of the crc computation. howev- er, another sixteen bit-times are required before the crc has been calculated on all of character f. at the end of eight-bit times, f is in the 8-bit delay and g is in the receive shift register. at this time, it is transferred to the receive data fifo. character g is read and discarded by the processor. eight-bit times later, h is also transferred to the receive data fifo. the result of a crc calculation is latched in to the receive error fifo at the same time as data is written to the receive data fifo. thus, the crc result through character f accompanies character h in the fifo and will be valid in rr1 until character h is read from the receive data fifo. the crc checker is disabled and reset at any time after character h is transferred to the re- ceive data fifo. recall, however, that internally the crc is not disabled until after this occurs. a better alternative is to place the receiver in hunt mode, which automatically disables and resets the crc checker. see table 4-7 for a condensed description. figure 4-9. receive crc data path receive data fifo receive shift register crc checker eight bit time delay receive data 3 bytes deep for nmos/cmos 8 bytes deep for escc scc /escc user? manual data communication modes 4-15 4 modem controls. up to two modem control signals asso- ciated with the receiver are available in synchronous modes: /dtr//req and /dcd. the /dtr//req pin carries the inverted state of the dtr bit (d7) in wr5 unless this pin has been programmed to carry a dma request on transmit signal. the /dcd pin is ordinarily a simple input to the dcd bit in rr0. however, if the auto enables mode is selected by setting d5 of wr3 to 1, this pin becomes an enable for the receiver. therefore, if auto enables is on and the /dcd pin is high, the receiver is disabled; while the /dcd pin is low, the receiver is enabled. note that with auto enables mode enabled, when /dcd goes inactive, the receiver stops immediately and the character being assembled is lost. initialization. the initialization sequence for the receiver in character-oriented mode is wr4 first, to select the mode, then wr10 to modify it if necessary; wr6 and wr7 to program the sync characters; wr3 and wr5 to select the various options. at this point the other registers are ini- tialized as necessary. when all this is completed, the re- ceiver is enabled by setting bit d0 of wr3 to a one. a sum- mary is shown in table 4-8. a detailed example of using the scc in 16-bit sync mode is available in the application note ?cc in binary synchronous communications. scc /escc user? manual data communication modes 4-16 4.3 byte-oriented synchronous mode (continued) table 4-7. enabling and disabling crc direction of dat a coming into sc c shift registe r delay registe r crc note s h g f e d c b h g f e d c h g f e d c cpu read cpu enables c r h g f e d cpu read h g f e cpu read cpu disables c r h g f cpu read cpu enables c r h g cpu read h cpu reads & disc a read rr1 d read h & disca ad d b bd c d e f g h c d* e f g b c d e f e e d e e h g e h crc calc on b crc calc on c crc calc is disabled on d crc calc on e crc calc on f crc calc on f result latched in error fifo ? * usually d is a end-of-message character indicator. ? the status is latched on the error fifo for each received byte. in the calculation of f, the crc error flag in the error fifo will be 0 for an error free message. d = disabled e = enabled a b c d e f g h a = sync b - f = data with e = crc1 and f = crc2 g and h are arbitrary data (pad character) legend: a note: no crc calculation on "d" (sync) b (data1) c (data2) d (data3) e (crc1) f (crc2) g (data) h (data) stag e 1 2 3 4 5 receive data fif o scc /escc user? manual data communication modes 4-17 4 4.3.3 transmitter/receiver synchronization the scc contains a transmitter-to-receiver synchronization function that is used to guarantee that the character boundaries for the received and transmitted data are the same. in this mode, the receiver is in hunt and the transmitter is idle, sending either all 1s or all 0s. when the receiver recognizes a sync character, it leaves hunt mode; one character time later the transmitter is enabled and begins sending sync characters. beyond this point the receiver and transmitter are again completely independent, except that the character boundaries are now aligned (figure 4-10). there are several restrictions on the use of this feature in the scc. first, it only works with 6-bit, 8-bit or 16-bit sync characters. the data character length for both the receiver and the transmitter must be six bits with 6-bit sync charac- ter, and eight bits with an 8-bit or 16-bit sync character. of course, the receive and transmit clocks must have the same rate as well as the proper phase relationship. a specific sequence of operations must be followed to syn- chronize the transmitter to the receiver. both the receiver and transmitter must have been initialized for operation in synchronous mode sometime in the past, although this ini- tialization need not be redone each time the transmitter is synchronized to the receiver. the transmitter is disabled by setting bit d3 of wr5 to 0. at this point the transmitter will send continuous 1s. if it is required that continuous table 4-8. initializing the receiver in character-oriented mode bit number reg d7 d6 d5 d4 d3 d2 d1 d0 description wr4 000x0000 select x1 clock, enable sync mode, & no parity x=0 for 8-bit sync, x=1 for 16-bit sync wr3 r x011000 rx=# of rx bits/char, no auto enable, enter hunt, enable rx crc, no sync character load inhibit wr5 d t x 0 0 0 r 1 d=inverse state of dtr pin, tx=# of tx bits/char, use crc-16, r=inverse state of /rts pin, crc enable wr6 xxxxxxxx sync character, lower byte wr7 xxxxxxxx sync character, upper byte wr10 c 0 0 0 i 0 0 s c=crc preset, nrz data, i=idle line condition s=size of sync character wr3 r x011001 enable receiver wr5 d t x 0 1 0 r 1 enable transmitter wr0 10000000 reset crc generator figure 4-10. transmitter to receiver synchronization receiver leaves hunt sync sync rxd txd sync sync direction of message flow scc /escc user? manual data communication modes 4-18 4.3 byte-oriented synchronous mode (continued) 0s be transmitted, the send break bit (d4) in wr5 is set to 1. the transmitter is now idling but is still placed in the transmitter to receiver synchronization mode. this is ac- complished by setting the loop mode bit (d1) in wr10 and then enabling the transmitter by setting bit d3 of wr5 to 1. at this point, the processor should set the go active on poll bit (d4) in wr10. the final step is to force the receiver to search for sync characters. if the receiver is currently disabled, the receiver enters hunt mode when it is enabled, by setting bit d0 of wr3 to 1. if the receiver is already enabled, it is placed in hunt mode by setting bit d4 of wr3 to 1. once the receiver leaves hunt mode, the transmitter is activated on the following character boundary. 4.4 bit-oriented synchronous (sdlc/hdlc) mode synchronous data link control mode (sdlc) uses syn- chronization characters similar to bisync and monosync modes (such as flags and pad characters). it is a bit-orient- ed protocol instead of a byte-oriented protocol. high level data link control (hdlc) is defined as ccitt, also eiaj and other standards; sdlc is one of the implementations made by ibm . the sdlc protocol uses the technique of zero insertion to make all data transparent from sync characters. all references to sdlc in this manual apply to both sdlc and hdlc. the basic format for sdlc is a frame (figure 4-11). a frame is marked at the beginning and end by a unique flag pattern. the flags enclose an address, control, information, and frame check fields. there are many different implementations of the sdlc protocol and many do not use all of the fields. the scc provides many features to control how each of the fields is received and transmitted. frames of information are enclosed by a unique bit pattern called a flag. the flag character has a bit pattern of ?1111110?(7e hex). this sequence of six consecutive ones is unique because all data between the opening and closing flags is prohibited from having more than five con- secutive 1s. the transmitter guarantees this by watching the transmit data stream and inserting a 0 after five con- secutive 1s, regardless of character boundaries. in turn, the receiver searches the receive data stream for five con- secutive 1s and deletes the next bit if it is a 0. since the sdlc mode does not use characters of defined length, but rather works on a bit-by-bit basis, the 01111110 flag can be recognized at any time. inserted and removed 0s are not included in the crc calculation. since the transmis- sion of the flag character is excluded from the zero inser- tion logic, its transmission is guaranteed to be seen as a flag by the receiver. the zero insertion and deletion is completely transparent to the user. because of the zero insertion/deletion, actual bit length on the transmission line may be longer than the number of bits sent. the two flags that delineate the sdlc frame serve as ref- erence points when positioning the address and control fields, and they initiate the transmission error check. the ending flag indicates to the receiving station that the 16- bits just received constitute the frame check (crc; also re- ferred to as fcs or frame check sequence). the ending flag can be followed by another frame, another flag, or an idle. this means that when two frames follow one another, the intervening flag may simultaneously be the ending flag of the first frame and the beginning flag of the next frame. this case is usually referred to as ?ack-to-back frames? the scc? sdlc address field is eight bits long and is used to designate which receiving stations accept a trans- mitted message. the 8-bit address allows up to 254 (00000001 through 11111110) stations to be addressed uniquely or a global address (11111111) is used to broad- cast the message to all stations. address 0 (00000000) is usually used as a test packet address. the control field of a sdlc frame is typically 8 bits, but can be any length. the control field is transparent to the scc figure 4-11. sdlc message format beginning flag 01111110 8 bits frame check 16 bits information any number of bits address 8 bits control 8 bits ending flag 01111110 8 bits frame scc /escc user? manual data communication modes 4-19 4 and is treated as normal data by the transmit and receive logic. the information field is not restricted in format or content and can be of any reasonable length (including zero). its maximum length is that which is expected to arrive at the receiver error-free most of the time. hence, the determina- tion of maximum length is a function of the communication channel? error rate. usually the upper layer of the protocol specifies the packet size. although the data is always writ- ten/read in a given character size, the residue code fea- ture provides the mechanism to read any number of bits at the end of the frame that do not make up a full character. this allows for the data field to be an arbitrary number of bits long. the frame check field is used to detect errors in the received address, control and information fields. the method used to test if the received data matches the transmitted data, is called a cyclic redundancy check (crc). the scc has an option to select between two crc polynomials, and in sdlc mode only the crc-ccitt polynomial is used because the transmitter in the scc automatically inverts the crc before transmission. to compensate for this, the receiver checks the crc result for the bit pattern 0001110100001111. this is consistent with bit-oriented protocols such as sdlc, hdlc, and adccp and the others. there are two unique bit patterns in sdlc mode besides the flag sequence. they are the abort and eop (end of poll) sequence. an abort is a sequence of seven to thir- teen consecutive 1s and is used to signal the premature termination of a frame. the eop is the bit pattern 11111110, which is used in loop applications as a signal to a secondary station that it may begin transmission. sdlc mode is selected by setting bit d5 of wr4 to 1 and bits d4, d3, and d2 of wr4 to 0. in addition, the flag se- quence is written to wr7. additional control bits for sdlc mode are located in wr10 and wr7' (85x30). 4.4.1 sdlc transmit in sdlc mode, the transmitter moves characters from the transmitter buffer (on the escc, four-byte transmitter fifo) to the transmit shift register, through the zero in- serter and out to the txd pin. the insertion of zero is com- pletely transparent to the user. zero insertion is done to all transmitted characters except the flag and abort. a sdlc frame must have the 01111110 (7e hex) flag se- quence transmitted before the data. this is done automat- ically by the scc by programming wr7 with 7eh as part of the device initialization, enabling the transmitter, and then writing data. if the scc is programmed to idle mark (wr10 d3=1), special consideration must be taken to transmit the opening flag. ordinarily, it is necessary to re- set the wr10 d3 to idle flag, wait 8-bit times, and then write data to the transmitter. it is necessary to wait eight bit times before writing data because ?s?are transmitted eight at a time and all eight must leave the transmit shift register before a flag is loaded. the escc has two improvements over the nmos/cmos version to control the transmission of the flag at the begin- ning of a frame. additionally, the escc has improved fea- tures to ease the handling of sdlc mode of operation, in- cluding a function to deactivate the /rts signal at the end of the packet automatically. for these features, refer to the next subsection, 4.4.1.2, ?scc enhancements for sdlc transmit. the number of bits per transmitted character is controlled by bits d6 and d5 of wr5 and the way the data is format- ted within the transmit buffer. the bits in wr5 allow the op- tion of five, six, seven, or eight bits per character. in all cas- es, the data must be right justified, with the unused bits being ignored, except in the case of five bits per character. when five bits per character are selected, the data may be formatted before being written to the transmit buffer. this allows transmission of one to five bits per character (table 4-2). an additional bit, carrying parity information, is automati- cally appended to every transmitted character by setting bit d0 of wr4 to 1. this bit is sent in addition to the number of bits specified in wr4 or by the data format. the parity sense is selected by bit d1 of wr4. parity is not normally used in sdlc mode as the overhead of parity is unneces- sary due to the availability of the crc. the scc transmits address and control fields as normal data and does not automatically send any address or con- trol information. the value programmed into wr6 is used by the receiver to compare the address of the received frame (if address search mode is enabled), but wr6 is not used by the transmitter. therefore, the address is written to the transmitter as the first byte of data in the frame. the information field can be any number of characters long. on the nmos/cmos version, the transmitter can in- terrupt the cpu when the transmit buffer is empty. on the escc, the transmitter can interrupt the cpu when the en- try location of the transmit fifo is empty or when the transmit fifo is completely empty. also, the nmos/cmos version can issue a dma request when the transmit buffer is empty, while the escc can issue a dma request when the entry location of the transmit fifo is empty or when the transmit fifo is completely empty. this allows the escc user to optimize the response to the application requirements. since the escc has a four byte transmit fifo buffer, the transmit buffer empty (tbe) bit (d2 of rr0) will become set when the entry location of the transmit fifo becomes empty. the tbe bit will reset when a byte of data is loaded into the entry location of the transmit fifo. for more details on this subject, refer to scc /escc user? manual data communication modes 4-20 4.3 byte-oriented synchronous mode (continued) section 2.4.8 ?ransmit interrupts and transmit buffer empty bit? the character length may be changed on the fly, but the desired length must be selected before the character is loaded into the transmit shift register from the transmit data fifo. the easiest way to ensure this is to write to wr5 to change the character length before writing the data to the transmit buffer. note that although the charac- ter can be any length, most protocols specify the ad- dress/control field as 8-bit fields. the scc receiver checks the address field as 8-bit, if address search mode is enabled. only the crc-ccitt polynomial is used in sdlc mode. this is selected by setting bit d2 in wr5 to 0. this bit con- trols the selection for both the transmitter and receiver. the initial state of the generator and checker is controlled by bit d7 of wr10. when this bit is set to 1, both the gen- erator and checker have an initial value of all 1s, and if this bit is set to 0, the initial values are all 0s. the scc does not automatically preset the crc genera- tor, so this is done in software. this is accomplished by is- suing the reset tx crc command, which is encoded in bits d7 and d6 of wr0. for proper results, this command is issued while the transmitter is enabled and idling. if the crc is to be used, the transmit crc generator is enabled by setting bit d0 of wr5 to 1. the crc is normally calcu- lated on all characters between opening and closing flags, so this bit is usually set to 1 at initialization and never changed. on the 85x30 with auto eom latch reset mode enabled (wr7' bit d1=1), resetting of the crc generator is done automatically. enabling the crc generator is not sufficient to control the transmission of the crc. in the scc, this function is con- trolled by tx underrun/eom bit, which may be reset by the processor and set by scc. on the 85x30 with auto eom reset mode enabled (wr7' bit d1=1), resetting of the tx underrun/eom latch is done automatically. ordinarily, a frame is terminated with a crc and a flag, but the scc may be programmed to send an abort and a flag in place of the crc. this option allows the scc to abort a frame transmission in progress if the transmitter is acci- dentally allowed to underrun. this is controlled by the abort/flag on underrun bit (d2) in wr10. when this bit is set to 1, the transmitter will send an abort and a flag in place of the crc when an underrun occurs. the frame is terminated normally with a crc and a flag if this bit is 0. the scc is also able to send an abort by a command from the processor. when the send abort command is issued in wr0, the transmitter sends eight consecutive 1s and then idles. since up to five consecutive 1s may be sent pri- or to the command being issued, a send abort causes a sequence of from eight to thirteen 1s to be transmitted. the send abort command also clears the transmit data fifo. when transmitting in sdlc mode, note that all data pass- es through the zero inserter, which adds an extra five bit times of delay between the transmit shift register and the txd pin. when the transmitter underruns (both the transmit fifo and transmit shift register are empty), the state of the tx underrun/eom bit determines the action taken by the scc. if the tx underrun/eom bit is set to 1 when the underrun occurs, the transmitter sends flags without sending the crc. if this bit is reset to 0 when the underrun occurs, the transmitter sends either the accumulated crc followed by flags, or an abort followed by flags, depending on the state of the abort/flag on the underrun bit in the wr10, bit d1. a summary is shown in table 4-9. the reset tx underrun/eom latch command is encoded in bits d7 and d6 of wr0. the scc sets the tx underrun/eom latch when the crc or abort is loaded into the shift register for transmission. this event can cause an interrupt, and the status of the tx underrun/eom latch can be read in rr0. resetting the tx underrun/eom latch is done by the pro- cessor via the command encoded in bits d7 and d6 of wr0. on the 85x30, this also can be accomplished by set- ting wr7' bit d1 for auto tx underrun/eom latch reset mode enabled. for correct transmission of the crc at the end of a frame, this command must be issued after the first character is written to the scc but before the transmitter underruns after the last character written to the scc. the command is usually issued immediately after the first char- acter is written to the scc so that the abort or crc is sent if an underrun occurs inadvertently. the abort/flag on un- derrun bit (d2) in wr10 is usually set to 1 at the same time as the tx underrun/eom bit is reset so that an abort is sent if the transmitter underruns. the bit is then set to 0 table 4-9. escc action taken on tx underrun tx underrun /eom latch bit abort/flag action taken by escc upon transmit underrun 0 0 sends crc followed by ?g 0 1 sends abort followed by ?g 1 x sends ?g scc /escc user? manual data communication modes 4-21 4 near the end of the frame to allow the correct transmission of the crc. in this paragraph the term ?ompletely sent?means shifted out of the transmit shift register, not shifted out of the zero inserter, which is an additional five bit times of delay. in sdlc mode, if the transmitter is disabled during transmis- sion of a character, that character will be ?ompletely sent. this applies to both data and flags. however, if the trans- mitter is disabled during the transmission of the crc, the 16-bit transmission will be completed, but the remaining bits are from the flag register rather than the remainder of the crc. the initialization sequence for the transmitter in sdlc mode is: 1. wr4 selects the mode. 2. wr10 modifies it if necessary. 3. wr7 programs the flag. 4. wr3 and wr5 selects the various options. at this point the other registers should be initialized as nec- essary. when all of this is complete, the transmitter may be enabled by setting bit d3 of wr5 to 1. now that the trans- mitter is enabled, the crc generator may be initialized by issuing the reset tx crc generator command in wr0. 4.4.1.1 modem control signals related to sdlc transmit there are two modem control signals associated with the transmitter provided by the scc. the /rts pin is a simple output that carries the inverted state of the rts bit (d1) in wr5. the /cts pin is ordinarily a simple input to the cts bit in rr0. however, if auto enables mode is selected, this pin becomes an enable for the transmitter. if auto enables is on and the /cts pin is high, the transmitter is disabled. the transmitter is enabled if the /cts pin is low. 4.4.1.2 escc enhancements for sdlc transmit the escc has the following enhancements available in the sdlc mode of operation which can reduce cpu over- head dramatically. these features are: n deeper transmit fifo (four bytes) n crc takes priority over the data n auto eom reset (wr7' bit d1) n auto tx flag (wr7' bit d0) n auto rts deactivation (wr7' bit d2) n txd pin forced high after closing flag in nrzi mode deeper transmit fifo: the escc has a four byte deep transmit fifo, where the nmos/cmos version has a one byte deep transmit buffer. to maximize the system? performance, there are two modes of operation for the transmit interrupt and dma request, which are pro- grammed by bit d5 of wr7'. the escc sets wr7' bit d5 to 1 following a hardware or software reset. this is done to provide maximum compat- ibility with existing scc designs. in this mode, the escc generates the transmit buffer empty interrupt and dma transmit request when the transmit fifo is completely empty. interrupt driven systems can maximize efficiency by writing four bytes for each entry into the transmit inter- rupt service routine (tisr), filling the transmit fifo with- out having to check any status bits. since the tbe status bit is set if the entry location of the fifo is empty, this bit can be tested at any time if more data is written. applica- tions requiring software compatibility with the nmos/cmos version can test the tbe bit in the tisr af- ter each data write to determine if more data can be writ- ten. this allows a system with an escc to minimize the number of transmit interrupts, but not overflow scc sys- tems. dma driven systems originally designed for the scc can use this mode to reassert the dma request for more data after the first byte written to the fifo is loaded to the transmit shift register. consequently, any subsequent re- assertion allows the dma sufficient time to detect the high- to-low edge. if wr7' d5 is reset to 0, the transmit buffer empty interrupt and dma request are generated when the entry location of the fifo is empty. therefore, if more than one byte is re- quired to fill the entry location of the fifo, the escc gen- erates interrupts or dma requests until the entry location of the fifo is filled. the transmit dma request pin (either /wait//req or /dtr//req) goes inactive after each data transfer, then goes active again and, consequently, gener- ates a high-to-low edge for each byte. edge triggered dma should be enabled before the transmit dma function is enabled in the escc to guarantee that the escc does not generate the edge before the dma is ready. crc takes priority over data: on the nmos/cmos version, the data has higher priority over crc data. writ- ing data before the tx interrupt, after loading the closing flag into the transmit shift register, terminates the packet illegally. in this case, crc byte(s) are replaced with flag or sync patterns, followed by the data written. on the es- cc, crc has priority over the data. consequently, after the underrun/eom (end of message) interrupt occurs, the escc accepts the data for the next packet without fear of collapsing the packet. on the escc, if data was written during the time period described above, the tbe bit (bit d2 of rr0) is not set; even if the 2nd txip is guaranteed to set when the flag/sync pattern is loaded into the transmit shift register (section 2.4.8). for the detailed timing on this, refer to figures 2-17 and 2-18. scc /escc user? manual data communication modes 4-22 4.3 byte-oriented synchronous mode (continued) hence, on the escc, there is no need to wait for the 2nd txip bit to set before writing data for the next packet which reduces the overhead. auto eom reset (wr7' bit d1): as described above, the tx underrun/eom latch has to be reset before the trans- mit shift register completes shifting out the last character, but after first character has been written. one of the ways to reset it is for the cpu to issue the ?eset tx under- run/eom latch?command. the other method to accom- plish it is by the ?utomatic eom latch reset feature?by setting bit d1 in wr7', which is one of the enhancements made to the escc. by setting this bit to one, it eliminates the need for the cpu command. in this mode, the crc generator is automatically reset at the start of every pack- et, without the cpu command. hence, it is not required to reset the crc generator prior to writing data into the es- cc. this is particularly valuable to a dma driven system where issuing cpu commands while the dma is transfer- ring data is difficult. also, it is very useful if the data rate is very high and the cpu may not be able to issue the com- mand on time. auto tx flag (wr7' bit d0): with the nmos/cmos ver- sion of the scc, in order to accomplish mark idle, it is re- quired to enable the transmitter as mark idle; then re-pro- gram to flag idle before writing first data, and then reprogram again to mark idle as described above. normal- ly, during mark idle, the transmitter sends continuous flags, but the escc can idle mark under program control. by setting the mark/flag idle bit (d3) in wr10 to 1, the transmitter sends continuous 1s in place of the idle flags. the closing flag always transmits correctly even when this mode is selected. normally, it is necessary to reset wr10 d3 to 0 before writing data for the next frame. however, on the escc, if wr7' bit d0 is set to 1, an opening flag is transmitted automatically and it is not necessary for the cpu to turn the mark idle feature on and off between frames. note: when this mode in not in effect (wr7' d0=0), the mark/flag idle bit is clear to 0, allowing a flag to be trans- mitted before data is written to the transmit buffer. care must be exercised in doing this because the continuous 1s are transmitted eight at a time and all eight must leave the transmit shift register. this allows a flag to be loaded into it before the first data is written to the transmit fifo. auto rts deactivation (wr7' bit d2): some applica- tions require toggling the modem signal to indicate the end of the packet. with the nmos/cmos version, this requires intensive cpu support; the cpu needs time to determine whether or not the last bit of the closing flag has left the txd pin. the escc has a new feature to deactivate the /rts signal when the last bit of the closing flag clears the txd pin. if this feature is enabled by setting bit d2 of wr7', and when wr5 bit d1 is reset during the transmission of a sdlc frame, the deassertion of the /rts pin is delayed until the last bit of the closing flag clears the txd pin. the /rts pin is deasserted after the rising edge of the transmit clock cycle on which the last bit of the closing flag is transmitted. this implies that the escc is programmed for flag on underrun (wr10 bit d2=1) for the /rts pin to deassert at the end of the frame. (otherwise, the deassertion occurs when the next flag is transmitted). this feature works independently of the programmed transmitter idle state. in synchronous modes other than sdlc, the /rts pin immediately follows the state programmed into wr5 d1. note that if the /rts pin is connected to one of the general purpose inputs (/cts or /dcd), it can be used to generate an external status in- terrupt when a frame is completely transmitted. nrzi forced high after closing flag: on the cmos/nmos version of the scc in the sdlc mode of operation with nrzi mode of encoding and mark idle (wr10 bit d6=0, d5=1, d3=1), the state of the txd pin af- ter transmission of the closing flag is undetermined, de- pending on the last data sent. with the escc in the same operation mode (sdlc, nrzi, with mark idle), the txd pin is automatically forced high on the falling edge of the txc of the last bit of the closing flag, and then the transmitter goes to the mark idle state. there are several different ways for a transmitter to go into the idle state. in each of the following cases, the txd pin is forced high when the mark idle condition is reached; da- ta, crc (2 bytes), flag and idle; data, flag and idle; data, abort (on underrun) and idle; data, abort (by command) and idle; idle, flag and command to idle mark. the force high feature is disabled when the mark idle bit is reset (programmed as mark idle). this feature is used in combi- nation with the automatic sdlc opening flag transmission feature, wr7' bit d0=1, to assure that data packets are properly formatted. when these features are used togeth- er, it is not necessary for the cpu to issue any commands after sending a closing flag in combination with nrzi data encoding. (on the nmos/cmos version, this is accom- plished by channel reset, followed by re-initializing the channel). if wr7' bit d0 is reset, like in the nmos/cmos version, it is necessary to reset the mark idle bit (wr10, bit d3) to enable flag transmission before a sdlc packet is transmitted. 4.4.2 sdlc receive the receiver in the scc always searches the receive data stream for flag characters in sdlc mode. ordinarily, the receiver transfers all received data between flags to the re- ceive data fifo. however, if the receiver is not in hunt mode no data is received. the receiver is in hunt mode when first enabled, or the receiver is placed in hunt mode scc /escc user? manual data communication modes 4-23 4 by the processor issuing the enter hunt mode command in wr3. this bit (d4) is a command, and writing a 0 to it has no effect. the hunt status of the receiver is reported by the sync/hunt bit in rr0. sync/hunt is one of the possible sources of external/status interrupts, with both transitions causing an interrupt. this is true even if the sync/hunt bit is set as a result of the pro- cessor issuing the enter hunt mode command. the receiver automatically enters hunt mode if an abort is received. because the receiver always searches the receive data stream for flags, and automatically enters hunt mode when an abort is received, the receiver always handles frames correctly. the enter hunt mode command should never be needed. the scc drives the /sync pin low to signal that a flag has been recognized. the timing for the /sync signal is shown in figure 4-12. the scc assumes the first byte in an sdlc frame is the address of the secondary station for which the frame is in- tended. the scc provides several options for handling this address. if the address search mode bit (d2) in wr3 is set to 0, the address recognition logic is disabled and all received frames are transferred to the receive data fifo. in this mode the software must perform any address recognition. if the address search mode bit is set to 1, only those frames whose address matches the address programmed in wr6 or the global address (all 1s) will be transferred to the receive data fifo. the address comparison is across all eight bits of wr6 if the sync character load inhibit bit (d1) in wr3 is set to 0. the comparison may be modified so that only the four most significant bits of wr6 match the received address. this mode is selected by setting the sync character load inhibit bit to 1. in this mode, however, the address field is still eight bits wide. the address field is transferred to the receive data fifo in the same manner as data. it is not treated differently than data. the number of bits per character is controlled by bits d7 and d6 of wr3. five, six, seven, or eight bits per character may be selected via these two bits. the data is right-justi- fied in the receive buffer. the scc merely takes a snap- shot of the receive data stream at the appropriate times, so the ?nused?bits in the receive buffer are only the bits fol- lowing the character. an additional bit carrying parity information is selected by setting bit d6 of wr4 to 1. this also enables parity in the transmitter. the parity sense is selected by bit d1 of wr4. parity is not normally used in sdlc mode. the character length can be changed at any time before the new number of bits have been assembled by the receiver. care should be exercised, however, as unexpected results may occur. a representative example, switching from five bits to eight bits and back to five bits, is shown in figure 4-13. figure 4-12. /sync as an output state changes in one /rtxc clock cycle /rtxc pclk /sync scc /escc user? manual data communication modes 4-24 4.3 byte-oriented synchronous mode (continued) most bit-oriented protocols allow an arbitrary number of bits between opening and closing flags. the scc allows for this by providing three bits of residue code in rr1. these indicate which bits in the last three bytes transferred from the receive data fifo by the processor are actually valid data bits (and not part of the frame check sequence or crc). table 4-10 gives the meanings of the different codes for the four different character length options. the valid data bits are right-justified, meaning, if the number of valid bits given by the table is less than the character length, then the bits that are valid are the right-most or least significant bits. it should also be noted that the resi- due code is only valid at the time when the end of frame bit in rr1 is set to 1. as indicated in the table, these bits allow the processor to determine those bits in the information (and not crc) field. this allows transparent retransmission of the received frame. the residue code bits do not go through a fifo, so they change in rr1 when the last character of the frame is loaded into the receive data fifo. if there are any characters already in the receive data fifo the residue code is updated before they are read by the processor. figure 4-13. changing character length 654321 receive data buffer 7 8 11109876 12 13 19 18 17 16 15 14 20 21 27 26 25 24 23 22 28 29 32 31 30 29 28 27 33 34 37 36 35 34 33 32 38 39 time change from five to eight change from eight to five 5 bits 5 bits 5 bits 8 bits 8 bits table 4-10. residue codes residue code bits in previous byte bits in second previous byte bits in third previous byte 2 1 0 8b/c 7b/c 6b/c 5b/c 8b/c 7b/c 6b/c 5b/c 8b/c 7b/c 6b/c 5b/c 100 0000 3100 8752 010 0000 4200 8763 110 0000 5310 8764 001 0000 6420 8765 101 0000 7531 8765 011 000 864 876 111 10 87 87 000 2 8 8 scc /escc user? manual data communication modes 4-25 4 as an example of how the codes are interpreted, consider the case of eight bits per character and a residue code of 101. the number of valid bits for the previous, second previous, and third previous bytes are 0, 7, and 8, respectively. this indicates that the information field (i- field) boundary falls on the second previous byte as shown in figure 4-14. a frame is terminated by the detection of a closing flag. upon detection of the flag the following actions take place: the contents of the receive shift register are transferred to the receive data fifo; the residue code is latched, the crc error bit is latched; the end of frame upon reaching the top of the fifo can cause a special receive condition. the processor then reads rr1 to determine the result of the crc calculation and the residue code. only the crc-ccitt polynomial is used for crc calcula- tions in sdlc mode, although the generator and checker can be preset to all 1s or all 0s. the crc-ccitt polyno- mial is selected by setting bit d2 of wr5 to 0. bit d7 of wr10 controls the preset value. if this bit is set to 1, the generator and checker are preset to 1s, and if this bit is re- set, the generator and checker are preset to all 0s. the receiver expects the crc to be inverted before trans- mission, so it checks the crc result against the value 0001110100001111. the scc presets the crc checker whenever the receiver is in hunt mode or whenever a flag is received, so a crc reset command is not necessary. however, the crc checker can be preset by issuing the reset crc checker command in wr0. the crc checker is automatically enabled for all data be- tween the opening and closing flags by the scc in sdlc mode, and the rx crc enable bit (d3) in wr3 is ignored. the result of the crc calculation for the entire frame is valid in rr1 only when accompanied by the end of frame bit set in rr1. at all other times, the crc error bit in rr1 should be ignored by the processor. on the nmos/cmos version, care must be exercised so that the processor does not attempt to use the crc bytes that are transferred as data, because not all of the bits are transferred properly. the last two bits of crc are never transferred to the receive data fifo and are not recoverable. on the escc, an enhancement has been made allowing the 2nd byte of the crc to be received completely. this feature is useful when the application requires the 2nd crc byte as data. for example, applications which oper- ate in transparent mode or protocols using the error check- ing mechanism other than crc-ccitt (like 32-bit crc). note the following about scc crc operation: n the normal crc checking mechanism involves checking over data and crc characters. if the division remainder is 0, there is no crc error. n sdlc is different. the crc generator, when receiving a correct frame, has a fixed, non-zero remainder. the actual remainder in the receive crc calculation is checked against this fixed value to determine if a crc error exists. a frame is terminated by a closing flag. when the scc rec- ognizes this flag: n the contents of the receive shift register are transferred to the receive data fifo. n the residue code is latched, the crc error bit is latched in the status fifo and the end of frame bit is set in the receive status fifo. the end of frame bit, upon reaching the exit location of the fifo, will cause a special receive condition. the pro- cessor may then read rr1 to determine the result of the crc calculation as well as the residue code. if either the rx interrupt on special condition only or the rx in- terrupt on first character or special condition modes are figure 4-14. residue code 101 interpretation third previous byte 7-bits second previous byte previous byte i - field crc field scc /escc user? manual data communication modes 4-26 4.3 byte-oriented synchronous mode (continued) selected, the processor must issue an error reset com- mand in wr0 to unlock the receive fifo. in addition to searching the data stream for flags, the re- ceiver in the scc also watches for seven consecutive 1s, which is the abort condition. the presence of seven con- secutive 1s is reported in the break/abort bit in rr0. this is one of the possible external/status interrupts, so transi- tions of this status may be programmed to cause inter- rupts. upon receipt of an abort the receiver is forced into hunt mode where it looks for flags. the hunt status is also a possible external/status condition whose transition may be programmed to cause an interrupt. the transitions of these two bits occur very close together, but either one or two external/status interrupts may result. the abort condi- tion is terminated when a 0 is received, either by itself or as the leading 0 of a flag. the receiver does not leave hunt mode until a flag has been received, so two discrete exter- nal/status conditions occur at the end of an abort. an abort received in the middle of a frame terminates the frame re- ception, but not in an orderly manner because the charac- ter being assembled is lost. up to two modem control signals associated with the re- ceiver are available in sdlc mode: n the /dtr//req pin carries an inverted state of the dtr bit (d7) in wr5 unless this pin has been programmed to carry a dma request signal. n the /dcd pin is ordinarily a simple input to the dcd bit in rr0. however, if the auto enables mode is selected by setting bit d5 of wr3 to 1, this pin becomes an enable for the receiver. that is, if auto enables is on and the /dcd pin is high, the receiver is disabled. while the /dcd pin is low, the receiver is enabled. sdlc initialization. the initialization sequence for sdlc mode is wr4 to select sdlc mode first, wr3 and wr5 to select the various options, wr7 to program flag, and then wr6 for the receive address. at this point the other regis- ters should be initialized as necessary. when all this is completed the receiver is enabled by setting bit d0 of wr3 to a one. a summary is shown in table 4-11. table 4-11. initializing in sdlc mode bit # reg d7 d6 d5 d4 d3 d2 d1 d0 description wr4 00100000 select x1 clock, sdlc mode, enable sync mode wr3 r x011100 rx=# of rx bits/char, no auto enable, enter hunt. enable rx crc, address search, no sync character load inhibit wr5 d t x 0 0 0 r 1 d=inverse of dtr pin, tx=# of tx bits/char, use sdlc crc, r=inverse state of /rts pin, crc enable wr7 01111110 sdlc flag wr6 xxxxxxxx receiver secondary address wr15 xxxxxxx1 enable access to new register wr7' 011d1 r 11 enable extended read, tx int on fifo empty, d=request timing mode, rx int on 4 char, r=rts deactivation, auto eom reset, auto ?g tx crc preset to zero, nrz data,i=idle line wr10 0 0 0 0 i 0 0 0 crc preset to zero, nrz data, i=idle line wr3 r x011101 enable receiver wr5 d t x 0 1 0 r 1 enable transmitter wr0 10000000 reset crc generator note: the receiver searches for synchronization when it is in hunt mode. in this mode, the receiver is idle except for searching the data stream for a flag match. note: the sync/hunt bit in rr0 reports the hunt status, and an interrupt is generated upon transitions between the hunt state and the sync state. note: when the receiver detects a flag match it achieves syn- chronization and interprets the following byte as the address field. note: the scc will drive the /sync pin low for one receive clock cycle to signal that the flag has been received. scc /escc user? manual data communication modes 4-27 4 4.4.3 sdlc frame status fifo this feature is not available on the nmos version. on the cmos version and the escc, the ability to receive high speed back-to-back sdlc frames is maximized by a 10-bit deep by 19-bit wide status fifo. when enabled (through wr15, bit d2), it provides a dma the ability to continue to transfer data into memory so that the cpu can examine the message later. for each sdlc frame, a 14- bit byte count and five status/error bits are stored. the byte count and status bits are accessed through read regis- ters 6 and 7. read registers 6 and 7 are only accessible when the sdlc fifo is enabled. the 10x19 status fifo is separate from the 8-byte receive data fifo. when the enhancement is enabled, the status in read register 1 (rr1) and byte count for the sdlc frame is stored in the 10 x 19 bit status fifo. this allows the dma controller to transfer the next frame into memory while the cpu verifies the message was properly received. summarizing the operation; data is received, assembled, and loaded into the eight-byte fifo before being trans- ferred to memory by the dma controller. when a flag is re- ceived at the end of an sdlc frame, the frame byte count from the 14-bit counter and five status bits are loaded into the status fifo for verification by the cpu. the crc check- er is automatically reset in preparation for the next frame which can begin immediately. since the byte count and sta- tus are saved for each frame, the message integrity can be verified at a later time. status information for up to 10 frames can be stored before a status fifo overrun occurs. if a frame is terminated with an abort, the byte count will be loaded to the status fifo and the counter reset for the next frame. fifo detail. for a better understanding of details of the fifo operation, refer to the block diagram in figure 4-15. scc /escc user? manual data communication modes 4-28 4.3 byte-oriented synchronous mode (continued) figure 4-15. sdlc frame status fifo (n/a on nmos) scc status reg residue bits(3) overrun, crc error byte counter reset on flag detect increment on byte det enable count in sdlc rr1 14 bits 5 bits fifo array 10 deep by 19 bits wide head pointer 4-bit counter 4-bit comparator over equal 5 bits eof = 1 tail pointer 4-bit counter end of frame si g nal status read comp en 6-bit mux 6 bits rr1 2 bits 6 bits 8 bits frame status fifo circuitr in sdlc mode the following definitions apply. - all sent bypasses mux and equals contents of scc status register. - parity bits bypasses mux and does the same. - eof is set to 1 whenever reading from the fifo. rr7 d5-d0 + rr6 d7 - d0 byte counter contains 14 bits for a 16 kbyte maximum count. rr7 d6 fifo data available status bit status bit set to 1 when readin g from fifo. wr(15) bit 2 set enables status fifo rr7 d7 fifo overflow status bit msb pf rr(7) is set on status fifo overflow interface to scc fifo enable rr6 bits 5-0 bit 6 bit 7 scc /escc user? manual data communication modes 4-29 4 enable/disable. the frame status fifo is enabled when wr15 bit d2 is set and the cmos/escc is in the sdlc/hdlc mode. otherwise, the status register con- tents bypass the fifo and go directly to the bus interface (the fifo pointer logic is reset either when disabled or via a channel or power-on reset). the fifo mode is dis- abled on power-up (wr15 d2 is set to 0 on reset). the effects of backward compatibility on the register set are that rr4 is an image of rr0, rr5 is an image of rr1, rr6 is an image of rr2 and rr7 is an image of rr3. for the details of the added registers, refer to chapter 5. the status of the fifo enable signal can be obtained by read- ing rr15 bit d2. if the fifo is enabled, the bit is set to 1; otherwise, it is reset. read operation. when wr15 bit d2 is set and the fifo is not empty, the next read to any of status register rr1 or the additional registers rr7 and rr6 is from the fifo. reading status register rr1 causes one location of the fifo to be emptied, so status is read after reading the byte count, otherwise the count is incorrect. before the fifo underflows, it is disabled. in this case, the multiplexer is switched to allow status to read directly from the status register, and reads from rr7 and rr6 contain bits that are undefined. bit d6 of rr7 (fifo data available) is used to determine if status data is coming from the fifo or directly from the status register, since it is set to 1 whenever the fifo is not empty. since not all status bits are stored in the fifo, the all sent, parity, and eof bits bypass the fifo. the status bits sent through the fifo are residue bits (3), overrun, and crc error. the sequence for proper operation of the byte count and fifo logic is to read the register in the following order: rr7, rr6, and rr1 (reading rr6 is optional). additional logic prevents the fifo from being emptied by multiple reads from rr1. the read from rr7 latches the fifo empty/full status bit (d6) and steers the status multiplexer to read from the cmos/escc megacell instead of the sta- tus fifo (since the status fifo is empty). the read from rr1 allows an entry to be read from the fifo (if the fifo was empty, logic was added to prevent a fifo underflow condition). write operation. when the end of an sdlc frame (eof) has been received and the fifo is enabled, the contents of the status and byte-count registers are loaded into the fifo. the eof signal is used to increment the fifo. if the fifo overflows, the rr7 bit d7 (fifo overflow) is set to indicate the overflow. this bit and the fifo control logic is reset by disabling and re-enabling the fifo control bit (wr15 bit 2). for details of fifo control timing during an sdlc frame, refer to figure 4-16. sdlc status fifo anti-lock feature (escc only). when the frame status fifo is enabled and the escc is programmed for special receive condition only (wr1 d4=d3=1), the data fifo is not locked when a character with end of frame status is read. when a char- acter with the eof status reaches the top of the fifo, an interrupt with a vector for receive data is generated. the command reset highest ius must be issued at the end of the interrupt service routine regardless of whether an interrupt ac knowledge cycle had been executed (hard- ware or software). this allows a dma to complete a trans- fer of the received frame to memory and then interrupt the cpu that a frame has been completed without locking the fifo. since in the receive interrupt on special condition only mode the interrupt vector for receive data is not used, it is used to indicate that the last byte of a frame has been read from the receive fifo. this eliminates having to read the frame status (crc and other status is stored in the status fifo with the frame byte count). figure 4-16. sdlc byte counting detail 00 00 00 00 f addddccf f addddccf 0 4 123 5670 0 4 12 3 5 6 7 internal byte strobe increments counter internal byte strobe increments counter don't load counter on 1st flag reset byte counter here reset byte counter load counter into fifo and in c r e m e n t ptr reset byte counter reset byte counter load counter into fifo and in c r e m e n t ptr scc /escc user? manual data communication modes 4-30 4.3 byte-oriented synchronous mode (continued) when a character with a special receive condition other than eof is received (receive overrun, or parity), a special receive condition interrupt is generated after the character is read from the fifo and the receive fifo is locked until the error reset command is issued. 4.4.4 sdlc loop mode the scc supports sdlc loop mode in addition to normal sdlc. sdlc loop mode is very similar to normal sdlc but is usually used in applications where a point-to-point network is not appropriate (for example, point-of-sale ter- minals). in an sdlc loop, there is a primary controller that manages the message traffic flow on the loop and any number of secondary stations. in sdlc loop mode, the scc operating in regular sdlc mode can act as the pri- mary controller. a secondary station in an sdlc loop is always listening to the messages being sent around the loop, and in fact must pass these messages to the rest of the loop by re- transmitting them with a one-bit-time delay. the secondary station can place its own message on the loop only at specific times. the controller signals that sec- ondary stations may transmit messages by sending a spe- cial character, called an eop (end of poll), around the loop. the eop character is the bit pattern 11111110. when a secondary station has a message to transmit and recognizes an eop on the line, it changes the last binary 1 of the eop to a 0 before transmission. this has the effect of turning the eop into a flag pattern. the secondary sta- tion now places its message on the loop and terminates its message with an eop. any secondary stations further down the loop with messages to transmit can append their messages to the message of the first secondary station by the same process. all secondary stations without messages to send merely echo the incoming messages and are prohibited from placing messages on the loop, except upon recognizing an eop. sdlc loop mode is quite similar to normal sdlc mode except that two additional control bits are used. writing a 1 to the loop mode bit in wr10 configures the scc for loop mode. writing a 1 to the go active on poll bit in the same register normally causes the scc to change the next eop into a flag and then begin transmitting on loop. however, when the scc first goes on loop it uses the first eop as a signal to insert the one-bit delay, and doesn? begin trans- mitting until it receives the second eop. there are also two additional status bits in rr10, the on-loop bit and the loop-sending bit. there are also restrictions as to when and how a second- ary station physically becomes part of the loop. a secondary station that has just powered up must monitor the loop, without the one-bit-time delay, until it recognizes an eop. when an eop is recognized the one-bit-time de- lay is switched on. this does not disturb the loop because the line is marking idle between the time that the controller sends the eop and the time that it receives the eop back. the secondary station that has gone on-loop cannot place a message on the loop until the next time that an eop is issued by the controller. a secondary station goes off loop in a similar manner. when given a command to go off-loop, the secondary station waits until the next eop to remove the one-bit-time delay. to operate the scc in sdlc loop mode, the scc must first be programmed just as if normal sdlc were to be used. loop mode is then selected by writing the appropri- ate control word in wr10. the scc is now waiting for the eop so that it can go on loop. while waiting for the eop, the scc ties txd to rxd with only the internal gate delays in the signal path. when the first eop is recognized by the scc, the break/abort/eop bit is set in rr0, generating an exter- nal/status interrupt (if so enabled). at the same time, the on-loop bit in rr10 is set to indicate that the scc is in- deed on-loop, and a one-bit time delay is inserted in the txd to the rxd path. the scc is now on-loop but cannot transmit a message until a flag and the next eop are received. the require- ment that a flag be received ensures that the scc cannot erroneously send messages until the controller ends the current polling sequence and starts another one. if the cpu in the secondary station with the scc needs to transmit a message, the go-active-on-poll bit in wr10 is set. if this bit is set when the eop is detected, the scc changes the eop to a flag and starts sending another flag. the eop is reported in the break/abort/eop bit in rr0 and the cpu writes its data bytes to the scc, just as in normal sdlc frame transmission. when the frame is com- plete and crc has been sent, the scc closes with a flag and reverts to one-bit-delay mode. the last zero of the flag, along with the marking line echoed from the rxd pin, form an eop for secondary stations further down the loop. while the scc is actually transmitting a message, the loop-sending bit in r10 is set to indicate this. if the go-active-on-poll bit is not set at the time the eop passes by, the scc cannot send a message until a flag (terminating the current polling sequence) and another eop are received. scc /escc user? manual data communication modes 4-31 4 if sdlc loop is deselected, the scc is designed to exit from the loop gracefully. when the sdlc loop mode is de- selected by writing to wr10, the scc waits until the next polling cycle to remove the one-bit time delay. if a polling cycle is in progress at the time the command is written, the scc finishes sending any message that it is transmitting, ends with an eop, and disconnects txd from rxd. if no message was in progress, the scc immediately disconnects txd from rxd. once the scc is not sending on the loop, exiting from the loop is accomplished by setting the loop mode bit in wr10 to 0, and at the same time writing the abort/flag on underrun and mark/flag idle bits with the desired values. the scc will revert to normal sdlc operation as soon as an eop is received, or immediately if the receiver is al- ready in hunt mode because of the receipt of an eop. to ensure proper loop operation after the scc goes off the loop, and until the external relays take the scc completely out of the loop, the scc should be programmed for mark idle instead of flag idle. when the scc goes off the loop, the on-loop bit is reset. note: with nrzi encoding, removing the stations from the loop (removing the one-bit time delay) may cause prob- lems further down the loop because of extraneous transi- tions on the line. the scc avoids this problem by making transparent adjustments at the end of each frame it sends in response to an eop. a response frame from the scc is terminated by a flag and eop. normally, the flag and the eop share a zero, but if such sharing would cause the rxd and txd pins to be of opposite polarity after the eop, the scc adds another zero between the flag and the eop. this causes an extra line transition so that rxd and txd are identical after the eop is sent. this extra zero is com- pletely transparent because it only means that the flag and the eop no longer share a zero. all that a proper loop exit needs, therefore, is the removal of the one-bit delay. the scc allows the user the option of using nrzi in sdlc loop mode by programming wr10 appropriately. with nrzi encoding, the outputs of secondary stations in the loop are inverted from their inputs because of messages that they have transmitted. subsections 4.4.4.1 and 4.4.4.2 discuss the sdlc loop mode in receive and transmit. 4.4.4.1 sdlc loop mode receive sdlc loop mode is quite similar to sdlc mode except that two additional control bits are used. they are the loop mode bit (d1) and the go-active-on-poll bit (d4) in wr10. in addition to these two extra control bits, there are also two status bits in rr10. they are the on loop bit (d1) and the loop sending bit (d4). before loop mode is selected, both the receiver and trans- mitter have to be completely initialized for sdlc operation. once this is done, loop mode is selected by setting bit d1 of wr10 to 1. at this point, the scc connects txd to rxd with only gate delays in the path. at the same time, a flag is loaded into the transmit shift register and is shifted to the end of the zero inserter, ready for transmission. the scc remains in this state until the go-active-on-poll bit (d4) in wr10 is set to 1. when this bit is set to 1, the re- ceiver begins looking for a sequence of seven consecutive 1s, indicating either an eop or an idle line. when the re- ceiver detects this condition, the break/abort bit in rr0 is set to 1, and a one-bit time delay is inserted in the path from rxd to txd. the on-loop bit in rr10 is also set to 1 at this time, and the receiver enters the hunt mode. the scc cannot trans- mit on the loop until a flag is received (causing the receiver to leave hunt mode) and another eop (bit pattern 11111110) is received. the scc is now on the loop and capable of transmitting on the loop. as soon as this status is recognized by the processor, the go-active-on-poll bit in wr10 is set to 0 to prevent the scc from transmitting on the loop without a processor acknowledgment. 4.4.4.2 sdlc loop mode transmit to transmit a message on the loop, the go-active-on-poll bit in wr10 must be set to 1. once this is done, the scc changes the next received eop into a flag and begins transmitting on the loop. when the eop is received, the break/abort and hunt bits in rr0 are set to 1, and the loop sending bit in rr10 is also set to 1. data to be transmitted is written after the go- active-on-poll bit has been set or after the receiver enters hunt mode. if the data is written immediately after the go-active-on- poll bit has been set, the scc only inserts one flag after the eop is changed into a flag. if the data is not written un- til after the receiver enters the hunt mode, the flags are transmitted until the data is written. if only one frame is to be transmitted on the loop in response to an eop, the pro- cessor must set the go active on poll bit to 0 before the last data is written to the transmitter. in this case, the trans- mitter closes the frame with a single flag and then reverts to the one-bit delay. the loop sending bit in rr10 is set to 0 when the closing flag has been sent. if more than one frame is to be trans- mitted, the go-active-on-poll bit should not be set to 0 un- til the last frame is being sent. if this bit is not set to 0 be- fore the end of a frame, the transmitter sends flags until either more data is written to the transmitter, or until the go-active-on-poll bit is set to 0. note that the state of the abort/flag on underrun and mark/flag idle bits in wr10 is ignored by the scc in sdlc loop mode. scc /escc user? manual data communication modes 4-32 4.3 byte-oriented synchronous mode (continued) 4.4.4.3 sdlc loop initialization the initialization sequence for the scc in sdlc loop mode is similar to the sequence used in sdlc mode, ex- cept that it is longer. the processor should program wr4 first to select sdlc mode, and then wr10 to select the crc preset value and program the mark/flag idle bit. the loop mode and go-active-on-poll bits in wr10 should not be set to 1 yet. the flag is written in wr7 and the various options are selected in wr3 and wr5. at this point, the other registers are initialized as necessary (table 4-12). the loop mode bit (d1) in wr10 is set to 1. when all of this is complete, the transmitter is enabled by setting bit d3 of wr5 to 1. now that the transmitter is enabled, the crc generator is initialized by issuing the reset tx crc gen- erator command in wr0. the receiver is enabled by set- ting the go-active-on-poll bit (d4) in wr10 to 1. the scc goes on the loop when seven consecutive 1s are received, and signals this by setting the on-loop bit in rr10. note that the seven consecutive 1s will set the break/abort and hunt bits in rr0 also. once the scc is on the loop, the go-active-on-poll bit should be set to 0 until a message is to be transmitted on the loop. to transmit a message on the loop, the go-active-on-poll bit should be set to 1. at this point, the processor may either write the first character to the transmit buffer and wait for a transmit buffer empty condition, or wait for the break/abort and hunt bits to be set in rr10 and the loop sending bit to be set in rr10 be- fore writing the first data to the transmitter. the go-active- on-poll bit should be set to 0 after the transition of the frame has begun. to go off of the loop, the processor should set the go-active-on-poll bit in wr10 to 0 and then wait for the loop sending bit in rr10 to be set to 0. at this point, the loop mode bit (d1) in wr10 is set to 0 to request an orderly exit from the loop. the scc exits sdlc loop mode when seven consecutive 1s have been received; at the same time the break/abort and hunt bits in rr0 are set to 1, and the on loop bit in rr10 is set to 0. table 4-12. sdlc loop mode initialization bit number reg d7 d6 d5 d4 d3 d2 d1 d0 description wr400100000 select x1 clock, sdlc mode, enable sync mode wr3 r x011100 rx=# of rx bits/char, no auto enable, enter hunt, enable rx crc, address search, no sync character load inhibit wr5 d t x 0 0 0 r 1 d=inverse of dtr pin, tx=# of tx bits/char, use sdlc crc, r=inverse state of /rts pin, crc enable wr701111110 sdlc flag wr6xxxxxxxx receiver secondary address wr15 xxxxxxx1 enable access to new register wr7' 011d1 r 11 enable extended read, tx int on fifo empty, d=request timing mode, rx int on 4 char, r=rts deactivation, auto eom reset, auto ?g tx wr10 c d e 1 i 0 1 0 enable loop mode, go active on poll, c=crc preset, de=data encoding method, i=idle line wr3 r x011101 enable receiver wr5 d t x 0 1 0 r 1 enable transmitter wr010000000 reset crc generator 5-1 5 u ser s m anual c hapter 5 r egister d escriptions 5.1 introduction this section describes the functions of the various bits in the registers of the scc (tables 5-1 and 5-2). reserved bits are not used in this implementation of the device and may or may not be physically present in the device. for the register addresses, also refer to tables 2-1, 2-2 and 2-5 in chapter 2. reserved bits that are physically present are readable and writable but reserved bits that are not present will always be read as zero. to ensure compatibility with fu- ture versions of the device, reserved bits should always be written with zeros. reserved commands are not used for the same reason. . notes for tables 5-1 and 5-2: 1. escc and 85c30 only. 2. on the escc and 85c30, these registers are readable as rr9, rr4, rr5, and rr11, respectively, when wr7' d6=1. refer to the description of wr7 prime for enabling the ex- tended read capability. 3. this feature is not available on nmos. table 5-1. scc write registers reg description wr0 reg. pointers, various initialization commands wr1 transmit and receive interrupt enables, wait/dma commands wr2 interrupt vector wr3 2 receive parameters and control modes wr4 2 transmit and receive modes and parameters wr5 2 transmit parameters and control modes wr6 sync character or sdlc address wr7 sync character or sdlc ?g wr7' 1 extended feature and fifo control (wr7 prime) wr8 transmit buffer wr9 master interrupt control and reset commands wr10 2 miscellaneous transmit and receive control bits wr11 clock mode controls for receive and transmit wr12 lower byte of baud rate generator wr13 upper byte of baud rate generator wr14 miscellaneous control bits wr15 external status interrupt enable control table 5-2. scc read registers reg description rr0 transmit and receive buffer status and external status rr1 special receive condition status rr2 modi?d interrupt vector (channel b only), unmodi?d interrupt vector (channel a only) rr3 interrupt pending bits (channel a only) rr4 2 transmit and receive modes and parameters (wr4) rr5 2 transmit parameters and control modes (wr5) rr6 3 sdlc fifo byte counter lower byte (only when enabled) rr7 3 sdlc fifo byte count and status (only when enabled) rr8 receive buffer rr9 2 receive parameters and control modes (wr3) rr10 miscellaneous status bits rr11 2 miscellaneous transmit and receive control bits (wr10) rr12 lower byte of baud rate generator time constant rr13 upper byte of baud rate generator time constant rr14 2 extended feature and fifo control (wr7 prime) rr15 external status interrupt information scc /escc user? manual register descriptions 5-2 5.1 introduction (continued) among these registers, wr9 (master interrupt control and reset register) can be accessed through either channel. the rr2 (interrupt vector register) returns the interrupt vector modified by status, if read from channel b, and writ- ten value (without modification), if read from channel a. channel a has an additional read register which contains all the interrupt pending bits (rr3a). write registers. eleven write registers are used for con- trol (includes transmit buffer/fifo); two for sync character generation/detection; two for baud rate generation. in ad- dition, there are two write registers which are shared by both channels; one is the interrupt vector register (wr2); the other is the master interrupt and reset register (wr9). on the escc and 85c30, there is one additional register (wr7') to control enhanced features. see table 5-1 for a summary of write registers. read registers. four read registers indicate status infor- mation; two are for baud rate generation; one for the re- ceive buffer. in addition, there are two read registers which are shared by both channels; one for the interrupt pending bits; another for the interrupt vector. on the cmos/escc, there are two additional registers, rr6 and rr7. they are available if the frame status fifo feature was enabled in the sdlc mode of operation. on the escc, there is an ?xtended read?option and if its enabled, certain write reg- isters can be read back. see table 5-2 for a summary of read registers. 5.2 write registers the scc write register set in each channel has 11 control registers (includes transmit buffer/fifo), two sync charac- ter registers, and two baud rate time constant registers. the interrupt control register and the master interrupt con- trol and reset register are shared by both channels. in ad- dition to these, the escc and 85c30 has a register (wr7'; prime 7) to control the enhancements. between 80x30 and 85x30, the variation in register defini- tion is a command decode structure; write register 0 (wr0). the following sections describe in detail each write register and the associated bit configuration for each. the following sections describe wr registers in detail: 5.2.1 write register 0 (command register) wr0 is the command register and the crc reset code register. wr0 takes on slightly different forms depending upon whether the scc is in the z85x30 or the z80x30. figure 5-1 shows the bit configuration for the z85x30 and includes register select bits in addition to command and re- set codes. figure 5-2 shows the bit configuration for the z80x30 and includes (in channel b only) the address decoding select described later. the following bit description for wr0 is identical for both versions except where specified: bits d7 and d6: crc reset codes 1 and 0. null command (00). this command has no effect on the scc and is used when a write to wr0 is necessary for some reason other than a crc reset command. reset receive crc checker command (01). this com- mand is used to initialize the receive crc circuitry. it is necessary in synchronous modes (except sdlc) if the en- ter hunt mode command in write register 3 is not issued between received messages. any action that disables the receiver initializes the crc circuitry. resetting the re- ceive crc checker command is accomplished automati- cally in sdlc mode. reset transmit crc generator command (10). this command initializes the crc generator. it is usually is- sued in the initialization routine and after the crc has been transmitted. a channel reset does not initialize the generator and this command is not issued until after the transmitter has been enabled in the initialization routine. on the escc and 85c30, this command is not needed if auto eom reset mode is enabled (wr7' d1=1). reset transmit underrun/eom latch command (11). this command controls the transmission of crc at the end of transmission (eom). if this latch has been reset, and a transmit underrun occurs, the scc automatically appends crc to the message. in sdlc mode with abort on underrun selected, the scc sends an abort and flag on underrun if the tx underrun/eom latch has been reset. scc /escc user? manual register descriptions 5-3 5 at the start of the crc transmission, the tx under- run/eom latch is set. the reset command can be issued at any time during a message. if the transmitter is disabled, this command does not reset the latch. however, if no ex- ternal status interrupt is pending, or if a reset external status interrupt command accompanies this command while the transmitter is disabled, an external/status inter- rupt is generated with the tx underrun/eom bit reset in rr0. bits d5-d3: command codes for the scc. null command (000). the null command has no effect on the scc. point high command (001). this command effectively adds eight to the register pointer (d2-d0) by allowing wr8 through wr15 to be accessed. the point high com- mand and the register pointer bits are written simulta- neously. this command is used in the z85x30 version of the scc. note that wr0 changes form depending upon the scc version. register access for the z80x30 version of the scc is accomplished through direct addressing. reset external/status interrupts command (010). after an external/status interrupt (a change on a modem line or a break condition, for example), the status bits in rr0 are latched. this command re-enables the bits and allows in- terrupts to occur again as a result of a status change. latching the status bits captures short pulses until the cpu has time to read the change. the scc contains simple queueing logic associated with most of the external status bits in rr0. if another exter- nal/status condition changes while a previous condition is still pending (reset external/status interrupt has not yet been issued) and this condition persists until after the com- mand is issued, this second change causes another exter- nal/status interrupt. however, if this second status change does not persist (there are two transitions), another inter- rupt is not generated. exceptions to this rule are detailed in the rr0 description. send abort command (011). this command is used in sdlc mode to transmit a sequence of eight to thirteen 1s. this command always empties the transmit buffer and sets tx underrun/eom bit in read register 0. enable interrupt on next rx character command (100). if the interrupt on first received character mode is selected, this command is used to reactivate that mode af- ter each message is received. the next character to enter the receive fifo causes a receive interrupt. alternative- ly, the first previously stored character in the fifo causes a receive interrupt. figure 5-1. write register 0 in the z85x30 figure 5-2. write register 0 in the z80x30 d7 d6 d5 d4 d3 d2 d1 d0 0 0 0 register 0 0 0 1 register 1 0 1 0 register 2 0 1 1 register 3 1 0 0 register 4 1 0 1 register 5 1 1 0 register 6 1 1 1 register 7 0 0 0 register 8 0 0 1 register 9 0 1 0 register 10 0 1 1 register 11 1 0 0 register 12 1 0 1 register 13 1 1 0 register 14 1 1 1 register 15 with point high command * * write register 0 (non-multiplexed bus mode) 0 0 0 null code 0 0 1 point high 0 1 0 reset ext/status interrupts 0 1 1 send abort (sdlc) 1 0 0 enable int on next rx character 1 0 1 reset tx int pending 1 1 0 error reset 1 1 1 reset highest ius 0 0 null code 0 1 reset rx crc checker 1 0 reset tx crc generator 1 1 reset tx underrun/eom latch d7 d6 d5 d4 d3 d2 d1 d0 null code null code select shift left mode select shift right mode write register 0 (multiplexed bus mode) null code null code reset ext/status interrupts send abort enable int on next rx character reset tx int pending error reset reset highest ius null code reset rx crc checker reset tx crc generator reset tx underrun/eom latch 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 0 0 1 1 0 1 0 1 0 0 1 1 0 1 0 1 0 * 0 0 0 0 1 1 1 1 * b channel only scc /escc user? manual register descriptions 5-4 5.1 introduction (continued) reset tx interrupt pending command (101). this com- mand is used in cases where there are no more characters to be sent; e.g., at the end of a message. this command prevents further transmit interrupts until after the next character has been loaded into the transmit buffer or until crc has been completely sent. this command is neces- sary to prevent the transmitter from requesting an interrupt when the transmit buffer becomes empty (with transmit interrupt enabled). error reset command (110). this command resets the error bits in rr1. if interrupt on first rx character or inter- rupt on special condition modes is selected and a special condition exists, the data with the special condition is held in the receive fifo until this command is issued. if either of these modes is selected and this command is issued be- fore the data has been read from the receive fifo, the data is lost. reset highest ius command (110). this command re- sets the highest priority interrupt under service (ius) bit, allowing lower priority conditions to request interrupts. this command allows the use of the internal daisy chain (even in systems without an external daisy chain) and is the last operation in an interrupt service routine. bits 2 through 0: register selection code on the z85x30, these three bits select registers 0 through 7. with the point high command, registers 8 through 15 are selected (table 5-3). in the multiplexed bus mode, bits d2 through d0 have the following function. bit d2 must be programmed as 0. bits d1 and d0 select shift left/right; that is wr0 (1-0)=10 for shift left and wr0 (1-0)=11 for shift right. see section 2.1.4 for further details on z80x30 register access. 5.2.2 write register 1 (transmit/receive in- terrupt and data transfer mode definition) write register 1 is the control register for the various scc interrupt and wait/request modes. figure 5-3 shows the bit assignments for wr1. bit 7: wait/dma request enable. this bit enables the wait/request function in conjunction with the request/wait function select bit (d6). when programmed to 0, the selected function (bit 6) forces the /w//req pin into the appropriate inactive state (high for request, floating for wait). when programmed to 1, the state of bit 6 determines the activity of the /w//req pin (wait or request). bit 6: wait/dma request function when programmed to 0, the wait function is selected. in the wait mode, the /w//req pin switches from floating to low when the cpu attempts to transfer data before the scc is ready. when programmed to 1, the request function is selected. in the request mode, the /w//req pin switches from high to low when the scc is ready to transfer data. bit 5: /wait//request on transmit or receive when programmed to 0, the state of the /w//req pin is de- termined by bit 6 and the state of the transmit buffer. note: a transmit request function is available on the /dtr//req pin. this allows full-duplex operation under dma control for both channels. figure 5-3. write register 1 d7 d6 d5 d4 d3 d2 d1 d0 write register 1 ext int enable tx int enable parity is special condition 0 0 rx int disable 0 1 rx int on first character or special condition 1 0 int on all rx characters or special condition 1 1 rx int on special condition only wait/dma request on receive//transmit /wait/dma request function wait/dma request enable scc /escc user? manual register descriptions 5-5 5 table 5-3. z85x30 register map a//b pnt2 pnt1 pnt0 write read 8530 85c30/230* wr15 d2 = 0 85c30/230 wr15 d2=1 85c30/85230w r15 d2=1 wr7' d6=1 0000 wr0b rr0b rr0b rr0b 0001 wr1b rr1b rr1b rr1b 0010wr2 rr2b rr2b rr2b 0011 wr3b rr3b rr3b rr3b 0100 wr4b (rr0b) (rr0b) (wr4b) 0101 wr5b (rr1b) (rr1b) (wr5b) 0110 wr6b (rr2b) rr6b rr6b 0111 wr7b (rr3b) rr7b rr7b 1000 wr0a rr0a rr0a rr0a 1001 wr1a rr1a rr1a rr1a 1010wr2 rr2a rr2a rr2a 1011 wr3a rr3a rr3a rr3a 1100 wr4a (rr0a) (rr0a) (wr4a) 1101 wr5a (rr1a) (rr1a) (wr5a) 1110 wr6a (rr2a) rr6a rr6a 1111 wr7a (rr3a) rr7a rr7a with point high command 0000 wr8b rr8b rr8b rr8b 0001wr9 (rr13b) (rr13b) (wr3b) 0010 wr10b rr10b rr10b rr10b 0011 wr11b (rr15b) (rr15b) (wr10b) 0100 wr12b rr12b rr12b rr12b 0101 wr13b rr13b rr13b rr13b 0110 wr14b rr14b rr14b (wr7?) 0111 wr15b rr15b rr15b rr15b 1000 wr8a rr8a rr8a rr8a 1001 wr9a (rr13a) (rr13a) (wr3a) 1010 wr10a rr10a rr10a rr10a 1011 wr11a (rr15a) (rr15a) (wr10a) 1100 wr12a rr12a rr12a rr12a 1101 wr13a rr13a rr13a rr13a 1110 wr14a rr14a rr14a (wr7?) 1111 wr15a rr15a rr15a rr15a notes: wr15 bit d2 enables status fifo function. (not available on nmos) wr7' bit d6 enables extend read function. (only on escc and 85c30) * includes 85c30 and 85230 with wr15 d2=0. scc /escc user? manual register descriptions 5-6 5.1 introduction (continued) when programmed to 1, this bit allows the wait/request function to follow the state of the receive buffer. thus, de- pending on the state of bit 6, the /w//req pin is active or inactive in relation to the empty or full state of the receive buffer. the request function occurs only when the scc is not se- lected; e.g., if the internal request becomes active while the scc is in the middle of a read or write cycle, the exter- nal request does not become active until the cycle is com- plete. an active request output causes a dma controller to initiate a read or write operation. if the request on transmit mode is selected in either sdlc or synchronous mode, the request pin is pulsed low for one pclk cycle at the end of crc transmission to allow the immediate transmis- sion of another block of data. in the wait on receive mode, the /wait pin is active if the cpu attempts to read scc data that has not yet been re- ceived. in the wait on transmit mode, the /wait pin is ac- tive if the cpu attempts to write data when the transmit buffer is still full. both situations occur frequently when block transfer instructions are used. bits 4 and 3: receive interrupt modes receive interrupts disabled (00). this mode prevents the receiver from requesting an interrupt. it is normally used in a polled environment where either the status bits in rr0 or the modified vector in rr2 (channel b) are mon- itored to initiate a service routine. although the receiver in- terrupts are disabled, a special condition can still provide a unique vector status in rr2. receive interrupt on first character or special condi- tion (01). the receiver requests an interrupt in this mode on the first available character (or stored fifo character) or on a special condition. sync characters, stripped from the message stream, do not cause interrupts. special receive conditions are: receiver overrun, framing error, end of frame, or parity error (if selected). if a special receive condition occurs, the data containing the error is stored in the receive fifo until an error reset command is issued by the cpu. this mode is usually selected when a block transfer mode is used. in this interrupt mode, a pending special receive condition remains set until either an error reset command, a channel or hardware reset, or until receive interrupts are disabled. the receive interrupt on first character or special condi- tion mode can be re-enabled by the enable rx interrupt on next character command in wr0. escc: see the description of wr7' on how this function can be changed . interrupt on all receive characters or special condi- tion (10). this mode allows an interrupt for every character received (or character in the receive fifo) and provides a unique vector when a special condition exists. the re- ceiver overrun bit and the parity error bit in rr1 are two special conditions that are latched. these two bits are re- set by the error reset command. receiver overrun is al- ways a special receive condition, and parity can be pro- grammed to be a special condition. data characters with special receive conditions are not held in the receive fifo in the interrupt on all receive characters or special conditions mode as they are in the other receive interrupt modes. receive interrupt on special condition (11). this mode allows the receiver to interrupt only on characters with a special receive condition. when an interrupt occurs, the data containing the error is held in the receive fifo until an error reset command is issued. when using this mode in conjunction with a dma, the dma is initialized and en- abled before any characters have been received by the escc. this eliminates the time-critical section of code re- quired in the receive interrupt on first character or spe- cial condition mode. hence, all data can be transferred via the dma so that the cpu need not handle the first re- ceived character as a special case. in sdlc mode, if the sdlc frame status fifo is enabled and an eof is re- ceived, an interrupt with vector for receive data available is generated and the receive fifo is not locked. bit 2: parity is special condition if this bit is set to 1, any received characters with parity not matching the sense programmed in wr4 give rise to a special receive condition. if parity is disabled (wr4), this bit is ignored. a special condition modifies the status of the interrupt vector stored in wr2. during an interrupt ac- knowledge cycle, this vector can be placed on the data bus. bit 1: transmitter interrupt enable if this bit is set to 1, the transmitter requests an interrupt whenever the transmit buffer becomes empty. bit 0: external/status master interrupt enable this bit is the master enable for external/status interrupts including /dcd, /cts, /sync pins, break, abort, the begin- ning of crc transmission when the transmit/under- run/eom latch is set, or when the counter in the baud rate generator reaches 0. write register 15 contains the individ- ual enable bits for each of these sources of external/status interrupts. this bit is reset by a channel or hardware reset. scc /escc user? manual register descriptions 5-7 5 5.2.3 write register 2 (interrupt vector) wr2 is the interrupt vector register. only one vector register exists in the scc, and it can be accessed through either channel. the interrupt vector can be modified by status information. this is controlled by the vector includes status (vis) and the status high/status low bits in wr9. the bit positions for wr2 are shown in figure 5-4. 5.2.4 write register 3 (receive parameters and control) this register contains the control bits and parameters for the receiver logic as illustrated in figure 5-5. on the escc and 85c30, with the extended read option enabled, this register may be read as rr9. bits 7 and 6: receiver bits/character the state of these two bits determines the number of bits to be assembled as a character in the received serial data stream. the number of bits per character can be changed while a character is being assembled, but only before the number of bits currently programmed is reached. unused bits in the received data register (rr8) are set to 1 in asynchronous modes. in synchronous and sdlc modes, the scc merely transfers an 8-bit section of the serial data stream to the receive fifo at the appropriate time. table 5-4 lists the number of bits per character in the assembled character format. bit 5: auto enable this bit programs the function for both the /dcd and /cts pins. /cts becomes the transmitter enable and /dcd be- comes the receiver enable when this bit is set to 1. how- ever, the receiver enable and transmit enable bits must be set before the /dcd and /cts pins can be used in this manner. when the auto enable bit is set to 0, the /dcd and /cts pins are inputs to the corresponding status bits in read register 0. the state of /dcd is ignored in the lo- cal loopback mode. the state of /cts is ignored in both auto echo and local loopback modes. bit 4: enter hunt mode this command forces the comparison of sync characters or flags to assembled receive characters for the purpose of synchronization. after reset, the scc automatically en- ters the hunt mode (except asynchronous). whenever a flag or sync character is matched, the sync/hunt bit in read register 0 is reset and, if external/status interrupt enable is set, an interrupt sequence is initiated. the scc automatically enters the hunt mode when an abort condi- tion is received or when the receiver is enabled. bit 3: receiver crc enable this bit is used to initiate crc calculation at the beginning of the last byte transferred from the receiver shift register to the receive fifo. this operation occurs independently of the number of bytes in the receive fifo. when a par- ticular byte is to be excluded from the crc calculation, this bit should be reset before the next byte is transferred to the receive fifo. if this feature is used, care must be taken to ensure that eight bits per character is selected in the re- ceiver because of an inherent delay from the receive shift register to the crc checker. figure 5-4. write register 2 figure 5-5. write register 3 d7 d6 d5 d4 d3 d2 d1 d0 write register 2 v0 v1 v2 v3 v4 v5 v6 v7 interrupt vector d7 d6 d5 d4 d3 d2 d1 d0 write register 3 rx enable 0 0 rx 5 bits/character 0 1 rx 7 bits/character 1 0 rx 6 bits/character 1 1 rx 8 bits/character sync character load inhibit address search mode (sdlc) rx crc enable enter hunt mode auto enables table 5-4. receive bits per character d7 d6 bits/character 00 5 01 7 10 6 11 8 scc /escc user? manual register descriptions 5-8 5.1 introduction (continued) this bit is internally set to 1 in sdlc mode and the scc calculates the crc on all bits except zeros inserted be- tween the opening and closing flags. this bit is ignored in asynchronous modes. bit 2: address search mode (sdlc) setting this bit in sdlc mode causes messages with ad- dresses not matching the address programmed in wr6 to be rejected. no receiver interrupts occur in this mode un- less there is an address match. the address that the scc attempts to match is unique (1 in 256) or multiple (16 in 256), depending on the state of sync character load in- hibit bit. address ffh is always recognized as a global ad- dress. the address search mode bit is ignored in all modes except sdlc. bit 1: sync character load inhibi t if this bit is set to 1 in any mode except sdlc, the scc com- pares the byte in wr6 with the byte about to be stored in the fifo, and it inhibits this load if the bytes are equal. (caution: this also occurs in the asynchronous mode if the received character matches the contents of wr6.) the scc does not calculate the crc on bytes stripped from the data stream in this manner. if the 6-bit sync option is selected while in monosync mode, the comparison is still across eight bits, so wr6 is programmed for proper operation. if the 6-bit sync option is selected with this bit set to 1, all sync characters except the one immediately preceding the data are stripped from the message. if the 6-bit sync option is selected while in the bisync mode, this bit is ignored. the address recognition logic of the receiver is modified in sdlc mode if this bit is set to 1, i.e., only the four most sig- nificant bits of wr6 must match the receiver address. this procedure allows the scc to receive frames from up to 16 separate sources without programming wr6 for each source (if each station address has the four most signifi- cant bits in common). the address field in the frame is still eight bits long. address ffh is always recognized as a global address. the bit is ignored in sdlc mode if address search mode has not been selected. bit 0: receiver enable when this bit is set to 1, receiver operation begins. this bit should be set only after all other receiver parameters are established and the receiver is completely initialized. this bit is reset by a channel or hardware reset command, and it disables the receiver. 5.2.5 write register 4 (transmit/receive mis- cellaneous parameters and modes) wr4 contains the control bits for both the receiver and the transmitter. these bits should be set in the transmit and receiver initialization routine before issuing the contents of wr1, wr3, wr6, and wr7. bit positions for wr4 are shown in figure 5-6. on the escc and 85c30, with the extended read option enabled, this register is read as rr4. bits 7 and 6: clock rate bits 1 and 0 these bits specify the multiplier between the clock and data rates. in synchronous modes, the 1x mode is forced internally and these bits are ignored unless external sync mode has been selected. 1x mode (00). the clock rate and data rate are the same. in external sync mode, this bit combination specifies that only the /sync pin is used to achieve character synchro- nization. 16x mode (01). the clock rate is 16 times the data rate. in external sync mode, this bit combination specifies that only the /sync pin is used to achieve character synchronization. 32x mode (10). the clock rate is 32 times the data rate. in external sync mode, this bit combination specifies that ei- ther the /sync pin or a match with the character stored in wr7 will signal character synchronization. the sync char- acter can be either six or eight bits long as specified by the 6-bit/8-bit sync bit in wr10. figure 5-6. write register 4 d7 d6 d5 d4 d3 d2 d1 d0 write register 4 parity enable 0 0 x1 clock mode 0 1 x16 clock mode 1 0 x32 clock mode 1 1 x64 clock mode parity even//odd 0 0 sync modes enable 0 1 1 stop bit/character 1 0 1 1/2 stop bits/character 1 1 2 stop bits/character 0 0 8-bit sync character 0 1 16-bit sync character 1 0 sdlc mode (01111110 flag) 1 1 external sync mode scc /escc user? manual register descriptions 5-9 5 64x mode (11). the clock rate is 64 times the data rate. with this bit combination in external sync mode, both the receiver and transmitter are placed in sdlc mode. the only variation from normal sdlc operation is that the /sync pin is used to start or stop the reception of a frame by forcing the receiver to act as though a flag had been received. bits 5 and 4: sync mode selection bits 1 and 0 these two bits select the various options for character syn- chronization. they are ignored unless synchronous modes are selected in the stop bits field of this register. monosync mode (00). in this mode, the receiver achieves character synchronization by matching the character stored in wr7 with an identical character in the received data stream. the transmitter uses the character stored in wr6 as a time fill. the sync character is either six or eight bits, depending on the state of the 6-bit/8-bit sync bit in wr10. if the sync character load inhibit bit is set, the re- ceiver strips the contents of wr6 from the data stream if received within character boundaries. bisync mode (01). the concatenation of wr7 with wr6 is used for receiver synchronization and as a time fill by the transmitter. the sync character is 12 or 16 bits in the re- ceiver, depending on the state of the 6-bit/8-bit sync bit in wr10. the transmitted character is always 16 bits. sdlc mode (10). in this mode, sdlc is selected and re- quires a flag (01111110) to be written to wr7. the receiv- er address field is written to wr6. the sdlc crc polyno- mial is also selected (wr5) in sdlc mode. external sync mode (11). in this mode, the scc expects external logic to signal character synchronization via the /sync pin. if the crystal oscillator option is selected (in wr11), the internal /sync signal is forced to 0. in this mode, the transmitter is in monosync mode using the con- tents of wr6 as the time fill with the sync character length specified by the 6-bit/8-bit sync bit in wr10. bits 3 and 2: stop bits selection, bits 1 and 0 these bits determine the number of stop bits added to each asynchronous character that is transmitted. the re- ceiver always checks for one stop bit in asynchronous mode. a special mode specifies that a synchronous mode is to be selected. d2 is always set to 1 by a channel or hardware reset to ensure that the /sync pin is in a known state after a reset. synchronous modes enable (00). this bit combination selects one of the synchronous modes specified by bits d4, d5, d6, and d7 of this register and forces the 1x clock mode internally. 1 stop bit/character (01). this bit selects asynchronous mode with one stop bit per character. 1 1/2 stop bits/character (10). these bits select asyn- chronous mode with 1-1/2 stop bits per character. this mode is not used with the 1x clock mode. 2 stop bits/character (11). these bits select asynchro- nous mode with two stop bits per transmitted character and checks for one received stop bit. bit 1: parity even//odd select bit this bit determines whether parity is checked as even or odd. a 1 programmed here selects even parity, and a 0 se- lects odd parity. this bit is ignored if the parity enable bit is not set. bit 0: parity enable when this bit is set, an additional bit position beyond those specified in the bits/character control is added to the trans- mitted data and is expected in the receive data. the re- ceived parity bit is transferred to the cpu as part of the data unless eight bits per character is selected in the receiver. 5.2.6 write register 5 (transmit parameters and controls) wr5 contains control bits that affect the operation of the transmitter. d2 affects both the transmitter and the receiver. bit positions for wr5 are shown in figure 5-7. on the 85x30 with the extended read option enabled, this register is read as rr5. bit 7: data terminal ready control bit this is the control bit for the /dtr//req pin while the pin is in the dtr mode (selected in wr14). when set, /dtr is low; when reset, /dtr is high. this bit is ignored when /dtr//req is programmed to act as a /req pin. this bit is reset by a channel or hardware reset. figure 5-7. write register 5 d7 d6 d5 d4 d3 d2 d1 d0 write register 5 tx crc enable 0 0 tx 5 bits(or less)/character 0 1 tx 7 bits/character 1 0 tx 6 bits/character 1 1 tx 8 bits/character rts /sdlc/crc-16 tx enable send break dtr scc /escc user? manual register descriptions 5-10 5.1 introduction (continued) bits 6 and 5: transmit bits/character select bits 1 and 0 these bits control the number of bits in each byte trans- ferred to the transmit buffer. bits sent must be right justified with the least significant bits first. the five or less mode allows transmission of one to five bits per character. for five or fewer bits per character, the data character must be formatted as shown below in table 5-5. in the six or seven bits/character modes, unused data bits are ignored. bit 4: send break control bit when set, this bit forces the txd output to send continuous 0s beginning with the following transmit clock, regardless of any data being transmitted at the time. this bit functions whether or not the transmitter is enabled. when reset, txd continues to send the contents of the transmit shift regis- ter, which might be syncs, data, or all 1s. if this bit is set while in the x21 mode (monosync and loop mode select- ed) and character synchronization is achieved in the re- ceiver, this bit is automatically reset and the transmitter be- gins sending syncs or data. this bit is also reset by a channel or hardware reset. bit 3: transmit enable data is not transmitted until this bit is set, and the txd out- put sends continuous 1s unless auto echo mode or sdlc loop mode is selected. if this bit is reset after transmission starts, the transmission of data or sync characters is com- pleted. if the transmitter is disabled during the transmis- sion of a crc character, sync or flag characters are sent instead of crc. this bit is reset by a channel or hardware reset. bit 2: sdlc/crc-16 polynomial select bit this bit selects the crc polynomial used by both the transmitter and receiver. when set, the crc-16 polynomi- al is used; when reset, the sdlc polynomial is used. the sdlc/crc polynomial is selected when sdlc mode is selected. the crc generator and checker can be preset to all 0s or all 1s, depending on the state of the preset 1/preset 0 bit in wr10. bit 1: request to send control bit this is the control bit for the /rts pin. when the rts bit is set, the /rts pin goes low; when reset, /rts goes high. when auto enable is set in asynchronous mode, the /rts pin immediately goes low when the rts bit is set. howev- er, when the rts bit is reset, the /rts pin remains low until the transmitter is completely empty and the last stop bit has left the txd pin. in synchronous modes, the /rts pin directly follows the state of this bit, except in sdlc mode under specific conditions. in sdlc mode, if flag on underrun bit (wr10, d2) is set, rts bit in wr5 is reset, and d2 in wr7' is set. the /rts pin deasserts au- tomatically at the last bit of the closing flag triggered by the rising edge of the tx clock. this bit is reset by a channel or hardware reset. bit 0: transmit crc enable this bit determines whether or not the crc is calculated on a transmit character. if this bit is set at the time the char- acter is loaded from the transmit buffer to the transmit shift register, the crc is calculated on that character. the crc is not automatically sent unless this bit is set when the transmit underrun exists. 5.2.7 write register 6 (sync characters or sdlc address field) wr6 is programmed to contain the transmit sync character in the monosync mode, or the first byte of a 16- bit sync character in the external sync mode. wr6 is not used in asynchronous modes. in the sdlc modes, it is programmed to contain the secondary address field used to compare against the address field of the sdlc frame. in sdlc mode, the scc does not automatically transmit the station address at the beginning of a response frame. bit positions for wr6 are shown in figure 5-8. table 5-5. transmit bits per character bit 7 bit 6 0 0 1 1 0 1 0 1 5 or less bits/character 7 bits/character 6 bits/character 8 bits/character note: for five or less bits per character selection in wr5, the fol- lowing encoding is used in the data sent to the transmitter. d is the data bit(s) to be sent. d7 d6 d5 d4 d3 d2 d1 d0 1111000 d sends one data bit 111000d d sends two data bits 11000dd d sends three data bits 1000ddd d sends four data bits 0 0 0dddd d sends ?e data bits scc /escc user? manual register descriptions 5-11 5 5.2.8 write register 7 (sync character or sdlc flag) wr7 is programmed to contain the receive sync character in the monosync mode, a second byte (the last eight bits) of a 16-bit sync character in the bisync mode, or a flag character (01111110) in the sdlc modes. wr7 holds the receive sync character or a flag if one of the special versions of the external sync mode is selected. wr7 is not used in asynchronous mode. bit positions for wr7 are shown in figure 5-9. figure 5-8. write register 6 d7 d6 d5 d4 d3 d2 d1 d0 write register 6 sync3 sync3 sync3 1 adr3 x sync2 sync2 sync2 1 adr2 x sync1 sync1 sync1 1 adr1 x sync0 sync0 sync0 1 adr0 x monosync, 8 bits monosync, 6 bits bisync, 16 bits bisync, 12 bits sdlc sdlc (address range) sync4 sync4 sync4 sync0 adr4 adr4 sync5 sync5 sync5 sync1 adr5 adr5 sync6 sync0 sync6 sync2 adr6 adr6 sync7 sync1 sync7 sync3 adr7 adr7 figure 5-9. write register 7 d7 d6 d5 d4 d3 d2 d1 d0 write register 7 sync3 sync1 sync11 sync7 1 sync2 sync0 sync10 sync6 1 sync1 x sync9 sync5 1 sync0 x sync8 sync4 0 monosync, 8 bits monosync, 6 bits bisync, 16 bits bisync, 12 bits sdlc sync4 sync2 sync12 sync8 1 sync5 sync3 sync13 sync9 1 sync6 sync4 sync14 sync10 1 sync7 sync5 sync15 sync11 0 scc /escc user? manual register descriptions 5-12 5.1 introduction (continued) 5.2.9 write register 7 prime (escc only) this register is used only with the escc. write register 7 prime is located at the same address as write register 7. this register is written to by setting bit d0 of wr15 to a 1. refer to the description in the section on write register 15. features enabled in wr7 prime remain enabled unless otherwise disabled; a hardware or channel reset leaves wr7 prime with all features intact (register contents are 0) (figure 5-10). bit 7: reserved this bit is not used and must always be written zero. bit 6: extended read enable bit setting this bit enables the reading of wr3, wr4, wr5, wr7 prime and wr10. when this feature is enabled, these registers can be accessed by reading rr9, rr4, rr5, rr14, and rr11, respectively. when the extended read is not enabled, register access is identical to that of the nmos/cmos version. refer to chapter two on how this feature affects the mapping of read registers. bit 5: transmit fifo interrupt level if this bit is set, the transmit buffer empty interrupt is gen- erated when the transmit fifo is completely empty. if this bit is reset (0), the transmit buffer empty interrupt is gener- ated when the entry location of the transmit fifo is emp- ty. this latter operation is identical to that of the nmos/cmos version. in the dma request on transmit mode, when using either the /w//req or /dtr//req pins, the request is asserted when the transmit fifo is completely empty if the trans- mit fifo interrupt level bit is set. the request is asserted when the entry location of the transmit fifo is empty if the transmit fifo interrupt level bit is reset (0). bit 4: /dtr//req timing if this bit is set and the /dtr//req pin is used for request mode (wr14 bit d2 = 1), the deactivation of the /dtr//req pin is identical to the /w//req pin. refer to the chapter on interfacing for further details. if this bit is reset (0), the deactivation time for the /dtr//req pin is 4tcpc. this latter operation is identical to that of the scc. bit 3: receive fifo interrupt level if wr7' d3=1 and ?eceive interrupt on all characters and special conditions?is enabled, the receive character available interrupt is triggered when the rx fifo is half full, i.e., the four byte slots of the rx fifo are empty. however, if any character has a special condition, a special condition interrupt is generated when the character is loaded into the receive fifo. therefore, the special condition interrupt service routine should read rr1 before reading the data to determine which byte has which special condition. if wr7' d3=0, the escc sets the receiver and generates the receive character available interrupt on every received character, regardless of any special receive condition. bit 2: auto /rts pin deactivation this bit controls the timing of the deassertion of the /rts pin. if the escc is programmed for sdlc mode and flag- on-underrun (wr10 d2=0), this bit is set and the rts bit is reset. the /rts is deasserted automatically at the last bit of the closing flag, triggered by the rising edge of the transmit clock. if this bit is reset, the /rts pin follows the state programmed in wr5 d1. bit 1: automatic eom reset if this bit is set, the escc automatically resets the tx un- derrun/eom latch and presets the transmit crc generator to its programmed preset state (per values set in wr5 d2 & wr10 d7). therefore, it is not necessary to issue the reset tx underrun/eom latch command when this feature is enabled. if this bit is reset, escc operation is identical to the scc. bit 0: automatic tx sdlc flag if this bit is set, the escc automatically transmits an sdlc flag before transmitting data. this removes the require- ment to reset the mark idle bit (wr10 d3) before writing data to the transmitter, or having to enable the transmitter before writing data to the transmit fifo. also, this feature enables a transmit data write before enabling the transmit- ter. if this bit is reset, operation is identical to that of the scc. figure 5-10. write register 7 prime d7 d6 d5 d4 d3 d2 d1 d0 wr7' auto tx flag auto eom reset auto/rts deactivation rx fifo half full dtr/req timing mode tx fifo empty extended read enable reserved (must be 0) scc /escc user? manual register descriptions 5-13 5 5.2.10 write register 7 prime (85c30 only) this register is used only with the cmos 85c30 scc. wr7' is written to by first setting bit d0 of wr15 to 1, and pointing to wr7 as normal. all writes to register 7 will be to wr7' so long as wr d0 is set. wr 15 bit d0 must be reset to 0 to address the sync register, wr7. if bit d6 of wr7' was set during the write, then wr7' can be read by accessing to rr14. the features remain enabled until specifically disabled, or disabled by a hardware or software reset. figure 5-10a. shows wr7'. bit 7: reserved. this bit is reserved and must be programmed as 0. bit 6: extended read enable bit this bit enables the extended read. setting this bit en- ables the reading of wr3, wr4, wr5, wr7' and wr10. when this feature is enabled, these registers can be ac- cessed by reading rr9, rr4, rr5, rr14, and rr11, re- spectively. when this feature is not enabled, register ac- cess is to the scc. in this case, read to these register locations returns rr13, rr0, rr1, rr10, and rr15 re- spectively. bit 5: receive complete crc on this version, with this bit set to 1, the 2nd byte of the crc is received completely. this feature is ideal for appli- cations which require a 2nd crc byte for complete data; for example, a protocol analyzer or applications using oth- er than crc-ccitt crc (i.e., 32bit crc). in sdlc mode of operation, the cmos scc, on this bit is programmed as 0. in this case on the eof condition (when the closing flag is detected), the contents of the receive shift register are transferred to the receive data fifo re- gardless of the number of bits assembled. because of the three-bit delay path between the sync register and the re- ceive shift register, the last two bits of the 2nd byte of the crc are never transferred to the receive data fifo. the data is actually formed with the six least significant bits of the 2nd crc byte. bit 4: /dtr//req timing fast mode. if this bit is set and the /dtr//req pin is used for request mode (wr14, bit d2=1), the deactivation of the /dtr//req pin is identical to the /w//req pin, which is triggered on the falling edge of the /wr signal, and the /dtr//req pin goes inactive below 200 ns (this number varies depending on the speed grade of the device). when this bit is reset to 0, the deactivation time for the /dtr//req pin is 4tcpc. bit 3: force txd high. in the sdlc mode of operation with the nrzi encoding mode, there is an option to force txd high. if bit d0 of wr15 is set to 1, bit d3 of wr7' can be used to set txd pin high. note that the operation of this bit is independent of the tx enable bit in wr5 is used to control transmission activities, whereas bit d3 of wr7' acts as a pseudo transmitter may actually be mark or flag idling. care must be exercised when setting this bit because any character being trans- mitted at the time that bit is set is ?hopped off? data writ- ten to the transmit buffer while this bit is set is lost. bit 2: auto /rts pin deactivation this bit controls the timing of the deassertion of the /rts pin. if this device is programmed for sdlc mode and flag- on-underrun (wr10 d2=0), this bit is set and the rts bit is reset. the /rts is deasserted automatically at the last bit of the closing flag, triggered by the rising edge of the txc. if this bit is reset to 0, the /rts pin follows the state programmed in wr5 bit d1. bit 1: automatic tx underrun/eom latch reset if this bit is set, this version automatically resets the tx un- derrun/eom latch and presets the transmit crc generator to its programmed preset state (the values set in wr5 d2 & wr10 d7). this removes the requirement to issue the reset tx underrun/eom latch command. also, this fea- ture enables a write transmit data before enabling the transmitter. bit 0: automatic sdlc opening flag transmission. if this bit is set, the device automatically transmits an sdlc opening flag before transmitting data. this removes the requirement to reset the mark idle bit (wr10, bit d3) before writing data to the transmitter, or having to enable the transmitter before writing data to the transmit buffer. also, this feature enables a write transmit data before en- abling the transmitter. 5.2.11 write register 8 (transmit buffer) wr8 is the transmit buffer register. figure 5-10a. write register 7 prime (wr7') d7 d6 d5 d4 d3 d2 d1 d0 wr7' prime auto tx flag auto eom reset auto/rts deactivation force txd high /dtr//req fast mode complete crc reception extended read enable reserved (program as 0) scc /escc user? manual register descriptions 5-14 5.1 introduction (continued) 5.2.12 write register 9 (master interrupt control) wr9 is the master interrupt control register and contains the reset command bits. only one wr9 exists in the scc and is accessed from either channel. the interrupt control bits are programmed at the same time as the reset command, because these bits are only reset by a hardware reset. bit positions for wr9 are shown in figure 5-11. bit 7 and 6: reset command bits together, these bits select one of the reset commands for the scc. setting either of these bits to 1 disables both the receiver and the transmitter in the corresponding channel; forces txd for that channel marking, forces the modem control signals high in that channel, resets all ips and iuss and disables all interrupts in that channel. four extra pclk cycles must be allowed beyond the usual cycle time after any of the reset commands is issued before any additional commands or controls are written to the channel affected. null command (00). this command has no effect. it is used when a write to wr9 is necessary for some reason other than an scc reset command. channel reset b command (01). issuing this command causes a channel reset to be performed on channel b. channel reset a command (10). issuing this command causes a channel reset to be performed on channel a. force hardware reset command (11). the effects of this command are identical to those of a hardware reset, except that the shift right/shift left bit is not changed and the mie, status high/status low and dlc bits take the programmed values that accompany this command. bit 5: software interrupt acknowledge control bit if bit d5 is set, reading read register 2 (rr2) results in an interrupt acknowledge cycle to be executed internally. like a hardware intack cycle, a software acknowledge caus- es the int pin to return high, the ieo pin to go low, and sets the ius latch for the highest priority interrupt pending. this bit is reserved on nmos, and always writes as 0. bit 4: status high//status low control bit this bit controls which vector bits the scc modifies to in- dicate status. when set to 1, the scc modifies bits v6, v5, and v4 according to table 5-6. when set to 0, the scc modifies bits v1, v2, and v3. this bit controls status in both the vector returned during an interrupt acknowledge cycle and the status in rr2b. this bit is reset by a hard- ware reset. bit 3: master interrupt enable this bit is set to 1 to globally enable interrupts, and cleared to zero to disable interrupts. clearing this bit to zero forces the ieo pin to follow the state of the iei pin unless there is an ius bit set in the scc. no ius bit is set after the mie bit is cleared to zero. this bit is reset by a hardware reset. bit 2: disable lower chain control bit the disable lower chain bit is used by the cpu to control the interrupt daisy chain. setting this bit to 1 forces the ieo pin low, preventing lower priority devices on the daisy chain from requesting interrupts. this bit is reset by a hard- ware reset. bit 1: no vector select bit the no vector bit controls whether or not the scc re- sponds to an interrupt acknowledge cycle. this is done by placing a vector on the data bus if the scc is the highest priority device requesting an interrupt. if this bit is set, no vector is returned; i.e., ad7-ad0 remains tri-stated during an interrupt acknowledge cycle, even if the scc is the highest priority device requesting an interrupt. figure 5-11. write register 9 d7 d6 d5 d4 d3 d2 d1 d0 write register 9 vis 0 0 no reset 0 1 channel reset b 1 0 channel reset a 1 1 force hardware reset nv dlc mie status high//status low software intack enable (reserved on nmos) table 5-6. interrupt vector modi?ation v3 v2 v1 status high/status low =0 v4 v5 v6 status high/status low =1 0 0 0 ch b transmit buffer empty 0 0 1 ch b external/status change 0 1 0 ch b receive char. available 0 1 1 ch b special receive condition 1 0 0 ch a transmit buffer empty 1 0 1 ch a external/status change 1 1 0 ch a receive char. available 1 1 1 ch a special receive condition scc /escc user? manual register descriptions 5-15 5 bit 0: vector includes status control bit the vector includes status bit controls whether or not the scc includes status information in the vector it places on the bus in response to an interrupt acknowledge cycle. if this bit is set, the vector returned is variable, with the vari- able field depending on the highest priority ip that is set. table 5-5 shows the encoding of the status information. this bit is ignored if the no vector (nv) bit is set. 5.2.13 write register 10 (miscellaneous transmitter/receiver control bits) wr10 contains miscellaneous control bits for both the receiver and the transmitter. bit positions for wr10 are shown in figure 5-12. on the escc and 85c30 with the extended read option enabled, this register may be read as rr11. bit 7: crc presets i/o select bit this bit specifies the initialized condition of the receive crc checker and the transmit crc generator. if this bit is set to 1, the crc generator and checker are preset to 1. if this bit is set to 0, the crc generator and checker are pre- set to 0. either option can be selected with either crc polynomial. in sdlc mode, the transmitted crc is invert- ed before transmission, and the received crc is checked against the bit pattern 0001110100001111. this bit is re- set by a channel or hardware reset. this bit is ignored in asynchronous mode. bits 6 and 5: data encoding select bits. these bits control the coding method used for both the transmitter and the receiver, as illustrated in table 5-7. all of the clocking options are available for all coding methods. the dpll in the scc is useful for recovering clocking information in nrzi and fm modes. any coding method can be used in x1 mode. a hardware reset forces nrz mode. timing for the various modes is shown in figure 5-13. figure 5-12. write register 10 d7 d6 d5 d4 d3 d2 d1 d0 write register 10 6-bit//8-bit sync 0 0 nrz 0 1 nrzi 1 0 fm1 (transition = 1) 1 1 fm0 (transition = 0) loop mode abort//flag on underrun mark//flag idle go active on poll crc preset i//o table 5-7. data encoding bit 6 bit 5 encoding 0 0 nrz 0 1 nrzi 1 0 fm1 (transition = 1) 1 1 fm0 (transition = 0) scc /escc user? manual register descriptions 5-16 5.1 introduction (continued) bit 4: go-active-on-poll control bit when loop mode is first selected during sdlc operation, the scc connects rxd to txd with only gate delays in the path. the scc does not go on-loop and insert the 1-bit de- lay between rxd and txd until this bit has been set and an eop received. when the scc is on-loop, the transmit- ter does not go active unless this bit is set at the time an eop is received. the scc examines this bit whenever the transmitter is active in sdlc loop mode and is sending a flag. if this bit is set at the time the flag is leaving the trans- mit shift register, another flag or data byte (if the transmit buffer is full) is transmitted. if the go-active-on-poll bit is not set at this time, the trans- mitter finishes sending the flag and reverts to the 1-bit de- lay mode. thus, to transmit only one response frame, this bit is reset after the first data byte is sent to the scc, but before crc has been transmitted. if the bit is not reset be- fore crc is transmitted, extra flags are sent, slowing down response time on the loop. if this bit is reset before the first data is written, the scc completes the transmission of the present flag and reverts to the 1-bit delay mode. after gaining control of the loop, the scc is not able to transmit again until a flag and another eop are received. it is good practice to set this bit only upon receipt of a poll frame to ensure that the scc does not go on-loop without the cpu noticing it. in synchronous modes other than sdlc with the loop mode bit set, this bit is set before the transmitter goes ac- tive in response to a received sync character. this bit is always ignored in asynchronous mode and syn- chronous modes unless the loop mode bit is set. this bit is reset by a channel or hardware reset. bit 3: mark//flag idle line control bit this bit affects only sdlc operation and is used to control the idle line condition. if this bit is set to 0, the transmitter send flags as an idle line. if this bit is set to 1, the transmit- ter sends continuous 1s after the closing flag of a frame. the idle line condition is selected byte by byte i.e., either a flag or eight 1s are transmitted. the primary station in an sdlc loop should be programmed for mark idle to create the eop sequence. mark idle must be deselected at the beginning of a frame before the first data is written to the scc, so that an opening flag is transmitted. this bit is ig- nored in loop mode, but the programmed value takes ef- fect upon exiting the loop mode. this bit is reset by a channel or hardware reset. figure 5-13. nrz (nrzi), fm1 (fm0) timing data nrz nrzi fm1 fm0 110010 manchester scc /escc user? manual register descriptions 5-17 5 on the escc and 85c30 with the automatic tx sdlc flag mode enabled (wr7', d0=1), this bit can be left as mark idle. it will send an opening flag automatically, as well as sending a closing flag followed by mark idle after the frame transmission is completed. bit 2: abort//flag on underrun select bit this bit affects only sdlc operation and is used to control how the scc responds to a transmit underrun condition. if this bit is set to 1 and a transmit underrun occurs, the scc sends an abort and a flag instead of a crc. if this bit is re- set, the scc sends a crc on a transmit underrun. at the beginning of this 16-bit transmission, the transmit under- run/eom bit is set, causing an external/status interrupt. the cpu uses this status, along with the byte count from memory or the dma, to determine whether the frame must be retransmitted. to start the next frame, a transmit buffer empty interrupt occurs at the end of this 16-bit transmission. if both this bit and the mark/flag idle bit are set to 1, all 1s are transmit- ted after the transmit underrun. this bit should be set after the first byte of data is sent to the scc and reset immedi- ately after the last byte of data, terminating the frame prop- erly with crc and a flag. this bit is ignored in loop mode, but the programmed value is active upon exiting loop mode. this bit is reset by a channel or hardware reset. bit 1: loop mode control bit in sdlc mode, the initial set condition of this bit forces the scc to connect txd to rxd and to begin searching the in- coming data stream so that it can go on loop. all bits perti- nent to sdlc mode operation in other registers are set be- fore this mode is selected. the transmitter and receiver are not enabled until after this mode has been selected. as soon as the go-active-on-poll bit is set and an eop is re- ceived, the scc goes on-loop. if this bit is reset after the scc goes on-loop, the scc waits for the next eop to go off-loop. in synchronous modes, the scc uses this bit, along with the go-active-on-poll bit, to synchronize the transmitter to the receiver. the receiver should not be enabled until after this mode is selected. the txd pin is held marking when this mode is selected unless a break condition is pro- grammed. the receiver waits for a sync character to be re- ceived and then enables the transmitter on a character boundary. the break condition, if programmed, is re- moved. this mode works properly with sync characters of 6, 8, or 16 bits. this bit is ignored in asynchronous mode and is reset by a channel or hardware reset. bit 0: 6-bit/8-bit sync select bit this bit is used to select a special case of synchronous modes. if this bit is set to 1 in monosync mode, the receiv- er and transmitter sync characters are six bits long in- stead of the usual eight. if this bit is set to 1 in bisync mode, the received sync is 12 bits and the transmitter sync character remains 16 bits long. this bit is ignored in sdlc and asynchronous modes, but still has effect in the special external sync modes. this bit is reset by a chan- nel or hardware reset. 5.2.14 write register 11 (clock mode control) wr11 is the clock mode control register. the bits in this register control the sources of both the receive and transmit clocks, the type of signal on the /sync and /rtxc pins, and the direction of the /trxc pin. bit positions for wr11 are shown in figure 5-14; also, refer to section 3.5 clock selection. bit 7: rtxc-xtal//no xtal select bit this bit controls the type of input signal the scc expects to see on the /rtxc pin. if this bit is set to 0, the scc ex- pects a ttl-compatible signal as an input to this pin. if this bit is set to 1, the scc connects a high-gain amplifier be- tween the /rtxc and /sync pins in expectation of a quartz crystal being placed across the pins. the output of this oscillator is available for use as a clock- ing source. in this mode of operation, the /sync pin is un- available for other use. the /sync signal is forced to zero internally. a hardware reset forces /no xtal. (at least 20 ms should be allowed after this bit is set to allow the oscil- lator to stabilize.) bits 6 and 5: receiver clock select bits 1 and 0 these bits determine the source of the receive clock as shown in table 5-8. they do not interfere with any of the modes of operation in the scc, but simply control a multi- plexer just before the internal receive clock input. a hard- ware reset forces the receive clock to come from the /rtxc pin. figure 5-14. write register 11 d7 d6 d5 d4 d3 d2 d1 d0 write register 11 0 0 /trxc out = xtal output 0 1 /trxc out = transmit clock 1 0 /trxc out = br generator output 1 1 /trxc out = dpll output /trxc o/i 0 0 transmit clock = /rtxc pin 0 1 transmit clock = /trxc pin 1 0 transmit clock = br generator output 1 1 transmit clock = dpll output 0 0 receive clock = /rtxc pin 0 1 receive clock = /trxc pin 1 0 receive clock = br generator output 1 1 receive clock = dpll output /rtxc xtal//no xtal scc /escc user? manual register descriptions 5-18 5.1 introduction (continued) bits 4 and 3: transmit clock select bits 1 and 0. these bits determine the source of the transmit clock as shown in table 5-9. they do not interfere with any of the modes of operation of the scc, but simply control a multi- plexer just before the internal transmit clock input. the dpll output that is used to feed the transmitter in fm modes lags by 90 degrees the output of the dpll used by the receiver. this makes the received and transmitted bit cells occur simultaneously, neglecting delays. a hardware reset selects the /trxc pin as the source of the transmit clocks. bit 2: trxc pin i/o control bit this bit determines the direction of the /trxc pin. if this bit is set to 1, the /trxc pin is an output and carries the signal selected by d1 and d0 of this register. however, if either the receive or the transmit clock is programmed to come from the /trxc pin, /trxc is an input, regardless of the state of this bit. the /trxc pin is also an input if this bit is set to 0. a hardware reset forces this bit to 0. bits 1 and 0: /trxc output source select bits 1 and 0 these bits determine the signal to be echoed out of the scc via the /trxc pin as given in table 5-10. no signal is produced if /trxc has been programmed as the source of either the receive or the transmit clock. if /trxc o/i (bit 2) is set to 0, these bits are ignored. if the xtal oscillator output is programmed to be echoed, and the xtal oscillator is not enabled, the /trxc pin goes high. the dpll signal that is echoed is the dpll signal used by the receiver. hardware reset selects the xtal os- cillator as the output source. 5.2.15 write register 12 (lower byte of baud rate generator time constant) wr12 contains the lower byte of the time constant for the baud rate generator. the time constant can be changed at any time, but the new value does not take effect until the next time the time constant is loaded into the down counter. no attempt is made to synchronize the loading of the time constant into wr12 and wr13 with the clock driv- ing the down counter. for this reason, it is advisable to dis- able the baud rate generator while the new time constant is loaded into wr12 and wr13. ordinarily, this is done anyway to prevent a load of the down counter between the writing of the upper and lower bytes of the time constant. the formula for determining the appropriate time constant for a given baud is shown below, with the desired rate in bits per second and the br clock period in seconds. this formula is derived because the counter decrements from n down to zero-plus-one-cycle for reloading the time con- stant. this is then fed to a toggle flip-flop to make the out- put a square wave. bit positions for wr12 are shown in figure 5-15. table 5-8. receive clock source bit 6 bit 5 receive clock 0 0 /rtxc pin 0 1 /trxc pin 1 0 br output 1 1 dpll output table 5-9. transmit clock source bit 4 bit 3 transmit clock 0 0 /rtxc pin 0 1 /trxc pin 1 0 br output 1 1 dpll output table 5-10. transmit external control selection bit 1 bit 0 trxc pin output 0 0 xtal oscillator output 0 1 transmit clock 1 0 br output 1 1 dpll output (receive) figure 5-15. write register 12 time constant clock frequency 2 x (desired rate) x (br clock period) - 2 = d7 d6 d5 d4 d3 d2 d1 d0 write register 12 tc0 tc1 tc2 tc3 tc4 tc5 tc6 tc7 lower byte of time constant scc /escc user? manual register descriptions 5-19 5 5.2.16 write register 13 (upper byte of baud rate generator time constant) wr13 contains the upper byte of the time constant for the baud rate generator. bit positions for wr13 are shown in figure 5-16. 5.2.17 write register 14 (miscellaneous con- trol bits) wr14 contains some miscellaneous control bits. bit positions for wr14 are shown in figure 5-17. for dpll function, refer to section 3.4 as well. bits d7-d5: digital phase-locked loop command bits. these three bits encode the eight commands for the digi- tal phase-locked loop. a channel or hardware reset dis- ables the dpll, resets the missing clock latches, sets the source to the /rtxc pin and selects nrzi mode. the enter search mode command enables the dpll after a reset. null command (000). this command has no effect on the dpll. enter search mode command (001) . issuing this com- mand causes the dpll to enter the search mode, where the dpll searches for a locking edge in the incoming data stream. the action taken by the dpll upon receipt of this command depends on the operating mode of the dpll. in nrzi mode, the output of the dpll is high while the dpll is waiting for an edge in the incoming data stream. after the search mode is entered, the first edge the dpll sees is assumed to be a valid data edge, and the dpll be- gins the clock recovery operation from that point. the dpll clock rate must be 32x the data rate in nrzi mode. upon leaving the search mode, the first sampling edge of the dpll occurs 16 of these 32x clocks after the first data edge, and the second sampling occurs 48 of these 32x clocks after the first data edge. beyond this point, the dpll begins normal operation, adjusting the output to re- main in sync with the incoming data. in fm mode, the output of the dpll is low while the dpll is waiting for an edge in the incoming data stream. the first edge the dpll detects is assumed to be a valid clock edge. for this to be the case, the line must contain only clock edges; i.e. with fm1 encoding, the line must be con- tinuous 0s. with fm0 encoding the line must be continu- ous 1s, whereas manchester encoding requires alternat- ing 1s and 0s on the line. the dpll clock rate must be 16 times the data rate in fm mode. the dpll output causes the receiver to sample the data stream in the nominal cen- ter of the two halves of the bit to decide whether the data was a 1 or a 0. after this command is issued, as in nrzi mode, the dpll starts sampling immediately after the first edge is detect- ed. (in fm mode, the dpll examines the clock edge of ev- ery other bit to decide what correction must be made to re- main in sync.) if the dpll does not see an edge during the expected window, the one clock missing bit in rr10 is set. if the dpll does not see an edge after two successive at- tempts, the two clocks missing bits in rr10 are set and the dpll automatically enters the search mode. this com- mand resets both clocks missing latches. reset clock missing command (010). issuing this com- mand disables the dpll, resets the clock missing latches in rr10, and forces a continuous search mode state. disable dpll command (011). issuing this command disables the dpll, resets the clock missing latches in rr10, and forces a continuous search mode state. figure 5-16. write register 13 figure 5-17. write register 14 d7 d6 d5 d4 d3 d2 d1 d0 write register 13 tc8 tc9 tc10 tc11 tc12 tc13 tc14 tc15 upper byte of time constant d7 d6 d5 d4 d3 d2 d1 d0 write register 14 0 0 0 null command 0 0 1 enter search mode 0 1 0 reset missing clock 0 1 1 disable dpll 1 0 0 set source = br generator 1 0 1 set source = /rtxc 1 1 0 set fm mode 1 1 1 set nrzi mode br generator enable br generator source /dtr/request function auto echo local loopback scc /escc user? manual register descriptions 5-20 5.1 introduction (continued) set source to brg command (100). issuing this com- mand forces the clock for the dpll to come from the out- put of the brg. set source to /rtxc command (101). issuing the com- mand forces the clock for the dpll to come from the /rtxc pin or the crystal oscillator, depending on the state of the xtal/no xtal bit in wr11. this mode is selected by a channel or hardware reset. set fm mode command (110). this command forces the dpll to operate in the fm mode and is used to recover the clock from fm or manchester-encoded data. (manchester is decoded by placing the receiver in nrz mode while the dpll is in fm mode.) set nrzi mode command (111). issuing this command forces the dpll to operate in the nrzi mode. this mode is also selected by a hardware or channel reset. bit 4: local loopback select bit setting this bit to 1 selects the local loopback mode of op- eration. in this mode, the internal transmitted data is routed back to the receiver, and to the txd pin. the /cts and /dcd inputs are ignored as enables in local loopback mode, even if auto enable is selected. (if so programmed, transitions on these inputs still cause interrupts.) this mode works with any transmit/receive mode except loop mode. for meaningful results, the frequency of the trans- mit and receive clocks must be the same. this bit is reset by a channel or hardware reset. bit 3: auto echo select bit setting this bit to 1 selects the auto echo mode of opera- tion. in this mode, the txd pin is connected to rxd as in local loopback mode, but the receiver still listens to the rxd input. transmitted data is never seen inside or out- side the scc in this mode, and /cts is ignored as a trans- mit enable. this bit is reset by a channel or hardware reset. bit 2: dtr/request function select bit this bit selects the function of the /dtr//req pin following the state of the dtr bit in wr5. if this is set to 0, the /dtr//req pin follows the state of the dtr bit in wr5. if this bit is set to 1, the /dtr//req pin goes low whenever the transmit buffer becomes empty and in any of the syn- chronous modes when the crc has been sent at the end of a message. the request function on the /dtr//req pin differs from the transmit request function available on the /w//req pin. the /req does not go inactive until the inter- nal operation satisfying the request is complete, which oc- curs three to four pclk cycles after the falling edge of /ds, /rd or /wr. if the dma used is edge-triggered, this differ- ence is unimportant. the deassertion timing of the req mode can be programmed to occur with the same timing as the /w/req pin if wr7' d4=1. this bit is reset by a channel or hardware reset. bit 1: baud rate generator source select bit this bit selects the source of the clock for the baud rate generator, if this bit is set to 0. the baud rate generator clock comes from either the /rtxc pin or the xtal oscil- lator (depending on the state of the xtal//no xtal bit). if this bit is set to 1, the clock for the baud rate generator is the scc? pclk input. hardware reset sets this bit to 0, select the /rtxc pin as the clock source for the brg. bit 0: baud rate generator enable this bit controls the operation of the brg. the counter in the brg is enabled for counting when this bit is set to 1, and counting is inhibited when this bit is set to 0. when this bit is set to 1, change in the state of this bit is not reflected by the output of the brg for two counts of the counter. this allows the command to be synchronized. however, when set to 0, disabling is immediate. this bit is reset by a hardware reset. 5.2.18 write register 15 (external/status in- terrupt control) wr15 is the external/status source control register. if the external/status interrupts are enabled as a group via wr1, bits in this register control which external/status conditions cause an interrupt. only the external/status conditions that occur after the controlling bit is set to 1 cause an interrupt. this is true, even if an external/status condition is pending at the time the bit is set. bit positions for wr15 are shown in figure 5-18. on the cmos version, bits d2 and d0 are reserved. on the nmos version, bit d2 is reserved. these reserved bits should be written as 0s. figure 5-18. write register 15 d7 d6 d5 d4 d3 d2 d1 d0 write register 15 wr7' sdlc feature enable (reserved on nmos/cmos) zero count ie sdlc fifo enable (reserved on nmos) dcd ie sync/hunt ie cts ie tx underrun/eom ie break/abort ie scc /escc user? manual register descriptions 5-21 5 bit 7: brea/abort interrupt enable if this bit is set to 1, a change in the break/abort status of the receiver causes an external/status interrupt. this bit is set by a channel or hardware reset. bit 6: transmit underrun/eom interrupt enable if this bit is set to 1, a change of state by the tx under- run/eom latch in the transmitter causes an exter- nal/status interrupt. this bit is set to 1 by a channel or hardware reset. bit 5: cts interrupt enable if this bit is set to 1, a change of state on the /cts pin caus- es an external/status interrupt. this bit is set by a channel or hardware reset. bit 4: sync/hunt interrupt enable if this bit is set to 1, a change of state on the /sync pin causes an external/status interrupt in asynchronous mode, and a change of state in the hunt bit in the receiver causes and external/status interrupt in synchronous modes. this bit is set by a channel or hardware reset. bit 3: dcd interrupt enable if this bit is set to 1, a change of state on the /dcd pin causes an external/status interrupt. this bit is set by a channel or hardware reset. bit 2: status fifo enable control bit (cmos/escc) if this bit is set and if the cmos/escc is in the sdlc/hdlc mode, status (five bits from read register 1: residue, overrun, and crc error) and fourteen bits of byte count are held in the status fifo until read. status in- formation for up to ten frames can be stored. if this bit is reset (0) or if the cmos/escc is not in the sdlc/hdlc mode, the fifo is not operational and status information read reflects the current status only. this bit is reset to 0 by a channel or hardware reset. for details on this func- tion, refer to section 4.4.3. on the nmos version, this bit is reserved and should be programmed as 0. bit 1: zero count interrupt enable if this bit is set to 1, an external/status interrupt is gener- ated whenever the counter in the baud rate generator reaches 0. this bit is reset to 0 by a channel or hardware reset. bit 0: point to write register wr7 prime (escc and 85c30 only) when this bit is programmed to 0, writes to the wr7 ad- dress are made to wr7. when this bit is programmed to 1, writes to the wr7 address are made to wr7 prime. once set, this bit remains set unless cleared by writing a 0 to this bit or by a hardware or software reset. note that if the extended read option is enabled, wr7 prime is read in rr14. for details about wr7', refer to section 4.4.1.2 and section 5.2.9. on the nmos/cmos version, this bit is reserved and should be programmed as 0. 5.3 read registers the scc read register set in each channel has four status registers (includes receive data fifo), and two baud rate time constant registers in each channel. the interrupt vec- tor register (rr2) and interrupt pending register (rr3) are shared by both channels. in addition to these, the cmos/escc has two additional registers for the sdlc frame status fifo. on the escc, if that function is en- abled (wr7' bit d6=1), five more registers are available which return the value written to the write registers. the status of these registers is continually changing and depends on the mode of communication, received and transmitted data, and the manner in which this data is transferred to and from the cpu. the following description details the bit assignment for each register. 5.3.1 read register 0 (transmit/receive buffer status and external status) read register 0 (rr0) contains the status of the receive and transmit buffers. rr0 also contains the status bits for the six sources of external/status interrupts. the bit con- figuration is illustrated in figure 5-19. on the nmos/cmos version, note that the status of this register might be changing during the read. an enhancement allows the escc and 85c30 to latch the contents of rr0 during read transactions for this register. the latch is released on the rising edge of the /rd of the read transaction to this register. this feature prevents missed status due to changes that take place when the read cycle is in progress. figure 5-19. read register 0 d7 d6 d5 d4 d3 d2 d1 d0 read register 0 rx character available zero count tx buffer empty dcd sync/hunt cts tx underrun/eom break/abort scc /escc user? manual register descriptions 5-22 5.3 read registers (continued) bit 7: break/abort status in the asynchronous mode, this bit is set when a break se- quence (null character plus framing error) is detected in the receive data stream. this bit is reset when the se- quence is terminated, leaving a single null character in the receive fifo. this character is read and discarded. in sdlc mode, this bit is set by the detection of an abort se- quence (seven or more 1s), then reset automatically at the termination of the abort sequence. in either case, if the break/abort ie bit is set, an external/status interrupt is ini- tiated. unlike the remainder of the external/status bits, both transitions are guaranteed to cause an external/sta- tus interrupt, even if another external/status interrupt is pending at the time these transitions occur. this procedure is necessary because abort or break conditions may not persist. bit 6: transmit underrun/eom status this bit is set by a channel or hardware reset when the transmitter is disabled or a send abort command is issued. this bit is only reset by the reset tx underrun/eom latch command in wr0. when the transmit underrun occurs, this bit is set and causes an external/status interrupt (if the tx underrun/eom ie bit is set). only the 0-to-1 transition of this bit causes an interrupt. this bit is always 1 in asynchronous mode, unless a reset tx underrun/eom latch command has been erroneously issued. in this case, the send abort command can be used to set the bit to one and at the same time cause an exter- nal/status interrupt. bit 5: clear to send pin status if the cts ie bit in wr15 is set, this bit indicates the state of the /cts pin while no interrupt is pending, latches the state of the /cts pin and generates an external/status in- terrupt. any odd number of transitions on the /cts pin causes another external/status interrupt condition. if the cts ie bit is reset, it merely reports the current unlatched state of the /cts pin. bit 4: sync/hunt status the operation of this bit is similar to that of the cts bit, ex- cept that the condition monitored by the bit varies depend- ing on the mode in which the scc is operating. when the xtal oscillator option is selected in asynchro- nous modes, this bit is forced to 0 (no external/status in- terrupt is generated). selecting the xtal oscillator in syn- chronous or sdlc modes has no effect on the operation of this bit. the xtal oscillator should not be selected in external sync mode. in asynchronous mode, the operation of this bit is identical to that of the cts status bit, except that this bit reports the state of the /sync pin. in external sync mode the /sync pin is used by external logic to signal character synchronization. when the enter hunt mode command is issued in external sync mode, the /sync pin must be held high by the external sync logic un- til character synchronization is achieved. a high on the /sync pin holds the sync/hunt bit in the reset condition. when external synchronization is achieved, /sync is driv- en low on the second rising edge of the receive clock af- ter the last rising edge of the receive clock on which the last bit of the receive character was received. once /sync is forced low, it is good practice to keep it low until the cpu informs the external sync logic that synchronization is lost or that a new message is about to start. both transi- tions on the /sync pin cause external/status interrupts if the sync/hunt ie bit is set to 1. the enter hunt mode command should be issued when- ever character synchronization is lost. at the same time, the cpu should inform the external logic that character synchronization has been lost and that the scc is waiting for /sync to become active. in the monosync and bisync receive modes, the sync/hunt status bit is initially set to 1 by the enter hunt mode command. the sync/hunt bit is reset when the scc established character synchronization. both transitions cause external/status interrupts if the sync/hunt ie bit is set. when the cpu detects the end of message or the loss of character synchronization, the enter hunt mode com- mand should be issued to set the sync/hunt bit and cause an external/status interrupt. in this mode, the /sync pin is an output, which goes low every time a sync pattern is detected in the data stream. in the sdlc modes, the sync/hunt bit is initially set by the enter hunt mode command or when the receiver is disabled. it is reset when the opening flag of the first frame is detected by the scc. an external/status inter- rupt is also generated if the sync/hunt ie bit is set. unlike the monosync and bisync modes, once the sync/hunt bit is reset in sdlc mode, it does not need to be set when the end of the frame is detected. the scc automatically maintains synchronization. the only way the sync/hunt bit is set again is by the enter hunt mode command or by disabling the receiver. bit 3: data carrier detect status if the dcd ie bit in wr15 is set, this bit indicates the state of the /dcd pin the last time the enabled external/status bits changed. any transition on the /dcd pin, while no in- terrupt is pending, latches the state of the /dcd pin and scc /escc user? manual register descriptions 5-23 5 generates an external/status interrupt. any odd number of transitions on the /dcd pin while another external/status interrupt condition. if the dcd ie is reset, this bit merely re- ports the current, unlatched state of the /dcd pin. bit 2: tx buffer empty status this bit is set to 1 when the transmit buffer is empty. it is reset while the crc is sent in a synchronous or sdlc mode and while the transmit buffer is full. the bit is reset when a character is loaded into the transmit buffer. on the escc, the status of this bit is not related to the transmit interrupt status or the state of wr7' bit d5, but it shows the status of the entry location of the transmit fifo. this means more data can be written without being overwritten. this bit is set to 1 when the entry location of the transmit fifo is empty. it is reset when a character is loaded into the entry location of the transmit fifo. this bit is always in the set condition after a hardware or channel reset. for more information on this bit, refer to section 2.4.8 ?ransmit interrupts and transmit buffer empty bit? bit 1: zero count status if the zero count interrupt enable bit is set in wr15, this bit is set to one while the counter in the baud rate genera- tor is at the count of zero. if there is no other external/sta- tus interrupt condition pending at the time this bit is set, an external/status interrupt is generated. however, if there is another external/status interrupt pending at this time, no interrupt is initiated until interrupt service is complete. if the zero count condition does not persist beyond the end of the interrupt service routine, no interrupt is generated. this bit is not latched high, even though the other external/sta- tus latches close as a result of the low-to-high transition on zc. the interrupt routine checks the other external/sta- tus conditions for changes. if none changed, zc was the source. in polled applications, check the ip bit in rr3a for a status change and then proceed as in the interrupt ser- vice routine. bit 0: receive character available this bit is set to 1 when at least one character is available in the receive data fifo. it is reset when the receive data fifo is completely empty. a channel or hardware reset empties the receive data fifo. on the escc, the status of this bit is independent of wr7' bit d3. for details on this bit, refer to section 2.4.7, the receive interrupt. 5.3.2 read register 1 rr1 contains the special receive condition status bits and the residue codes for the l-field in sdlc mode. figure 5-20 shows the bit positions for rr1. bit 7: end of frame (sdlc) status this bit is used only in sdlc mode and indicates that a valid closing flag has been received and that the crc er- ror bit and residue codes are valid. this bit is reset by is- suing the error reset command. it is also updated by the first character of the following frame. this bit is reset in any mode other than sdlc. bit 6: crc/framing error status if a framing error occurs (in asynchronous mode), this bit is set (and not latched) for the receive character in which the framing error occurred. detection of a framing error adds an additional one-half bit to the character time so that the framing error is not interpreted as a new start bit. in synchronous and sdlc modes, this bit indicates the re- sult of comparing the crc checker to the appropriate check value. this bit is reset by issuing an error reset command, but the bit is never latched. therefore, it is al- ways updated when the next character is received. when used for crc error status in synchronous or sdlc modes, this bit is usually set since most bit combinations, except for a correctly completed message, result in a non- zero crc. on the cmos and escc, if the status fifo is enabled (re- fer to the description in write register 15, bit d2 and the de- scription in read register 7, bits d7 and d6), this bit reflects the status stored at the exit location of the status fifo. bit 5: receiver overrun error status this bit indicates that the receive fifo has overflowed. only the character that has been written over is flagged with this error. when that character is read, the error con- dition is latched until reset by the error reset command. figure 5-20. read register 1 d7 d6 d5 d4 d3 d2 d1 d0 read register 1 all sent residue code 2 residue code 1 residue code 0 parity error rx overrun error crc/framing error end of frame (sdlc) scc /escc user? manual register descriptions 5-24 5.3 read registers (continued) also, a special receive condition vector is returned, caused by the overrun characters and all subsequent char- acters received until the error reset command is issued. on the cmos and escc, if the status fifo is enabled (refer to the description in write register 15, bit d2 and the description in read register 7, bits d7 and d6), this bit re- flects the status stored at the exit location of the status fifo. bit 4: parity error status. when parity is enabled, this bit is set for the characters whose parity does not match the programmed sense (even/odd). this bit is latched so that once an error occurs, it remains set until the error reset command is issued. if the parity in special condition bit is set, a parity error caus- es a special receive condition vector to be returned on the character containing the error and on all subsequent characters until the error reset command is issued. bits 3, 2, and 1: residue codes, bits 2, 1, and 0 in those cases in sdlc mode where the received i-field is not an integral multiple of the character length, these three bits indicate the length of the i-field and are mean- ingful only for the transfer in which the end of frame bit is set. this field is set to 011 by a channel or hardware reset and is forced to this state in asynchronous mode. these three bits can leave this state only if sdlc is selected and a character is received. the codes signify the following (reference table 5-11) when a receive character length is eight bits per character. on the cmos and escc, if the status fifo is enabled (refer to the description in write register 15, bit d2 and the description in read register 7, bits d7 and d6), these bits reflect the status stored at the exit location of the status fifo. i-field bits are right-justified in all cases. if a receive character length other than eight bits is used for the i-field, a table similar to table 5-11 can be constructed for each different character length. table 5-12 shows the residue codes for no residue (the i-field boundary lies on a character boundary). bit 0: all sent status in asynchronous mode, this bit is set when all characters have completely cleared the transmitter pins. most mo- dems contain additional delays in the data path, which re- quires the modem control signals to remain active until af- ter the data has cleared both the transmitter and the modem. this bit is always set in synchronous and sdlc modes. 5.3.3 read register 2 rr2 contains the interrupt vector written into wr2. when the register is accessed in channel a, the vector returned is the vector actually stored in wr2. when this register is accessed in channel b, the vector returned includes status information in bits 1, 2 and 3 or in bits 6, 5 and 4, depending on the state of the status high/status low bit in wr9 and independent of the state of the vis bit in wr9. the vector is modified according to table 5-6 shown in the explanation of the vis bit in wr9 (section 5.2.11). if no interrupts are pending, the status is v3,v2,v1 -011, or v6,v5,v4-110. figure 5-21 shows the bit positions for rr2. table 5-11. i-field bit selection (8 bits only) bit 3 bit 2 bit 1 i-field bits in last byte i-field bits in previous byte 1 0 003 0 1 004 1 1 005 0 0 106 1 0 107 0 1 108 1 1 118 0 0 028 table 5-12. bits per character residue decoding bits per character bit 3 bit 2 bit 1 8011 7000 6010 5001 scc /escc user? manual register descriptions 5-25 5 5.3.4 read register 3 rr3 is the interrupt pending register. the status of each of the interrupt pending bits in the scc is reported in this register. this register exists only in channel a. if this register is accessed in channel b, all 0s are returned. the two unused bits are always returned as 0. figure 5-22 shows the bit positions for rr3. 5.3.5 read register 4 (escc and 85c30 only) on the escc, read register 4 reflects the contents of write register 4 provided the extended read option is en- abled. otherwise, this register returns an image of rr0. on the nmos/cmos version, a read to this location re- turns an image of rr0. 5.3.6 read register 5 (escc and 85c30 only) on the escc, read register 5 reflects the contents of write register 5 provided the extended read option is en- abled. otherwise, this register returns an image of rr1. on the nmos/cmos version, a read to this register re- turns an image of rr1. 5.3.7 read register 6 (not on nmos) on the cmos and escc, read register 6 contains the least significant byte of the frame byte count that is current- ly at the top of the status fifo. rr6 is shown in figure 5- 23. this register is readable only if the fifo is enabled (re- fer to the description write register 15, bit d2 and section 4.4.3). otherwise, this register is an image of rr2. on the nmos version, a read to this register location re- turns an image of rr2. 5.3.8 read register 7 (not on nmos) on the cmos and escc, read register 7 contains the most significant six bits of the frame byte count that is currently at the top of the status fifo. bit d7 is the fifo overflow status and bit d6 is the fifo data available status. the status indications are given in table 5-13. rr7 is shown in figure 5-24. this register is readable only if the fifo is enabled (refer to the description write register 15, bit d2). otherwise this register is an image of rr3. note, for proper operation of the fifo and byte count logic, the registers should be read in the following order: rr7, rr6, rr1. figure 5-21. read register 2 figure 5-22. read register 3 d7 d6 d5 d4 d3 d2 d1 d0 read register 2 v0 v1 v2 v3 v4 v5 v6 v7 interrupt vector * * modified in b channel d7 d6 d5 d4 d3 d2 d1 d0 read register 3 channel b ext/status ip channel b tx ip channel b rx ip channel a ext/status ip channel a tx ip channel a rx ip 0 0 * * always 0 in b channel figure 5-23. read register 6 (not on nmos) d7 d6 d5 d4 d3 d2 d1 d0 read register 6 * bc0 bc1 bc2 bc3 bc4 bc5 bc6 bc7 * can only be accessed if the sdlc fifo enhancement is enabled (wr15 bit d2 set to 1) sdlc fifo status and byte count (lsb) scc /escc user? manual register descriptions 5-26 5.3 read registers (continued) if the fifo overflows, the fifo and the fifo overflow status bit are cleared by disabling and then re-enabling the fifo through the fifo control bit (wr15, d2). otherwise, this register returns an image of rr3. on the nmos version, a read to this location returns an image of rr3. 5.3.9 read register 8 rr8 is the receive data register. 5.3.10 read register 9 (escc and 85c30 only) on the escc, read register 9 reflects the contents of write register 3 provided the extended read option has been enabled. on the nmos/cmos version, a read to this location re- turns an image of rr13. 5.3.11 read register 10 rr10 contains some miscellaneous status bits. unused bits are always 0. bit positions for rr10 are shown in figure 5-25. bit 7: one clock missing status while operating in the fm mode, the dpll sets this bit to 1 when it does not see a clock edge on the incoming lines in the window where it expects one. this bit is latched until reset by a reset missing clock or enter search mode command in wr14. in the nrzi mode of operation and while the dpll is disabled, this bit is always 0. bit 6: two clocks missing status while operating in the fm mode, the dpll sets this bit to 1 when it does not see a clock edge in two successive tries. at the same time the dpll enters the search mode. this bit is latched until reset by a reset missing clock or enter search mode command in wr14, bit 5-7. in the nrzi mode of operation and while the dpll is disabled, this bit is always 0. bit 4: loop sending status this bit is set to 1 in sdlc loop mode while the transmitter is in control of the loop, that is, while the scc is actively transmitting on the loop. this bit is reset at all other times. this bit can be polled in sdlc mode to determine when the closing flag has been sent. bit 1: on loop status this bit is set to 1 while the scc is actually on loop in sdlc loop mode. this bit is set to 1 in the x21 mode (loop mode selected while in monosync) when the trans- mitter goes active. this bit is 0 at all other times. this bit can also be pulled in sdlc mode to determine when the closing flag has been sent. figure 5-24. read register 7 (not on nmos) table 5-13. .read register 7 fifo status decoding bit d7 fifo data available status 1 status reads come from fifo (fifo is not empty) 0 status reads bypass fifo because fifo is empty) bit d6 fifo over?w status 1 fifo has over?wed 0 normal operation d7 d6 d5 d4 d3 d2 d1 d0 read register 7 * bc8 bc9 bc10 bc11 bc12 bc13 fda: fifo data available 1 = status reads from fifo 0 = status reads from escc fos: fifo overflow status 1 = fifo overflowed 0 = normal * can only be accessed if the sdlc fifo enhancement is enabled (wr15 bit d2 set to 1) sdlc fifo status and byte count (msb) figure 5-25. read register 10 d7 d6 d5 d4 d3 d2 d1 d0 read register 10 0 on loop 0 0 loop sending 0 two clocks missing one clock missing scc /escc user? manual register descriptions 5-27 5 5.3.12 read register 11 (escc and 85c30 only) on the escc, read register 11 reflects the contents of write register 10 provided the extended read option has been enabled. otherwise, this register returns an image of rr15. on the nmos/cmos version, a read to this location re- turns an image of rr15. 5.3.13 read register 12 rr12 returns the value stored in wr12, the lower byte of the time constant, for the brg. figure 5-26 shows the bit positions for rr12. 5.3.14 read register 13 rr13 returns the value stored in wr13, the upper byte of the time constant for the brg. figure 5-27 shows the bit positions for rr13. 5.3.15 read register 14 (escc and 85c30 only) on the escc, read register 14 reflects the contents of write register 7 prime provided the extended read option has been enabled. otherwise, this register returns an im- age of rr10. on the nmos/cmos version, a read to this location re- turns an image of rr10. 5.3.16 read register 15 rr15 reflects the value stored in wr15, the external/status ie bits. the two unused bits are always returned as os. figure 5-28 shows the bit positions for rr15. figure 5-26. read register 12 figure 5-27. read register 13 d7 d6 d5 d4 d3 d2 d1 d0 read register 12 tc0 tc1 tc2 tc3 tc4 tc5 tc6 tc7 lower byte of time constant d7 d6 d5 d4 d3 d2 d1 d0 read register 13 tc8 tc9 tc10 tc11 tc12 tc13 tc14 tc15 upper byte of time constant figure 5-28. read register 15 d7 d6 d5 d4 d3 d2 d1 d0 read register 15 0 zero count ie 0 dcd ie sync/hunt ie cts ie tx underrun/eom ie break/abort ie 5-28 6-1 6 a pplication n ote i nterfacing z80 ? cpu s to the z8500 p eripheral f amily 6 introduction the z8500 family consists of universal peripherals that can interface to a variety of microprocessor systems that use a non-multiplexed address and data bus. though similar to z80 peripherals, the z8500 peripherals differ in the way they respond to i/o and interrupt acknowledge cycles. in addition, the advanced features of the z8500 peripherals enhance system performance and reduce processor overhead. to design an effective interface, the user needs an understanding of how the z80 family interrupt structure works, and how the z8500 peripherals interact with this structure. this application note provides basic information on the interrupt structures, as well as a discussion of the hardware and software considerations involved in interfacing the z8500 peripherals to the z80 cpus. discussions center around each of the following situations: n z80a 4 mhz cpu to z8500 4 mhz peripherals n z80b 6 mhz cpu to z8500a 6 mhz peripherals n z80h 8 mhz cpu to z8500 4 mhz peripherals n z80h 8 mhz cpu to z8500a 6 mhz peripherals this application note assumes the reader has a strong working knowledge of the z8500 peripherals; it is not intended as a tutorial. cpu hardware interfacing the hardware interface consists of three basic groups of signals; data bus, system control, and interrupt control, described below. for more detailed signal information, refer to zilog? databook, universal peripherals. data bus signals d7-d0. data bus (bidirectional tri-state). this bus transfers data between the cpu and the peripherals. system control signals ad-a0. address select lines (optional). these lines select the port and/or control registers. /ce. chip enable (input, active low). /ce is used to select the proper peripheral for programming. /ce should be gated with /iorq or /mreq to prevent spurious chip selects during other machine cycles. /rd* read (input, active low). /rd activates the chip-read circuitry and gates data from the chip onto the data bus. /wr* write (input, active low). /wr strobes data from the data bus into the peripheral. *chip reset occurs when /rd and /wr are active simultaneously. interrupt control /intack. interrupt acknowledge (input, active low). this signal indicates an interrupt acknowledge cycle and is used with /rd to gate the interrupt vector onto the data bus. /int . interrupt request (output, open-drain, active low). the ius bit indicates that an interrupt is currently being serviced by the cpu. the ius bit is set during an interrupt acknowledge cycle if the ip bit is set and the iei line is high. if the iei line is low, the ius bit is not set, and the device is inhibited from placing its vector onto the data bus. in the z80 peripherals, the ius bit is normally cleared by decoding the reti instruction, but can also be cleared by a software command (sio). in the z8500 peripherals, the ius bit is cleared only by software commands. application note interfacing z80 ? cpus to the z8500 peripheral family 6-2 cpu hardware interfacing (continued) z80 interrupt daisy-chain operation in the z80 peripherals, both the ip and ius bits control the ieo line and the lower portion of the daisy chain. when a peripheral? ip bit is set, its ieo line is forced low. this is true regardless of the state of the iei line. additionally, if the peripheral? ius bit is clear and its iei line high, the /int line is also forced low. the z80 peripherals sample for both /m1 and /iorq active, and /rd inactive to identify and interrupt acknowledge cycle. when /m1 goes active and /rd is inactive, the peripheral detects an interrupt acknowledge cycle and allows its interrupt daisy chain to settle. when the /iorq line goes active with /m1 active, the highest priority interrupting peripheral places its interrupt vector onto the data bus. the ius bit is also set to indicate that the peripheral is currently under service. as long as the ius bit is set, the ieo line is forced low. this inhibits any lower priority devices from requesting an interrupt. when the z80 cpu executes the reti instruction, the peripherals monitor the data bus and the highest priority device under service resets its ius bit. z8500 interrupt daisy-chain operation in the z8500 peripherals, the ius bit normally controls the state of the ieo line. the ip bit affects the daisy chain only during an interrupt acknowledge cycle. since the ip bit is normally not part of the z8500 peripheral interrupt daisy chain, there is no need to decode the reti instruction. to allow for control over the daisy chain, z8500 peripherals have a disable lower chain (dlc) software command that pulls ieo low. this can be used to selectively deactivate parts of the daisy chain regardless of the interrupt status. table 1 shows the truth tables for the z8500 interrupt daisy-chain control signals during certain cycles. table 2 shows the interrupt state diagram for the z8500 peripherals. iei. interrupt enable in (input, active high). ieo. interrupt enable out (output, active high). these lines control the interrupt daisy chain for the peripheral interrupt response. z8500 i/o operation the z8500 peripherals generate internal control signals from /rd and /wr. since pclk has not required phase relationship to /rd or /wr, the circuitry generating these signals provides time for metastable conditions to disappear. the z8500 peripherals are initialized for different operating modes by programming the internal registers. these internal registers are accessed during i/o read and write cycles, which are described below. read cycle timing figure 1 illustrates the z8500 read cycle timing. all register addresses and /intack must remain stable throughout the cycle. if /ce goes active after /rd goes active, or if /ce goes inactive before /rd goes inactive, then the effective read cycle is shortened. table 1. z8500 daisy-chain control signals truth table for daisy chain signals during idle state truth table for daisy chain signals during /intack cycle iei ip ius ieo iei ip ius ieo 0x x 0 0x x 0 1x01 11x0 1x 1 0 1x 1 0 1001 application note interfacing z80 ? cpus to the z8500 peripheral family 6-3 6 write cycle timing figure 2 illustrates the z8500 write cycle timing. all register addresses and /intack must remain stable throughout the cycle. if /ce goes active after /wr goes active, or if /ce goes inactive before /wr goes inactive, then the effective write cycle is shortened. data must be available to the peripheral prior to the falling edge of /wr. figure 1. z8500 peripheral i/o read cycle timing figure 2. z8500 peripheral i/o write cycle timing application note interfacing z80 ? cpus to the z8500 peripheral family 6-4 peripheral interrupt operation understanding peripheral interrupt operation requires a basic knowledge of the interrupt pending (ip) and interrupt under service (ius) bits in relation to the daisy chain. both z80 and z8500 peripherals are designed in such a way that no additional interrupts can be requested during an interrupt acknowledge cycle. this allows that interrupt daisy chain to settle, and ensures proper response of the interrupting device. the ip bit is set in the peripheral when cpu intervention is required (such conditions as buffer empty, character available, error detection, or status changes). the interrupt acknowledge cycle does not necessarily reset the ip bit. this bit is cleared by a software command to the peripheral, or when the action that generated the interrupt is completed (i.e., reading a character, writing data, resetting errors, or changing the status). when the interrupt has been serviced, other interrupts can occur. the z8500 peripherals use /intack (interrupt acknowledge) for recognition of an interrupt acknowledge cycle. this pin, used in conjunction with /rd, allows the z8500 peripheral to gate its interrupt vector onto the data bus. an active /rd signal during an interrupt acknowledge cycle performs two functions. first, it allows the highest priority device requesting an interrupt to place its interrupt vector on the data bus. secondly, it sets the ius bit in the highest priority device to indicate that the device is currently under service. figure 3. z8500 interrupt state diagram application note interfacing z80 ? cpus to the z8500 peripheral family 6-5 6 input/output cycles although z8500 peripherals are designed to be as universal as possible, certain timing parameters differ from the standard z80 timing. the following sections discuss the i/o interface for each of the z80 cpus and the z8500 peripherals. figure 9 depicts logic for the z80a cpu to z8500 peripherals (and z80b cpu to z8500a peripherals) i/o interface as well as the interrupt acknowledge interface. figures 4 and 7 depict some of the logic used to interface the z80h cpu to the z8500 and z8500a peripherals for the i/o and interrupt acknowledge interfaces. the logic required for adding additional wait states into the timing flow is not discussed in the following sections. z80a cpu to z8500 peripherals no additional wait states are necessary during the i/o cycles, although additional wait states can be inserted to compensate for timing delays that are inherent in a system. although the z80a timing parameters indicate a negative value for data valid prior to /wr, this is a worse than ?orst case?value. this parameter is based upon the longest (worst case) delay for data available from the falling edge of the cpu clock minus the shortest (best case) delay for cpu clock high to /wr low. the negative value resulting from these two parameters does not occur because the worst case of one parameter and the best case of the other do not occur within the same device. this indicates that the value for data available prior to /wr will always be greater than zero. all setup and pulse width times for the z8500 peripherals are met by the standard z80a timing. in determining the interface necessary, the /ce signal to the z8500 peripherals is assumed to be the decoded address qualified with the /iorq signal. figure 4 shows the minimum z80a cpu to z8500 peripheral interface timing for i/o cycles. if additional wait states are needed, the same number of wait states can be inserted for both i/o read and write cycles to simplify interface logic. there are several ways to place the z80a cpu into a wait condition (such as counters or shift registers to count system clock pulses), depending upon whether or not the user wants to place wait states in all i/o cycles, or only during z8500 i/o cycles. tables 3 and 4 list the z8500 peripheral and the z80a cpu timing parameters (respectively) of concern during the i/o cycles. tables 5 and 6 list the equations used in determining if these parameters are satisfied. in generating these equations and the values obtained from them, the required number of wait states was taken into account. the reference numbers in tables 3 and 4 refer to the timing diagram in figure 4. application note interfacing z80 ? cpus to the z8500 peripheral family 6-6 input/output cycles (continued) . table 2. z8500 timing parameters i/o cycles worst case min max units 6. tsa(wr) address to /wr to low setup 80 ns 1. tsa(rd) address to /rd low setup 80 ns 2. tda(dr) address to read data valid 590 tscei(wr) /ce low to /wr low setup ns tscei(rd) /ce low to /rd low setup ns 4. twrdi /rd low width 390 ns 8. twwri /wr low width 390 ns 3. tdrdf(dr) /rd low to read data valid 255 ns 7. tsdw(wr) write data to /wr low setup 0 ns table 3. z80a timing parameters i/o cycles worst case min max units tcc clock cycle period 250 ns twch clock cycle high width 110 ns tfc clock cycle fall time 30 ns tdcr(a) clock high to address valid 110 ns tdcr(rdf) clock high to /rd low 85 ns tdcr(iorqf) clock high to /iorq low 75 ns tdcr(wrf) clock high to /wr low 65 ns 5. tsd(cf) data to clock low setup 50 ns table 4. parameter equations z8500 parameter z80a equation value units tsa(rd) tcc-tdcr(a) 140 min ns tda(dr) 3tcc+twch-tdcr(a)-tsd(cf) 800 min ns tdrdf(dr) 2tcc+twch-tsd(cf) 460 min ns twrd1 2tcc+twch+tfc-tdcr(rdf) 525 min ns tsa(wr) tcc-tdcr (a) 140 min ns tsdw(wr) >0 min ns twwr1 2tcc+twch+tfc-tdcr(wrf) 560 min ns table 5. parameter equations z80a parameter z8500 equation value units tsd(cf) 3tcc+twch-tdcr(a)-tda(dr) 160 min ns /rd 2tcc+twch-tdcr(rdf)-tdrd(dr) 135 min ns application note interfacing z80 ? cpus to the z8500 peripheral family 6-7 6 figure 4. z80a cpu to z8500 peripheral minimum i/o cycle timing application note interfacing z80 ? cpus to the z8500 peripheral family 6-8 z80b cpu to z8500a peripherals no additional wait states are necessary during i/o cycles, although wait states can be inserted to compensate for any systems delays. although the z80b timing parameters indicate a negative value for data valid prior to /wr, this is a worse than ?orst case?value. this parameter is based upon the longest (worst case) delay for data available from the falling edge of the cpu clock minus the shortest (best case) delay for cpu clock high to /wr low. the negative value resulting from these two parameters does not occur because the worst case of one parameter and best case of the other do not occur within the same device. this indicates that the value for data available prior to /wr will always be greater than zero. all setup and pulse width times for the z8500a peripherals are met by the standard z80b timing. in determining the interface necessary, the /ce signal to the z8500a peripherals is assumed to be the decoded address qualified with /iorq signal. figure 5 shows the minimum z80b cpu to z8500a peripheral interface timing for i/o cycles. if additional wait states are needed, the same number of wait states can be inserted for both i/o read and i/o write cycles in order to simplify interface logic. there are several ways to place the z80b cpu into a wait condition (such as counters or shift registers to count system clock pulses), depending upon whether or not the user wants to place wait states in all i/o cycles, or only during z8500a i/o cycles. tables 6 and 7 list the z8500a peripheral and z80b cpu timing parameters (respectively) of concern during the i/o cycles. tables 8 and 9 list the equations used in determining if these parameters are satisfied. in generating these equations and the values obtained from them, the required number of wait states was taken into account. the reference numbers in tables 6 and 7 refer to the timing diagram of figure 5. figure 5. z80b cpu to z8500a peripheral minimum i/o cycle timing application note interfacing z80 ? cpus to the z8500 peripheral family 6-9 6 table 6. z8500a timing parameters i/o cycles worst case min max units 6. tsa(wr) address to /wr low setup 80 ns 1. tsa(rd) address to /rd low setup 80 ns 2. tda(dr) address to read data valid 420 ns tsce1(wr) /ce low to /wr low setup ns tsce1(rd) /ce low to /rd low setup ns 4. twrd1 /rd low width 250 ns 8. twwr1 /wr low width 250 ns 3. tdrdf(dr) /rd low to read data valid 180 ns 7. tsdw(wr) write data to /wr low setup 0 ns table 7. z80b timing parameters i/o cycles worst case min max units tcc clock cycle period 165 ns twch clock cycle high width 65 ns tfc clock cycle fall time 20 ns tdcr(a) clock high to address valid 90 ns tdcr(rdf) clock high to /rd low 70 ns tdcr(iorqf) clock high to /iorq low 65 ns tdcr(wrf) clock high to /wr low 60 ns 5. tsd(cf) data to clock low setup 40 ns table 8. parameter equations z8500a parameter z80b equation value units tsa(rd) tcc-tdcr(a) >75 min ns tda(dr) 3tcc+twch-tdcr(a)-tsd(cf) 430 min ns tdrdf(dr) 2tcc+twch+tsd(cf) 345 min ns twrd1 2tcc+twch+tfc-tdcr(rdf) 325 min ns tsa(wr) tcc-tdcr(a) 75 min ns tsdw(wr) > 0 min ns twwr1 2 tcc+twch+tfc-tdcr(wrf) 352 min ns table 9. parameter equations z8500a equation value units 3tcc+twch-tdcr(a)-tda(dr) 50 min ns 2tcc+twch-tdcr(rdf)-tdrd(dr) 75 min ns z80h cpu to z8500 peripherals application note interfacing z80 ? cpus to the z8500 peripheral family 6-10 z90h cpu to z8500 peripherals during an i/o read cycle, there are three z8500 parameters that must be satisfied. depending upon the loading characteristics of the /rd signal, the designer may need to delay the leading (falling) edge of /rd to satisfy the z8500 timing parameter tsa(rd) (addresses valid to /rd setup). since z80h timing parameters indicate that the /rd signal may go low after the falling edge of t2, it is recommended that the rising edge of the system clock be used to delay /rd (if necessary). the cpu must also be placed into a wait condition long enough to satisfy tda(dr) (address valid to read data valid delay) and tdrdf(dr) (/rd low to read data valid delay). during an i/o write cycle, there are three other z8500 parameters that must be satisfied. depending upon the loading characteristics of the /wr signal and the data bus, the designer may need to delay the leading (falling) edge of /wr to satisfy the z8500 timing parameters tsa(wr) (address valid to /wr setup). since z80h timing parameters indicate that the /wr signal may go low after the falling edge of t2, it is recommended that the rising edge of the system clock be used to delay /wr (if necessary). this delay will ensure that both parameters are satisfied. the cpu must also be placed into a wait condition long enough to satisfy twwr1 (/wr low pulse width). assuming that the /wr signal is delayed, only two additional wait states are needed during an i/o write cycle when interfacing the z80h cpu to the z8500 peripherals. to simplify the i/o interface, the designer can use the same number of wait states for both i/o read and i/o write cycles. figure 6 shows the minimum z80h cpu to z8500 peripheral interface timing for the i/o cycles (assuming that the same number of wait states are used for both cycles and that both /rd and /wr need to be delayed). figure 8 shows two suits that can be used to delay the leading (falling) edge of either the /rd or the /wr signals. there are several ways to place the z80a cpu into a wait condition (such as counters or shift registers to count system clock pulses), depending upon whether or not the use wants to place wait states in all i/o cycles, or only during z8500 i/o cycles. tables 3 and 10 list the z8500 peripheral and the z80h cpu timing parameters (respectively) of concern during the i/o cycles. tables 13 and 14 list the equations used in determining if these parameters are satisfied. in generating these equations and the values obtained from them, the required number of wait states was taken into account. the reference numbers in tables 3 and 10 refer to the timing diagram of figure 6. table 10. z80h timing parameter i/o cycles equation min max units tcc clock cycle period 125 twch clock cycle high width 55 ns tfc clock cycle fall time 10 ns tdcr(a) clock high to address valid 80 ns tdcr(rdf) clock high to /rd low 60 ns tdcr(iorqf) clock high to /iorq low 55 ns tdcr(wrf) clock high to /wr low 55 ns 5. tsd(cf) data to clock low setup 30 ns table 11. parameter equations z8500 parameter z80h equation value units tsa(rd) 2tcc-tdcr(a) 170 min ns tda(dr) 6tcc+twch-tdcr(a)-tsd(cf) 695 min ns tdrdf(dr) 4tcc+twch-tsd(cf) 523 min ns twrd1 4tcc+twch+tfc-tdcr(rdf) 503 min ns tsa(wr) /wr - delayed 2tcc-tdcr(a) 170 min ns tsdw(wr) >0 min ns twwr1 4tcc+twch+tfc 563 min ns application note interfacing z80 ? cpus to the z8500 peripheral family 6-11 6 figure 6. z80h cpu to z8500 peripheral minimum i/o cycle timing application note interfacing z80 ? cpus to the z8500 peripheral family 6-12 z80h cpu to z8500a peripherals during an i/o read cycle, there are three z8500a parameters that must be satisfied. depending upon the loading characteristics of the /rd signal, the designer may need to delay the leading (falling) edge of /rd to satisfy the z8500a timing parameter tsa(rd) (address valid to /rd setup). since z80h timing parameters indicate that the /rd signal may go low after the falling edge of t2, it is recommended that the rising edge of the system must also be placed into wait condition long enough to satisfy tda(dr) (address valid to read data valid delay) and tdrdf(dr) (/rd low to read data valid delay). assuming that the /rd signal is delayed, then only one additional wait state is needed during an i/o read cycle when interfacing the z80h cpu to the z8500a peripherals. during an i/o write cycle, there are three other z850a parameters that have to be satisfied. depending upon the loading characteristics of the /wr signal and the data bus, the designer may need to delay the leading (falling) edge of /wr to satisfy the z8500a timing parameters tsa(wr) (address valid to /wr setup) and tsdw(wr) (data valid prior to /wr setup). since z80h timing parameters indicate that the /wr signal may go low after the falling edge of t2, it is recommended that the rising edge of the system clock be used to delay /wr (if necessary). this delay will ensure that both parameters are satisfied. the cpu must also be placed into a wait condition long enough to satisfy twwr1 (/wr low pulse width). assuming that the /wr signal is delayed, then only one additional wait state is needed during an i/o write cycle when interfacing the z80h cpu to the z8500a peripherals. figure 7 shows the minimum z80h cpu to z8500a peripheral interface timing for the i/o cycles (assuming that the same number of wait states are used for both cycles and that both /rd and /wr need to be delayed). figure 8 shows two circuits that may be used to delay leading (falling) edge of either the /rd or the /wr signals. there are several methods used to place the z80a cpu into a wait condition (such as counters or shift registers to count system clock pulses), depending upon whether or not the user wants to place wait states in all i/o cycles, or only during z8500a i/o cycles, tables 7 and 11 list the z8500a peripheral and the z80h cpu timing parameters (respectively) of concern during the i/o cycles. tables 14 and 15 list the equations used in determining if these parameters are satisfied. in generating these equations and the values obtained from them, the required number of wait states was taken into account. the reference numbers in table 4 and 11 refer to the timing diagram of figure 7. table 12. parameter equations z80h parameter z8500 equation value units tsd(cf) 6tcc+twch-tdcr(a)-tda(dr) 135 min ns /rd - delayed 4tcc+twch+tfc-tdrd(dr) 300 min ns table 13. parameter equations z8500a parameter z80h equation value units tsa(rd) 2tcc-tdcr(a) 170 min ns tda(dr) 6tcc+twch-tdcr(a)-tsd(cf) 695 min ns tdrdf(dr) 4tcc+twch-tsd(cf) 525 min ns twrd1 4tcc+twch+tfc-tdcr(rdf) 503 min ns tsa(wr) /wr - delayed 2tcc-tdcr(a) 170 min ns tsdw(wr) >0 min ns twwr1 2tcc+twch+tfc 313 min ns application note interfacing z80 ? cpus to the z8500 peripheral family 6-13 6 figure 7. z80h cpu to z8500a peripheral minimum i/o cycle timing application note interfacing z80 ? cpus to the z8500 peripheral family 6-14 z80h cpu to z8500a peripherals (continued) figure 8. delaying /rd or /wr table 14. parameter equations z80h parameter z8500a equation value units tsd(cf) 4tcc+twch-tdcr(a)-tda(dr) 55 min ns /rs - delayed 2tcc+twch-tdrd(dr) 125 min ns application note interfacing z80 ? cpus to the z8500 peripheral family 6-15 6 interrupt acknowledge cycles the primary timing differences between the z80 cpus and z8500 peripherals occur in the interrupt acknowledge cycle. the z8500 timing parameters that are significant during interrupt acknowledge cycles are listed in table 16, while the z80 parameters are listed in table 17. the reference numbers in tables 16 and 17 refer to figures 10, 12 and 13. if the cpu and the peripherals are running at different speeds (as with the z80h interface), the /intack signal must be synchronized to the peripheral clock. synchronization is discussed in detail under interrupt acknowledge for z80h cpu to z8500/8500a peripherals. during an interrupt acknowledge cycle, z8500 peripherals require both /intack and /rd to be active at certain times. since the z80 cpus do not issue either /intack or /rd, external logic must generate these signals. generating these two signals is easily accomplished, but the z80 cpu must be placed into a wait condition until the peripheral interrupt vector is valid. if more peripherals are added to the daisy chain, additional wait states may be necessary to give the daisy chain time to settle. sufficient time between /intack active and /rd active should be allowed for the entire daisy chain to settle. since the z8500 peripheral daisy chain does not use the ip flag except during interrupt acknowledge, there is no need for decoding the reti instruction used by the z80 peripherals. in each of the z8500 peripherals, there are commands that reset the individual ius flags. external interface logic the following sections discuss external interface logic required during interrupt acknowledge cycles for each interface type. cpu/peripheral same speed figure 9 shows the logic used to interface the z80a cpu to the z8500 peripherals and the z80b cpu to z8500a peripherals during an interrupt acknowledge cycle. the primary component in this logic is the shift register (74ls164), which generates /intack, /read, and /wait. . table 15. z8500 timing parameters interrupt acknowledge cycles 4 mhz 6 mhz worst case min max min max units 1. tsia(pc) /intack low to pclk high setup 100 100 ns thia(pc) /intack low to pclk high hold 100 100 ns 2. tdiai(rd) /intack low to rd (acknowledge) low 350 250 ns 5. twrda /rd (acknowledge) width 350 250 ns 3. tdrda(dr) /rd (acknowledge) to data valid 250 180 ns tsiei(rda) iei to /rd (acknowledge) setup 120 100 ns thiei(rda) iei to /rd (acknowledge) hold 100 70 ns tdiei(ie) iei to ieo delay 150 100 ns table 16. z80 cpu timing parameters interrupt acknowledge cycles 4 mhz 6 mhz 8 mhz worst case min max min max min max units tdc(m1f) clock high to /m1 low delay 100 80 70 ns tdm1f(iorqf) /m1 low to /iorq low delay 575* *345 275* ns 4. tsd(cr) data to clock high setup 35 30 25 ns *z80a: 2tcc + twch + tfc - 65 z80b: 2 tcc + twch + tfc - 50 z80h: 2tcc + twch + tfc - 45 application note interfacing z80 ? cpus to the z8500 peripheral family 6-16 external interface logic (continued) during i/o and normal memory access cycles, the shift registers remains cleared because the /m1 signal is inactive. during opcode fetch cycles, also, the shift register remains cleared, because only 0s can be clocked through the register. since shift register outputs are low, /read, /write, and /wait are controlled by other system logic and gated through the and gates (74ls11). during i/o and normal memory access cycles, /read and /write are active as a result of the system /rd and /wr signals (respectively) becoming active. if system logic requires that the cpu be placed into a wait condition, the /wait signal controls the cpu. should it be necessary to reset the system, /reset causes the interface logic to generate both /read and /write (the z8500 peripheral reset condition). normally an interrupt acknowledge cycle is indicated by the z80 cpu when /m1 and /iorq are both active (which can be detected on the third rising clock edge after t1). to obtain an early indication of an interrupt acknowledge cycle, the shift register decodes an active /m1 in the presence of an inactive /mreq on the rising edge of t2. during an interrupt acknowledge cycle, the /intack signal is generated on the rising edge of t2. since it is the presence of /intack and an active /read that gates the interrupt vector onto the data bus, the logic must also generate /read at the is td1ai(rd) /intack to /rd (acknowledge) low delay]. this time delay allows the interrupt daisy chain to settle so that the device requesting the interrupt can place its interrupt vector onto the data bus. the shift register allows a sufficient time delay from the generation of /intack before it generates /read. during this delay, it places the cpu into a wait state until the valid interrupt vector can be placed onto the data bus. if the time between these two signals is insufficient for daisy chain settling, more time can be added by taking /read and /wait from a later position on the shift register. figure 10 illustrates interrupt acknowledge cycle timing resulting from the z80a cpu to z8500 peripheral and the z80b cpu to a8500a peripheral interface. this timing comes from the logic illustrated in figure 9, which can be used for both interfaces. should more wait states be required, the additional time can be calculated in terms of system clocks, since the cpu clock and pclk are the same. figure 9. z80a/z80b cpu to z8500/z8500a peripheral interrupt acknowledge interface logic application note interfacing z80 ? cpus to the z8500 peripheral family 6-17 6 z8500/z8500a peripherals figure 11 depicts logic that can be used in interfacing the z80h cpu to the z8500/z8500a peripherals. this logic is the same as that shown in figure 5, except that a synchronizing flip-flop is used to recognize an interrupt acknowledge cycle. since z8500 peripherals do not rely upon pclk except during interrupt acknowledge cycles, synchronization need occur only at that time. since the cpu and the peripherals are running at different speeds, /intack and /rd must be synchronized to the z8500 peripherals clock. during i/o and normal memory access cycles, the synchronizing flip-flop and the shift register remain cleared because the /m1 signal is inactive. during opcode fetch cycles, the flip-flop and the shift register again remain cleared, but this time because the /mreq signal is active. the synchronizing flip-flop allows an interrupt acknowledge cycle to be recognized on the rising edge of t2 when /m1 is active and /mreq is inactive, generating the inta signal. when inta is active, the shift register can clock and generate /intack to the peripheral and /wait to the cpu. the shift register delays the generation of /read to the peripheral until the daisy chain settles. the /wait signal is removed when sufficient time has been allowed for the interrupt vector data to be valid. figure 12 illustrates interrupt acknowledge cycle timing for the z80h cpu to z8500 peripheral interface. figure 13 illustrates interrupt acknowledge cycle timing for the z80h cpu to z8500a peripheral interface. these timing result from the logic in figure 11. should more wait states be required, the needed time should be calculated in terms of pclks, not cpu clocks. z80 cpu to z80 and z8500 peripherals in a z80 system, a combination of z80 peripherals and z8500 peripherals can be used compatibly. while there is no restriction on the placement of the z8500 peripherals in the daisy chain, it is recommended that they be placed early in the chain to minimize propagation delays during ret1 cycles. during an interrupt acknowledge cycle, the ieo line from z8500 peripherals changes to reflect the interrupt status. time should be allowed for this change to ripple through the remainder of the daisy chain before activating /iorq to the z80 peripherals, or /read to the z8500 peripherals. figure 10. z80a/z80b cpu to z8500/z8500a peripheral interrupt acknowledge interface timing application note interfacing z80 ? cpus to the z8500 peripheral family 6-18 external interface logic (continued) during reti cycles, the ieo line from the z8500 peripherals does not change state as in the z80 peripherals. as long as the peripherals are at the top of the daisy chain, propagation delays are minimized. the logic necessary to create the control signals for both z80 and z8500 peripherals is shown in figure 9. this logic delays the generation of /iorq to the z80 peripherals by the same amount of time necessary to generate /read for the z8500 peripherals. timing for this logic during an interrupt acknowledge cycle is depicted in figure 10. figure 11. z80h to z8500/z8500a peripheral interrupt acknowledge interface logic application note interfacing z80 ? cpus to the z8500 peripheral family 6-19 6 figure 12. z80h cpu to z8500 peripheral interrupt acknowledge interface timing figure 13. z80h cpu to z8500a peripheral interrupt acknowledge interface timing application note interfacing z80 ? cpus to the z8500 peripheral family 6-20 external interface logic (continued) figure 14. z80 and z8500 peripheral interrupt acknowledge interface logic application note interfacing z80 ? cpus to the z8500 peripheral family 6-21 6 figure 15. z80 and z8500 peripheral interrupt acknowledge interface timing application note interfacing z80 ? cpus to the z8500 peripheral family 6-22 software considerations - polled operation there are several options available for servicing interrupts on the z8500 peripherals. since the vector of ip registers can be read at any time, software can be used to emulate the z80 interrupt response. the interrupt vector read reflects the interrupt status condition even if the device is programmed to return to vector that does not reflect the status change (sav or vis is not set). the code below is a simple software routine that emulates the z80 vector response operation. z80 vector interrupt response, emulation by software ;this code emulates the z80 vector interrupt ;operation by reading the device interrupt ;vector and forming an address from a vector ;table. it then executes an indirect jump to ;the interrupt service routine. indx: ld a,civreg ;current int. vect. reg out (ctrl), a ;write reg. ptr. in a, (ctrl) ;read vect. reg. inc a ;valid vector? ret z ;no int - return and 00001110b ;mask other bits ld e,a ld d,0 ;form index value ld hl,vectab add hl,de ;add vect. table addr. ld a, (hl) ;get low byte inc hl ld h, (hl) ;get high byte ld l,a ;form routine addr. jp (hl) ;jump to it vectab: defw int1 defw int2 defw int3 defw int4 defw int5 defw int6 defw int7 defw int8 application note interfacing z80 ? cpus to the z8500 peripheral family 6-23 6 a simple z80-z8500 system the z8500 devices interface easily to the z80 cpu, thus providing a system of considerable flexibility. figure 16 illustrates a simple system using the z80a cpu and z8536 counter/timer and parallel i/o unit (cio) in a mode 1 or non-interrupt environment. since interrupt vectors are not used, the /intack line is tied high and no additional logic is needed. because the cio can be used in a polled interrupt environment, the /int pin is connected to the cpu. the z80 should not be set for mode 2 interrupts since the cio will never place a vector onto the data bus. instead, the cpu should be placed into mode 1 interrupt mode and a global interrupt service routine can poll the cio to determine what caused the interrupt to occur. in this system, the software emulation procedure described above is effective. additional information in zilog publications: the z80 family user? manual includes technical information on the z80 cpu, dma, pio, ctc, and sio. technical information on the z80 cpu ac characteristics and the z80 family interrupt structure tutorial can be found in the z80 databook. the z8000 user? manual features technical information on the z8536 cio and z8038 fio. figure 16. z80 to z8500 simple system mode 1 interrupt or non-interrupt structure 6-24 6-25 7 a pplication n ote t he z180 i nterfaced with the scc at mhz 7 uild a simple system to prove and test the z180 mpu interfacing the scc at 10 mhz. replacing the z80 with the z180 provides higher integration, reduced parts, more board space, increased processing speed, and greater reliability. b introduction this application note describes the design of a system using a z80180 mpu (microprocessor unit) and a Z85C30 scc (serial communications controller), both running at 10 mhz. hereinafter, all references are to the z180 and scc. the system board is a vehicle for demonstration and evaluation of the 10 mhz interface and includes the following parts: n z8018010vsc z180 mpu 10 mhz, plcc package n Z85C3010vsc c-mos z8530 scc serial com- munication controller, 10 mhz, plcc package n 27c256 eprom n 55257 static ram the z180 is a z80-compatible high integration device with various peripherals on-board. using this device as an alternative to the z80 cpu, reduces the number of parts and board space while increasing processing speed and reliability. the serial communication devices on the z180 are: two asynchronous channels and one clocked serial channel. this means handling synchronous serial communications protocols requires an off-chip ?ulti-protocol serial communication controller.?the scc is the ideal device for this purpose. zilog? scc is the multi-protocol (@ 10 mhz) universal serial communication controller which supports most serial communication applications including monosync, bisync and sdlc at 2.5 mbits/sec speeds. further, the wide acceptance of this device by the market ensures it is an ?ndustry standard?serial communication controller. also, the z180 has special numbers for system clock frequencies of 6.144 - and 9.216 mhz which generate exact baud rates for on-chip asynchronous serial communication channels. this is due to the scc? on- chip, 16-bit wide baud rate generator for asynchronous asci communications. the following 10 mhz interface explanation defines how the interrupt structure works. also included is a discussion of the hardware and software considerations involved in running the system? communication board. this application note assumes the reader has a strong working knowledge of the z180 and scc; this is not a tutorial for each device. application note the z180 interfaced with the scc at mhz 6-26 interfaces the following subsections explain the interfaces between the: n z180 and memory n z180 and i/o n z180 and scc basic goals of this system design are: n system clock up to 10 mhz n using the z8018010vsc (z180 10 mhz plcc package) to take advantage of 1m byte addressing space and compactness (dip versions?addressing range is half; 512k bytes) n using Z85C3010vsc (cmos scc 10 mhz plcc package) n minimum parts count n worst case design n using epld for glue wherever possible n expendability the design method for epld is using ttls (74hct) and then translating them into epld logic. this design uses ttls and eplds. with these goals in mind, the discussion begins with the z180-to-memory interface. z180 to memory interface the memory access cycle timing of the z180 is similar to the z80 cpu memory access cycle timing. the three classifications are: n opcode fetch cycle (figure 1) n memory read cycle (figure 2) n memory write cycle (figure 3) table 1 shows the z180? basic timing elements for the opcode? fetch/memory read/write cycle. figure 1. z180 opcode fetch cycle timing (one wait state) 7 6 8 9 12 11 13 11 15 16 10 14 addres s /mreq /rd data /m1 read data t1 t2 tw t3 t1 application note the z180 interfaced with the scc at mhz 6-27 7 table 1. z8018010 timing parameters for opcode fetch cycle (worst case: z180 10 mhz) no symbol parameter min max units 1 tcyc clock cycle period 100 ns 2 tchw clock cycle high width 40 ns 3 tclw clock cycle low width 40 ns 4 tcf clock fall time 10 ns 6 tad clock high to address valid 70 ns 8 tmed1 clock low to /mreq low 50 ns 9 trdd1 clock low to /rd low 50 ns 11 tah address hold time 10 ns 12 tmed2 clock low to /mreq high 50 ns 15 tdrs data to clock setup 25 ns 16 tdrh data read hold time 0 ns 22 twrd1 clock high to /wr low 50 ns 23 twdd clock low to write data delay 60 ns 24 twds write data setup to /wr low 15 ns 25 twrd2 clock low to /wr high 50 ns 26 twrp /wr pulse width 110 ns 27 twdh /wr high to data hold time 10 ns note: parameter numbers in this table are in the z180 technical manual. figure 2. z180 memory read cycle timing (one wait state) 7 6 8 9 12 11 13 11 15 16 addres s /mreq /rd data read data t1 t2 tw t3 t1 application note the z180 interfaced with the scc at mhz 6-28 eprom interface during an opcode fetch cycle, data sampling of the bus is on the rising phi clock edge of t3 and on the falling edge of t3 during a memory read cycle. opcode fetch cycle data sample timing is half a clock cycle earlier. table 2 shows how a memory read cycles?timing requirements are easier than an opcode fetch cycle by half a phi cycle time. if the timing requirements for an opcode fetch cycle meet specifications, the design satisfies the timing requirements for a memory read cycle. table 2 has some equations for an opcode fetch, memory read/write cycle. the propagation delay for the decoded address and gates in the previous calculation is zero. hence, on the real design, subtracting another 20-30 ns to pay for propagation delays, is possible. the 27c256 provides the eprom for this board. typical timing parameters for the 27c256 are in table 3. sram interface table 4 has timing parameters for 256k bit sram for this design.) sram read cycle. an sram read cycle shares the same considerations as an eprom interface. like eprom, srams??ccess time?applies /g to data valid, and ?e active to data valid?is shorter than ?ccess time.?this design allows the use of a 150 ns access time sram by adding one wait state (using the on-chip wait state generator of the z180). the circuit is common to the eprom memory read cycle. no wait states are necessary if there is a 85 ns, or faster, access time by using srams. since the z180 has on-chip mmu with 85 ns or faster sram just copy the contents of eprom (application program starts at logical address 0000h) into sram after power on. set up the mmu to sram area to override the eprom area and stop table 2. parameter equations (10 mhz) opcode fetch/memory read/write cycle parameters z180 equation value units address valid to data valid (opcode fetch) 2(1+w)tcyc-tad-tdrs 105+100w min ns address valid to data valid (memory read 2(1+w)tcyc+tchw+tcf-tad-tdrs 155+100w min ns /mreq active to data valid (opcode fetch) (1+w)tcyc+tclw-tmed1-tdrs 55+100w min ns /mreq active to data valid (memory read) (2+w)tcyc-tmed1-tdrs 105+100w min ns /rd active to data valid (opcode fetch) (1+w)tcyc+tclw-trrd1-tdrs 55+100w min ns /rd active to data valid (memory read) (2+w)tcyc-trrd1-tdrs 105+100w min ns memory write cycle /wr pulse width twrp+w*tcyc 110+100w min ns note: * w is the number of wait states. table 3. eprom (27c256) key timing parameters (values may vary depending on mfg.) access time 170 ns 200 ns 250 ns parameter max max max addr access time 170 200 250 /e to data valid 170 200 250 /oe to data valid 75 75 100 note: table 3 shows ?ccess time?as applying /e to data valid. ?oe active to data valid?is shorter than ?ddress access time? hence, the interface logic for the eprom is: realize a 170 ns or faster eprom access time by adding one wait state (using the on-chip wait state generator of the z180). a 200 ns requirement uses two wait states for memory access. table 4. 256k sram key timing parameters (values may vary depending on mfg.) access time 85 ns 100 ns 150 ns parameter min min min read cycle: /e to data valid 85 100 150 /g to data valid 45 40 60 write cycle: write cycle time 85 100 150 addr valid to end of write 75 80 100 chip select to end of write 75 80 100 data select to end of write 40 40 60 write pulse width 60 60 90 addr setup time 0 0 0 application note the z180 interfaced with the scc at mhz 6-29 7 inserting wait states. with this scheme, you can get the highest performance with moderate cost. sram write cycle. during a z180 memory write cycle, the z180 write data is stable before the falling edge of /wr (z180 parameter #24; 15 ns min at 10 mhz). it is stable throughout the write cycle (z180 parameter #27; 10 ns min at 10 mhz). further, the address is fixed before the falling edge of /wr. as long as the /wr pulse width meets the sram? spec, there is no problem (reference table 2). memory interface logic the memory devices (eprom and sram) for this design are 256k bit (32k byte). there are two possible memory interface designs: connect address decode output to /e input. put the signal generated by /rd and /mreq anded together to /oe of eprom and sram. put the signal generated by /wr and /mreq anded together to the /we pin of sram (figure 4a). connect the signal address anded together with inactive /iorq to the /e input. connect /rd to /oe of eprom and sram, and /wr to /we pin of sram (figure 4b). using the second method, there could be a narrow glitch on the signal to the /e-pin during i/o cycles and the interrupt acknowledge cycle. during i/o cycles, /iorq and /rd or /wr go active at almost the same time. since the delay times of these signals are similar there is no ?verlapping time?between /ce generated by the address (/iorq inactive), and /wr or /rd active. during the interrupt acknowledge cycle, /wr and /rd signals are inactive. to keep the design simple and flexible, use the second method (figure 4b). to expand memory, decode the address a15 nanded with /usrram//usrrom and /iorq to produce /csram or /csrom. these are chip select inputs to chips 55257 or 27c256, respectively. this either disables or enables on-board rom or ram depending upon selection control. the circuit on figure 4b gives the physical memory address as shown on figure 5. if there are no z80 peripherals and /m1 is enabled (m1e bit in z180 omcr register set to 1), active wait states occur only during opcode fetch cycles (figure 6). if the m1e bit is cleared to 0, /m1e is active only during the interrupt acknowledge cycle and return from interrupt cycle. this case depends on the propagation delay of the address decoder which uses 135 ns or faster eprom assess time (assume there is 20 ns propagation delay). figure 6 shows the example of this implementation. figure 3. z180 memory write cycle timing (one wait state) 6 2 2 12 11 2 6 25 2 7 addres s /mreq /wr data t1 t2 tw t3 t1 8 2 4 2 3 application note the z180 interfaced with the scc at mhz 6-30 (continued) figure 4a. memory interface logic g /g2a /g2b c b a a9 a18 a17 a16 a15 /y9 /y6 /y5 /y4 /y3 /y2 /y1 /y0 /38000 ~ /30000 ~ /28000 ~ /20000 ~ /18000 ~ /10000 ~ /08000 ~ to 55257 /e pin /00000 ~ to 27c256 /e pin hct138 /rd /mreq /wr * /memr to 27c56 /oe, 55257 /oe pin * /memw to 55257 /we pin /rd to /oe pin of 27c256 and 55257 /wr to /we pin of 55257 * figure 4b. memory interface logic 4.7 k w x2 /csram to 55257 /ce pin /csrom to 27c256 /ce pin /usrram /iorq a15 /usrrom hct10 application note the z180 interfaced with the scc at mhz 6-31 7 (extends opcode fetch cycle only; not working in z mode of operation) figure 5. physical memory address map s-ram image ep-rom image s-ram image /ep-rom image s-ram image ep-rom image 256k sram ep-rom 27c256 fffffh f8000h f0000h 28000h 20000h 18000h 10000h 08000h 00000h image can be killed trhrough /usrram and /usrrom figure 6. wait state generator logic d ck q cl pr d ck q cl pr '74 '74 /m1 /m1 /wait application note the z180 interfaced with the scc at mhz 6-32 z180 to i/o interface the z180 i/o read/write cycle is similar to the z80 cpu if you clear the /ioc bit in the omcr register to 0 (figures 7 and 8). table 5 shows the z180 key parameters for an i/o cycle. figure 7. z180 i/o read cycle timing (/ioc = 0) 29 13 11 addres s /iorq /rd data t1 t2 t t3 t1 6 28 11 19 16 15 wa figure 8. z180 i/o write cycle timing 29 25 addres s /iorq /wr data t1 t2 tw t3 t1 6 25 11 22 27 23 26 21 2 4 application note the z180 interfaced with the scc at mhz 6-33 7 . if you are familiar with the z80 cpu design, the same interfacing logic applies to the z180 and i/o interface (see figure 9a). this circuit generates /iord (read) or iord (write) for peripherals from inputs /iorq, /rd, and /wr. the address decodes the chip select signal. note, if you have z80 peripherals, the decoder logic decodes only from addresses (does not have /iorq). the z180 signals /iorq, /rd, and /wr are active at about the same time (parameters #9, 22, 28). however, most of the z80 peripherals require /ce to /rd or /wr setup time. since the z180 occupies 64 bytes of i/o addressing space for system control and on-chip peripherals, there are no overlapping i/o addresses for off-chip peripherals. in this design, leave the area as default or assign on-chip registers at i/o address 0000h to 003fh. figure 9 shows a simple address decoder (the required interface signals, other than address decode outputs, are discussed later). table 5. z8018010 timing parameters for i/o cycle (worst case) no symbol parameter min max units 1 tcyc clock cycle period 100 ns 2 tchw clock cycle high width 40 ns 3 tclw clock cycle low width 40 ns 4 tcf clock fall time 10 ns 6 tad clock high to address valid 70 ns 9 trdd1 clock high to /rd low ioc=0 55 ns 11 tah address hold time 10 ns 13 trdd2 clock low to /rd high 50 ns 15 tdrs data to clock setup 25 ns 16 tdrh data read hold time 0 ns 21 twdz clock high to data float delay 60 ns 22 twrd1 clock high to /wr low 50 ns 23 twdd clock low to write data delay 60 ns 24 twds write data setup to /wr low 15 ns 25 twrd2 clock low to /wr high 50 ns 26a twrp /wr pulse width (i/o write) 210 ns 27 twdh /wr high to data hold time 10 ns 28 tiod1 clock high to /iorq low ioc=0 55 ns 29 tiod2 clock low to /iorq high 50 ns note: parameter numbers in this table are the numbers in the z180 technical manual. figure 9a. i/o interface logic (example) /g2a /g2b c b a a17 a2 a5 a4 a3 /y9 /y6 /y5 /y4 /y3 /y2 /y1 /y0 50 ~ 58 ~ 54 ~ 50 ~ 40 ~ 48 ~ 44 ~ 40 ~ hct138 /iorq /rd /wr /iord to each peripherals' /rd /iowr to each peripherals' /wr a6 g1 chip select signals for peripherals application note the z180 interfaced with the scc at mhz 6-34 (continued) when expanding this board to enable other peripherals, the decoded address a6/a7 is nanded with usrio to produce the chip enable (csscc) output signal (hc10). the scc registers are assigned from address xxc0h to xxc3h; with image, they occupy xxc0h to xxffh. to add wait states during i/o transactions, use the z180 on-chip wait state generator instead of external hardware logic. if there is a z80 pio on board in a z-mode of operation (that is, clear /m1e in omcr register to zero) and after enabling a z80 pio interrupt, zero is written to m1te in the omcr register. without a zero, there is no interrupt from the z80 pio. the z80 pio requires /m1 to activate an interrupt circuit after enabling interrupt by software. z180 to scc interface the following subsections discuss the various parameters between the z180/scc interface: cpu hardware, i/o operation (read/write), scc interrupts, z80 interrupt daisy- chain operation, scc interrupt daisy-chain operation, i/o cycles. cpu hardware interfacing the hardware interface has three basic groups of signals: data bus, system control, and interrupt control. for more detailed signal information, refer to zilog? technical manuals, and product specifications for each device. data bus signals d7-d0. data bus (bidirectional, tri-state). this bus transfers data between the z180 and scc. system control signals a//b, c//d. register select signals (input). these lines select the registers. /ce. chip enable (input, active low). /ce selects the proper peripheral for programming. /ce is gated with /iorq or /mreq to prevent false chip selects during other machine cycles. /rd+. read (input, active low). /rd activates the chip- read circuitry and gates data from the chip onto the data bus. /wr+. write (input, active low). /wr strobes data from the data bus into the peripheral. chip reset occurs when /rd and /wr are active simultaneously. interrupt control /intack. interrupt acknowledge (input, active low). this signal shows an interrupt acknowledge cycle which combines with /rd to gate the interrupt vector onto the data bus. /int. interrupt request (output, open-drain, active low). iei. interrupt enable in (input, active high). ieo. interrupt enable out (output, active high). these lines control the interrupt daisy chain for the peripheral interrupt response. scc i/o operation the scc generates internal control signals from /rd or /wr. since pclk has no required phase relationship to /rd or /wr, the circuitry generating these signals provides time for meta stable conditions to disappear. the scc starts the different operating modes by programming the internal registers. accessing these internal registers occurs during i/o read and write cycles, described below. read cycle timing figure 10 illustrates the scc read cycle timing. all register addresses and /intack are stable throughout the cycle. the timing specification of scc requires that the /ce signal (and address) be stable when /rd is active. figure 9b. i/o address decoder for this board 4.7 k w /csscc (to scc interface logic) /usrram a7 a6 hct10 application note the z180 interfaced with the scc at mhz 6-35 7 write cycle timing figure 11 illustrates the scc write cycle timing. all register addresses and /intack are stable throughout the cycle. the timing specification of the scc requires that the /ce signal (and address) be stable when /rd is active. data is available to the scc before the falling edge of /wr and remains active until /wr goes inactive. figure 10. scc read cycle timing address /intack /ce /rd d7-d0 data valid address valid figure 11. scc write cycle timing address /intack /ce /wr d7-d0 data valid address valid application note the z180 interfaced with the scc at mhz 6-36 (continued) scc interrupt operation understanding scc interrupt operations requires a basic knowledge of the interrupt pending (ip) and interrupt under service (ius) bits in relation to the daisy chain. the z180 and scc design allow no additional interrupt requests during an interrupt acknowledge cycle. this permits the interrupt daisy chain to settle, ensuring proper response of the interrupt device. the ip bit sets in the scc for cpu intervention requirements (that is, buffer empty, character available, error detection, or status changes). the interrupt acknowledge cycle does not reset the ip bit. the ip bit clears by a software command to the scc, or when the action that generated the interrupt ends, for example, reading a receive character for receive interrupt. others are, writing data to the transmitter data register, issuing reset tx interrupt pending command for tx buffer empty interrupt, etc.). after servicing the interrupt, other interrupts can occur. the ius bit means the cpu is servicing an interrupt. the ius bit sets during an interrupt acknowledge cycle if the ip bit sets and the iei line is high. if the iei line is low, the ius bit is not set. this keeps the device from placing its vector onto the data bus. the ius bit clears in the z80 peripherals by decoding the reti instruction. a software command also clears the ius bit in the z80 peripherals. only software commands clear the ius bit in the scc. z80 interrupt daisy-chain operation in the z80 peripherals, both ip and ius bits control the ieo line and the lower portion of the daisy chain. when a peripheral? ip bit sets, the ieo line goes low. this is true regardless of the state of the iei line. additionally, if the peripheral? ius bit clears and its iei line is high, the /int line goes low. the z80 peripherals sample for both /m1 and /iorq active (and /rd inactive) to identify an interrupt acknowledge cycle. when /m1 goes active and /rd is inactive, the peripheral detects an interrupt acknowledge cycle and allows its interrupt daisy chain to settle. when the /iorq line goes active with /m1 active, the highest priority interrupting peripheral places its interrupt vector onto the data bus. the ius bit also sets to show that the peripheral is now under service. as long as the ius bit sets, the ieo line remains low. this inhibits any lower priority devices from requesting an interrupt. when the z180 cpu executes the reti instruction, the peripherals check the data bus and the highest priority device under service resets its ius bit. scc interrupt daisy-chain operation in the scc, the ius bit normally controls the state of the ieo line. the ip bit affects the daisy chain only during an interrupt acknowledge cycle. since the ip bit is normally not part of the scc interrupt daisy chain, there is no need to decode the reti instruction. to allow for control over the daisy chain, the scc has a disable lower chain (dlc) software command that pulls ieo low. this selectively deactivates parts of the daisy chain regardless of the interrupt status. table 6 shows the truth table for the scc interrupt daisy chain control signals during certain cycles. table 12 shows the interrupt state diagram for the scc. table 6. scc daisy chain signal truth table during idle state during intack cycle iei ip ius ieo iei ip ius ieo 0xx00xx0 1x0111x0 1x101x10 1001 application note the z180 interfaced with the scc at mhz 6-37 7 the scc uses /intack (interrupt acknowledge) for recognition of an interrupt acknowledge cycle. this pin, used with /rd, allows the scc to gate its interrupt vector onto the data bus. an active /rd signal during an interrupt acknowledge cycle performs two functions. first, it allows the highest priority device requesting an interrupt to place its vector on the data bus. secondly, it sets the ius bit in the highest priority device to show the device is now under service. figure 12. scc interrupt status diagram ip set int active ius set ip cleared ius cleared interrupt condition return to main program cpu read, write, or reset ieo high? iei high? /intack * iei * /rd wait for cpu /intack cycle application note the z180 interfaced with the scc at mhz 6-38 input/output cycles although the scc is a universal design, certain timing parameters differ from the z180 timing. the following subsections discuss the i/o interface for the z180 mpu and scc. z180 mpu to scc interface table 7 shows key parameters of the 10 mhz scc for i/o read/write cycles. scc i/o read/write cycle assume that the z180 mpu? /ioc bit in the omcr (operation mode control register) clears to 0 (this condition is a z80 compatible timing mode for /iorq and /rd). the following are several design points to consider (also see table 3). i/o read cycle parameters 8 and 9 mean that address is stable 20 ns before the falling edge of /rd and until /rd goes inactive. parameters 19 and 20 mean that /ce is stable at the falling edge of /rd and until /rd goes inactive. parameter 22 means the /rd pulse width is wider than 125 ns. parameters 25 and 27 mean that read data is available on the data bus 120 ns later than the falling edge of /rd and 180 ns from a stable address. i/o write cycle parameters 6 and 7 mean that address is stable 50 ns before the falling edge of /wr and is stable until /wr goes inactive. parameters 16 and 17 mean that /ce is stable at the falling edge of /wr and is stable until /w goes inactive. parameter 28 means /wr pulse width is wider than 125 ns. parameters 28 and 29 mean that write data is on the data bus 10 ns before the falling edge of /wr. it is stable until the rising edge of /wr. tables 8 and 9 show the worst case scc parameters calculating z180 parameters at 10 mhz. table 7. 10 mhz scc timing parameters for i/o read/write cycle (worst case) no symbol parameter min max units 6 tsa(wr) address to /wr low setup 50 ns 7 tha(wr) address to /wr high hold 0 ns 8 tsa(rd) address to /rd low setup 50 ns 9 tha(rd) address to /rd high hold 0 ns 16 tscei(wr) /ce low to /wr low setup 0 ns 17 thce(wr) /ce to /wr high hold 0 ns 19 tscei(rd) /ce low to /rd low setup 0 ns 20 thce(rd) /ce to /rd high hold 0 ns 22 twrdi /rd low width 125 ns 25 tdrdf(dr) /rd low to read data valid 120 ns 27 tda(dr) address to read data valid 180 ns 28 twwri /wr low width 125 ns 29 tsdw(wr) write data to /wr low setup 10 ns 30 tdwr(w) write data to /wr high hold 0 ns application note the z180 interfaced with the scc at mhz 6-39 7 i/o read cycle these tables show that a delay of the falling edge of /rd satisfies the scc tsa(rd) timing requirement of 50 ns min. the z180 calculated value is 30 ns min for the worst case. also, z180 timing specification tah (address hold time) is 10 ns min. the scc timing parameters tha(rd) {address to /rd high hold} and thce(rd) {/ce to /rd high hold} are minimum at 0 ns. the rising edge of /rd is early to guarantee these parameters when considering address decoders and gate propagation delays. i/o write cycle delay the falling edge of /wr to satisfy the scc tsa(/wr) timing requirement of 50 ns min. the z180 calculates 30 ns min worst case. further, the z180 timing specifications tah (address hold time) and twdh (/wr high to data hold time) are both 10 ns min. the scc timing parameters tha(wr) {address to /wr high hold}, thce(wr) {/ce to /wr high hold} and tdwr(w) {write data to /wr high hold} are a minimum of 0 ns. the rising edge of /wr is early to guarantee these parameter requirements. this circuit depicts logic for the i/o interface and the interrupt acknowledge interface for 10 mhz clock of operation. figure 13 is the i/o read/write timing chart (discussions of timing considerations on the interrupt acknowledge cycle and the circuit using epld occur later). table 8. parameter equations worst case (without delay signals - no wait state) scc parameters z180 equation value units tsa(rd) tcyc-tad+trdd1 30 min ns tda(dr) 3tcyc+tchw+tcf-tad-tdrs 245 min ns tdrdf(dr) 2tcyc+tchw+tcf-trdd1-tdrs 160 min ns twrdi 2tcyc+tchw+tcf-tdrs+trdd2 185 min ns tsa(wr) tcyc-tad+twrd1 30 min ns tsdw(wr) twds 15 min ns twwri twrp 210 min ns table 9. parameter equations z180 parameters scc equation value units tdrs address 3tcyc+tchw-tad-tda(dr) 241 min ns rd 2tcyc+tchw-trdd1-tdrd(dr) 184 min ns application note the z180 interfaced with the scc at mhz 6-40 (continued) if you are running your system slower than 8 mhz, remove the hct74, d-flip/flop in front of hct164. connect the inverted csscc to the hct164 b input. this is a required flip/flop because the z180 timing specification on tiod1 (clock high to /iorq low, ioc=0) is maximum at 55 ns this is longer than half the phi clock cycle. sample it using the rising edge of clock, otherwise, hct164 does not generate the same signals. the reset signal feeds the scc /rd and /wr through hct27 and hct02 to supply the hardware reset signal. to reduce the gate count, drop these gates and make the scc reset by its software command. the scc software reset - 0c0h to write register 9, ?ardware reset command?has the same effect as hardware reset by ?ardware. interrupt acknowledge cycle timing the primary timing differences between the z180 and scc occur in the interrupt acknowledge cycle. the scc timing parameters that are significant during interrupt acknowledge cycles are in table 10. the z180 timing parameters are in table 10. the reference numbers in tables 10 and 11 refer to figure 13. figure 13. scc i/o read/write cycle timing this circuit works when [(lower hct164? clk 1 to z180 /wait 1 ) + tws |