Part Number Hot Search : 
C350E 890203 MSP10A01 FLX08 T346005 R2016 AN78N20 S60D4
Product Description
Full Text Search
 

To Download HD6433876NXXXF Datasheet File

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


  Datasheet File OCR Text:
  to all our customers regarding the change of names ment ioned in the document, such as hitachi electric and hitachi xx, to renesas technology corp. the semiconductor operations of mitsubishi electric and hitachi were transferred to renesas technology corporation on april 1st 2003. these operations include microcomput er, logic, analog and discrete devices, and memory chips other than drams (flash memory, srams etc.) accordingly, although hitachi, hitac hi, ltd., hitachi semiconductors, and other hitachi brand names are m entioned in the document, these names have in fact all been changed to renesas technology corp. thank you for your understanding. ex cept for our corporate trademark, logo and corporate statement, no changes whatsoever have been made to the contents of the document, and these changes do not constitute any alteration to the contents of the document itself. renesas technology home page: www.renesas.com renesas technology corp. customer support dept. april 1, 2003 renesas technology corp.
h8/3877n series h8/3877n, h8/3876n, h8/3875n hardware manual
preface the h8/300l series of single-chip microcomputers has a high-speed h8/300l cpu core, with many necessary peripheral system functions on-chip. the h8/300l cpu instruction set is compatible with the h8/300 cpu. on-chip peripheral functions of the h8/3877n series include a high-precision dtmf generator for tone dialing, a multitone generator, three types of timers, two serial communication interface channels, and an a/d converter. this manual describes the hardware of the h8/3877n series. for details on the h8/3877n series instruction set, refer to the h8/300l series programming manual.
contents section 1 overview .......................................................................................................... 1 1.1 overview.................................................................................................................... ..... 1 1.2 internal block diagram .................................................................................................. 5 1.3 pin arrangement and functions ..................................................................................... 6 1.3.1 pin arrangement................................................................................................. 6 1.3.2 pin functions ...................................................................................................... 8 section 2 cpu ................................................................................................................... 13 2.1 overview.................................................................................................................... ..... 13 2.1.1 features............................................................................................................... 13 2.1.2 address space..................................................................................................... 14 2.1.3 register configuration........................................................................................ 14 2.2 register descriptions...................................................................................................... 1 5 2.2.1 general registers................................................................................................ 15 2.2.2 control registers ................................................................................................ 15 2.2.3 initial register values......................................................................................... 17 2.3 data formats................................................................................................................ ... 17 2.3.1 data formats in general registers ..................................................................... 18 2.3.2 memory data formats ........................................................................................ 19 2.4 addressing modes .......................................................................................................... 20 2.4.1 addressing modes .............................................................................................. 20 2.4.2 effective address calculation ............................................................................ 22 2.5 instruction set............................................................................................................. .... 26 2.5.1 data transfer instructions .................................................................................. 28 2.5.2 arithmetic operations ........................................................................................ 30 2.5.3 logic operations ................................................................................................ 31 2.5.4 shift operations .................................................................................................. 31 2.5.5 bit manipulations ............................................................................................... 33 2.5.6 branching instructions........................................................................................ 37 2.5.7 system control instructions ............................................................................... 39 2.5.8 block data transfer instruction ......................................................................... 40 2.6 basic operational timing ............................................................................................... 42 2.6.1 access to on-chip memory (ram, rom) ....................................................... 42 2.6.2 access to on-chip peripheral modules ............................................................. 43 2.7 cpu states .................................................................................................................. .... 45 2.7.1 overview............................................................................................................. 45 2.7.2 program execution state ................................................................................... 46 2.7.3 program halt state.............................................................................................. 46 2.7.4 exception-handling state................................................................................... 46
2.8 memory map .................................................................................................................. 47 2.8.1 memory map ...................................................................................................... 47 2.9 application notes ........................................................................................................... 48 2.9.1 notes on data access ......................................................................................... 48 2.9.2 notes on bit manipulation.................................................................................. 50 2.9.3 notes on use of the eepmov instruction ......................................................... 56 section 3 exception handling ...................................................................................... 57 3.1 overview.................................................................................................................... ..... 57 3.2 reset ....................................................................................................................... ..... 57 3.2.1 overview............................................................................................................. 57 3.2.2 reset sequence ................................................................................................... 57 3.2.3 interrupt immediately after reset....................................................................... 58 3.3 interrupts.................................................................................................................. ....... 59 3.3.1 overview............................................................................................................. 59 3.3.2 interrupt control registers ................................................................................. 61 3.3.3 external interrupts .............................................................................................. 69 3.3.4 internal interrupts ............................................................................................... 70 3.3.5 interrupt operations............................................................................................ 71 3.3.6 interrupt response time..................................................................................... 76 3.4 application notes ........................................................................................................... 77 3.4.1 notes on stack area use .................................................................................... 77 3.4.2 notes on rewriting port mode registers ........................................................... 78 section 4 clock pulse generators ............................................................................... 81 4.1 overview.................................................................................................................... ..... 81 4.1.1 block diagram.................................................................................................... 81 4.1.2 system clock and subclock ............................................................................... 81 4.2 system clock generator ................................................................................................. 82 4.3 subclock generator ........................................................................................................ 85 4.4 prescalers .................................................................................................................. ...... 87 4.5 note on oscillators ......................................................................................................... 88 section 5 power-down modes ..................................................................................... 89 5.1 overview.................................................................................................................... ..... 89 5.1.1 system control registers ................................................................................... 92 5.2 sleep mode .................................................................................................................. ... 95 5.2.1 transition to sleep mode.................................................................................... 95 5.2.2 clearing sleep mode .......................................................................................... 95 5.3 standby mode................................................................................................................ .96 5.3.1 transition to standby mode ............................................................................... 96
5.3.2 clearing standby mode ...................................................................................... 96 5.3.3 oscillator settling time after standby mode is cleared .................................... 97 5.4 watch mode.................................................................................................................. .. 98 5.4.1 transition to watch mode .................................................................................. 98 5.4.2 clearing watch mode ......................................................................................... 98 5.4.3 oscillator settling time after watch mode is cleared ....................................... 98 5.5 subsleep mode............................................................................................................... .99 5.5.1 transition to subsleep mode .............................................................................. 99 5.5.2 clearing subsleep mode..................................................................................... 99 5.6 subactive mode .............................................................................................................. 100 5.6.1 transition to subactive mode ............................................................................. 100 5.6.2 clearing subactive mode.................................................................................... 100 5.6.3 operating frequency in subactive mode ........................................................... 100 5.7 active (medium-speed) mode ........................................................................................ 101 5.7.1 transition to active (medium-speed) mode....................................................... 101 5.7.2 clearing active (medium-speed) mode ............................................................. 101 5.7.3 operating frequency in active (medium-speed) mode ..................................... 101 5.8 direct transfer ............................................................................................................. ... 102 section 6 rom .................................................................................................................. 105 6.1 overview.................................................................................................................... ..... 105 6.1.1 block diagram ................................................................................................... 105 6.2 prom mode................................................................................................................... 106 6.2.1 selection of prom mode .................................................................................. 106 6.2.2 socket adapter pin arrangement and memory map ......................................... 106 6.3 programming ................................................................................................................. . 109 6.3.1 programming and verification............................................................................ 110 6.3.2 programming precautions................................................................................... 114 6.4 reliability of programmed data..................................................................................... 115 section 7 ram ................................................................................................................. 117 7.1 overview.................................................................................................................... ..... 117 7.1.1 block diagram ................................................................................................... 117 section 8 i/o ports ........................................................................................................... 119 8.1 overview .................................................................................................................. .......... 119 8.2 port 1 ...................................................................................................................... ...... 121 8.2.1 overview............................................................................................................. 121 8.2.2 register configuration and description ............................................................. 121 8.2.3 pin functions ...................................................................................................... 125 8.2.4 pin states ............................................................................................................ 126
8.2.5 mos input pull-up............................................................................................. 126 8.3 port 2 ...................................................................................................................... ...... 127 8.3.1 overview............................................................................................................. 127 8.3.2 register configuration and description ............................................................. 127 8.3.3 pin functions ...................................................................................................... 131 8.3.4 pin states ............................................................................................................ 132 8.3.5 mos input pull-up............................................................................................. 133 8.4 port 5 ...................................................................................................................... ...... 134 8.4.1 overview............................................................................................................. 134 8.4.2 register configuration and description ............................................................. 134 8.4.3 pin functions ...................................................................................................... 136 8.4.4 pin states ............................................................................................................ 137 8.4.5 mos input pull-up............................................................................................. 137 8.5 port 6 ...................................................................................................................... ...... 138 8.5.1 overview............................................................................................................. 138 8.5.2 register configuration and description ............................................................. 138 8.5.3 pin functions ...................................................................................................... 140 8.5.4 pin states ............................................................................................................ 140 8.5.5 mos input pull-up............................................................................................. 140 8.6 port 7 ...................................................................................................................... ...... 141 8.6.1 overview............................................................................................................. 141 8.6.2 register configuration and description ............................................................. 141 8.6.3 pin functions ...................................................................................................... 143 8.6.4 pin states ............................................................................................................ 143 8.7 port 8 ...................................................................................................................... ...... 144 8.7.1 overview............................................................................................................. 144 8.7.2 register configuration and description ............................................................. 144 8.7.3 pin functions ...................................................................................................... 146 8.7.4 pin states ............................................................................................................ 146 8.8 port 9 ...................................................................................................................... ...... 147 8.8.1 overview............................................................................................................. 147 8.8.2 register configuration and description ............................................................. 147 8.8.3 pin functions ...................................................................................................... 149 8.8.4 pin states ............................................................................................................ 149 8.9 port a ...................................................................................................................... ...... 150 8.9.1 overview............................................................................................................. 150 8.9.2 register configuration and description ............................................................. 150 8.9.3 pin functions ...................................................................................................... 152 8.9.4 pin states ............................................................................................................ 152 8.10 port b ..................................................................................................................... ....... 153 8.10.1 overview............................................................................................................. 153
8.10.2 register configuration and description ............................................................. 153 8.11 port d ..................................................................................................................... ....... 154 8.11.1 overview............................................................................................................. 154 8.11.2 register configuration and description ............................................................. 154 8.11.3 pin functions ...................................................................................................... 155 8.11.4 pin states ............................................................................................................ 155 8.12 port e ..................................................................................................................... ....... 156 8.12.1 overview............................................................................................................. 156 8.12.2 register configuration and description ............................................................. 156 8.12.3 pin functions ...................................................................................................... 157 8.12.4 pin states ............................................................................................................ 157 section 9 timers ............................................................................................................... 159 9.1 overview.................................................................................................................... ..... 159 9.2 timer a..................................................................................................................... ...... 160 9.2.1 overview............................................................................................................. 160 9.2.2 register descriptions.......................................................................................... 162 9.2.3 timer operation.................................................................................................. 164 9.2.4 timer a operation states ................................................................................... 165 9.3 timer f ..................................................................................................................... ...... 166 9.3.1 overview............................................................................................................. 166 9.3.2 register descriptions.......................................................................................... 168 9.3.3 interface with the cpu ....................................................................................... 175 9.3.4 timer operation.................................................................................................. 179 9.3.5 application notes ............................................................................................... 182 9.4 timer g..................................................................................................................... ...... 184 9.4.1 overview............................................................................................................. 184 9.4.2 register descriptions.......................................................................................... 186 9.4.3 noise canceller circuit....................................................................................... 190 9.4.4 timer operation.................................................................................................. 191 9.4.5 application notes ............................................................................................... 195 9.4.6 sample timer g application.............................................................................. 199 section 10 serial communication interface ............................................................. 201 10.1 overview................................................................................................................... ...... 201 10.2 sci1 ....................................................................................................................... ......... 202 10.2.1 overview........................................................................................................... 202 10.2.2 register descriptions........................................................................................ 204 10.2.3 operation .......................................................................................................... 209 10.2.4 interrupt sources............................................................................................... 213 10.3 sci3 ....................................................................................................................... ......... 214
10.3.1 overview........................................................................................................... 214 10.3.2 register descriptions........................................................................................ 217 10.3.3 operation .......................................................................................................... 235 10.3.4 operation in asynchronous mode.................................................................... 239 10.3.5 operation in synchronous mode ...................................................................... 247 10.3.6 multiprocessor communication function ........................................................ 254 10.3.7 interrupts........................................................................................................... 260 10.3.8 application notes ............................................................................................. 261 section 11 dtmf generator ......................................................................................... 267 11.1 overview................................................................................................................... ...... 267 11.1.1 features............................................................................................................. 268 11.1.2 block diagram.................................................................................................. 269 11.1.3 pin configuration.............................................................................................. 270 11.1.4 register configuration...................................................................................... 270 11.2 register descriptions...................................................................................................... 271 11.2.1 dtmf control register (dtcr) ..................................................................... 271 11.2.2 dtmf load register (dtlr).......................................................................... 273 11.3 operation .................................................................................................................. ...... 274 11.3.1 output waveform.............................................................................................. 274 11.3.2 programming .................................................................................................... 275 11.4 typical use ................................................................................................................ ..... 276 11.5 application notes .......................................................................................................... . 276 section 12 a/d converter .............................................................................................. 277 12.1 overview................................................................................................................... ...... 277 12.1.1 features............................................................................................................. 277 12.1.2 block diagram.................................................................................................. 277 12.1.3 pin configuration.............................................................................................. 278 12.1.4 register configuration...................................................................................... 278 12.2 register descriptions...................................................................................................... 279 12.2.1 a/d result register (adrr) ........................................................................... 279 12.2.2 a/d mode register (amr) .............................................................................. 279 12.2.3 a/d start register (adsr) .............................................................................. 281 12.3 operation .................................................................................................................. ...... 282 12.3.1 a/d conversion operation ............................................................................... 282 12.3.2 start of a/d conversion by external trigger input ......................................... 282 12.4 interrupts................................................................................................................. ........ 283 12.5 typical use ................................................................................................................ ..... 283 12.6 application notes .......................................................................................................... . 286
section 13 multitone generator ................................................................................... 287 13.1 overview................................................................................................................... ...... 287 13.1.1 features............................................................................................................. 287 13.1.2 block diagram.................................................................................................. 288 13.1.3 pin configuration.............................................................................................. 289 13.1.4 register configuration...................................................................................... 289 13.2 register descriptions...................................................................................................... 290 13.2.1 multitone control register (mtcr) ................................................................ 290 13.2.2 effective bit length register (eblr).............................................................. 292 13.2.3 frame register (frmr) ................................................................................... 292 13.2.4 fine-tuning register (ftnr) .......................................................................... 293 13.2.5 initial level register (itlr) ............................................................................ 293 13.3 operation .................................................................................................................. ...... 294 13.3.1 output waveform.............................................................................................. 294 13.3.2 flow of operation............................................................................................. 295 13.4 register settings .......................................................................................................... ... 297 13.4.1 how to calculate register settings .................................................................. 297 13.4.2 typical register settings .................................................................................. 298 13.5 bit pattern setting on mtg ram.................................................................................. 300 13.5.1 bit pattern on mtg ram ................................................................................ 300 13.5.2 typical bit pattern settings .............................................................................. 301 13.5.3 modification of bit patterns ............................................................................. 303 13.6 application notes .......................................................................................................... . 304 section 14 electrical characteristics .......................................................................... 305 14.1 absolute maximum ratings ........................................................................................... 305 14.2 electrical characteristics ................................................................................................ 3 06 14.2.1 power supply voltage and operating range.................................................... 306 14.2.2 dc characteristics ............................................................................................ 308 14.2.3 ac characteristics ............................................................................................ 313 14.2.4 a/d converter characteristics.......................................................................... 316 14.2.5 dtmf and multitone generator characteristics.............................................. 317 14.3 operation timing........................................................................................................... . 319 14.4 output load circuits ...................................................................................................... 3 22 appendix a cpu instruction set .................................................................................. 323 a.1 instructions ................................................................................................................ ..... 323 a.2 operation code map....................................................................................................... 331 a.3 number of execution states ........................................................................................... 333
appendix b on-chip registers ..................................................................................... 340 b.1 i/o registers (1) ........................................................................................................... .. 340 b.2 i/o registers (2) ........................................................................................................... .. 344 appendix c i/o port block diagrams ........................................................................ 381 c.1 port 1 block diagrams.................................................................................................... 381 c.2 port 2 block diagrams.................................................................................................... 386 c.3 port 5 block diagram ..................................................................................................... 394 c.4 port 6 block diagram ..................................................................................................... 395 c.5 port 7 block diagram ..................................................................................................... 396 c.6 port 8 block diagram ..................................................................................................... 397 c.7 port 9 block diagram ..................................................................................................... 398 c.8 port a block diagram .................................................................................................... 399 c.9 port b block diagram .................................................................................................... 400 c.10 port d block diagram .................................................................................................... 401 c.11 port e block diagram..................................................................................................... 40 2 appendix d port states in the different processing states .................................. 403 appendix e package dimensions ................................................................................ 404
section 1 overview 1.1 overview the h8/300l series is a series of single-chip microcomputers (mcu: microcomputer unit), built around the high-speed h8/300l cpu and equipped with peripheral system functions on-chip. within the h8/300l series, the h8/3877n series of single-chip microcomputers features a high- precision dtmf generator for tone dialing, and a multitone generator. other on-chip peripheral functions include three types of timers, two serial communication interface channels, and an a/d converter. the h8/3877n series has three members, the h8/3877n, h8/3876n, and h8/3875n, with different amounts of on-chip memory: the h8/3877n has 60 kbytes of rom and 2 kbytes of ram; the h8/3876n has 48 kbytes of rom and 2 kbytes of ram; the h8/3875n has 40 kbytes of rom and 2 kbytes of ram. the h8/3877n has a ztat version with user-programmable on-chip prom. table 1-1 summarizes the features of the h8/3877n series. note: * ztat is a trademark of hitachi, ltd. table 1-1 features item description cpu high-speed h8/300l cpu general-register architecture general registers: sixteen 8-bit registers (can be used as eight 16-bit registers) operating speed max. operating speed: 5 mhz add/subtract: 0.4 ? (operating at 5 mhz) multiply/divide: 2.8 ? (operating at 5 mhz) can run on 32.768 khz subclock instruction set compatible with h8/300 cpu instruction length of 2 bytes or 4 bytes basic arithmetic operations between registers mov instruction for data transfer between memory and registers 1
table 1-1 features (cont) item description cpu instruction features multiply (8 bits 8 bits) divide (16 bits ? 8 bits) bit accumulator register-indirect designation of bit position interrupts 31 interrupt sources 14 external interrupt sources: nmi, irq 4 to irq 0 , wkp 7 to wkp 0 17 internal interrupt sources clock pulse generators two on-chip clock pulse generators system clock pulse generator: 1 mhz to 10 mhz subclock pulse generator: 32.768 khz power-down modes six power-down modes sleep mode standby mode watch mode subsleep mode subactive mode active (medium-speed) mode memory large on-chip memory h8/3877n: 60-kbyte rom, 2-kbyte ram h8/3876n: 48-kbyte rom, 2-kbyte ram h8/3875n: 40-kbyte rom, 2-kbyte ram i/o ports 80 i/o ports i/o pins: 72 input pins: 8 2
table 1-1 features (cont) item description timers three on-chip timers timer a: 8-bit timer count-up timer with selection of eight internal clock signals divided from the system clock (? * and four clock signals divided from the watch clock ( w ) * timer f: 16-bit timer can be used as two independent 8-bit timers. count-up timer with selection of four internal clock signals or event input from external pin compare-match function with toggle output timer g: 8-bit timer count-up timer with selection of four internal clock signals input capture function with built-in noise canceller circuit note: * ?and w are defined in section 4, clock pulse generators. two channels on chip sci1: synchronous serial interface choice of 8-bit or 16-bit data transfer sci3: 8-bit synchronous or asynchronous serial interface built-in function for multiprocessor communication a/d converter successive approximations using a resistance ladder resolution: 8 bits 8-channel analog input port conversion time: 31/, 62/?or 124/?per channel serial communication interface 3
table 1-1 features (cont) item description dtmf generator built-in tone dialer supporting osc clock frequencies from 1.2 mhz to 10 mhz in 400-khz steps multitone generator can output arbitrary frequencies and waveforms in a wide range (40 hz to 4000 hz when osc clock frequency is 10 mhz) product lineup product code mask rom ztat ? version version package rom/ram size hd6433877nh hd6473877nh 100 pin qfp rom: 60 kbytes (fp-100b) ram: 2 kbytes hd6433877nf hd6473877nf 100 pin qfp (fp-100a) hd6433877nx hd6473877nx 100 pin tqfp (tfp-100b) hd6433876nh 100 pin qfp rom: 48 kbytes (fp-100b) ram: 2 kbytes hd6433876nf 100 pin qfp (fp-100a) hd6433876nx 100 pin tqfp (tfp-100b) hd6433875nh 100 pin qfp rom: 40 kbytes (fp-100b) ram: 2 kbytes hd6433875nf 100 pin qfp (fp-100a) hd6433875nx 100 pin tqfp (tfp-100b) 4
1.2 internal block diagram figure 1-1 shows a block diagram of the h8/3877n series. figure 1-1 block diagram p1 0 /tmow p1 1 /tmofl p1 2 /tmofh p1 3 /tmig p1 4 p1 5 /irq 1 p1 6 /irq 2 7 /irq 3 /tmif p2 0 /irq 4 /adtrg p2 1 /sck 1 p2 7 /irq 0 p2 6 /txd p2 5 /rxd p2 4 /sck 3 p2 3 /so 1 p2 2 /si 1 p5 0 /wkp p5 1 /wkp p5 2 /wkp p5 3 /wkp p5 4 /wkp p5 5 /wkp p5 6 /wkp p5 7 /wkp pa 3 pa 2 pa 1 pa 0 p9 7 p9 6 p9 5 p9 4 p9 3 p9 2 p9 1 p9 0 p8 7 p8 6 p8 5 p8 4 p8 3 p8 2 p8 1 p8 0 p6 0 p6 1 p6 2 p6 3 p6 4 p6 5 p6 6 p6 7 v ss v ss v cc v cc res test nmi av cc av ss pb 0 /an 0 pb 1 /an 1 pb 2 /an 2 pb 3 /an 3 pb 4 /an 4 pb 5 /an 5 pb 6 /an 6 pb 7 /an 7 vt ref toned p1 port a port e port d port 9 port 8 port 7 port 5 rom (60 k/40 k/ 48 kbytes) ram (2 kbytes) timer a timer f timer g sci1 sci3 dtmf generator a/d converter cpu h8/300l 0 1 2 3 4 5 6 7 port b address bus data bus (upper) port 1 port 2 p7 0 p7 1 p7 2 p7 3 p7 4 p7 5 p7 6 p7 7 tonem av ref multitone generator osc 1 osc 2 x 1 x 2 system clock pulse generator subclock pulse generator pe 3 pe 2 pe 1 pe 0 pd 7 pd 6 pd 5 pd 4 pd 3 pd 2 pd 1 pd 0 port 6 data bus (lower) 5
1.3 pin arrangement and functions 1.3.1 pin arrangement the h8/3877n series pin arrangement is shown in figure 1-2 and 1-3. figure 1-2 pin arrangement (fp-100b: top view) pb 0 /an 0 av ss test x 2 x 1 v ss osc 1 osc 2 res nmi p2 0 /irq 4 /adtrg p2 1 /sck p1 6 /irq 2 p1 4 p1 3 /tmig p1 2 /tmofh p1 1 /tmofl p9 7 p9 6 p9 5 p9 4 p9 3 p9 2 p9 1 p9 0 p8 7 p8 6 p8 5 p8 4 p8 3 p8 2 p8 1 p8 0 p7 7 p7 6 p7 5 p7 4 p7 3 p7 2 p7 1 p7 0 p6 7 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 pb 1 /an 1 pb 2 /an 2 pb 3 /an 3 pb 4 /an 4 pb 5 /an 5 pb 6 /an 6 pb 7 /an 7 av ref vt ref toned tonem av cc pe 3 pe 2 pe 1 pe 0 pd 7 pd 6 pd 5 pd 4 pd 3 pd 2 pd 1 pd 0 v cc p1 0 /tmow v ss nc v cc pa 3 pa 2 pa 1 pa 0 p6 0 p6 1 p6 2 p6 3 p6 4 p6 5 p6 6 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 1 p2 2 /si 1 p2 3 /so 1 p2 4 /sck 3 p2 5 /rxd p2 6 /txd p1 7 /irq 3 /tmif p1 5 /irq 1 p2 7 /irq 0 p5 0 /wkp p5 1 /wkp p5 2 /wkp p5 3 /wkp p5 4 /wkp p5 5 /wkp p5 6 /wkp p5 7 /wkp 0 1 2 3 4 5 6 7 nc nc 6
figure 1-3 pin arrangement (fp-100a: top view) 7 pb 3 /an 3 pb 2 /an 2 pb 1 /an 1 pb 0 /an 0 av ss test x 2 x 1 v ss osc 1 osc 2 res nmi p2 0 /irq 4 /adtrg p2 1 /sck p1 6 /irq 2 p1 4 p1 3 /tmig p1 2 /tmofh p1 1 /tmofl p1 0 v ss /tmow p9 7 p9 6 p9 5 p9 4 p9 3 p9 2 p9 1 p9 0 p8 7 p8 6 p8 5 p8 4 p8 3 p8 2 p8 1 p8 0 p7 7 p7 6 p7 5 p7 4 p7 3 p7 2 p7 1 p7 0 p6 7 p6 6 p6 5 p6 4 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 pb 4 /an 4 pb 5 /an 5 pb 6 /an 6 pb 7 /an 7 av ref vt ref toned tonem av cc pe 3 pe 2 pe 1 pe 0 pd 7 pd 6 pd 5 pd 4 pd 3 pd 2 pd 1 pd 0 v cc nc nc nc v cc pa 3 pa 2 pa 1 pa 0 p5 0 /wkp p5 1 /wkp p5 2 /wkp p5 3 /wkp p5 4 /wkp p5 5 /wkp p5 6 /wkp p5 7 /wkp p6 6 p6 1 p6 2 p6 3 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 0 1 2 3 4 5 6 7 1 p2 2 /si 1 p2 3 /so 1 p2 4 /sck 3 p2 5 /rxd p2 6 /txd p1 7 /irq 3 /tmif p1 5 /irq 1 p2 7 /irq 0
1.3.2 pin functions table 1-2 outlines the pin functions. table 1-2 pin functions pin no. fp-100b type symbol tfp-100b fp-100a i/o name and functions v cc 31, 76 34, 79 input power supply: all v cc pins should be connected to the system power supply (+5 v) v ss 6, 27 9, 30 input ground: all v ss pins should be connected to the system power supply (0 v) av cc 89 92 input analog power supply: this is the power supply pin for the a/d converter. when the a/d converter is not used, connect this pin to the system power supply (+5 v). av ss 2 5 input analog ground: this is the a/d converter ground pin. it should be connected to the system power supply (0 v). av ref 93 96 input a/d converter reference level: this is a power supply pin for the reference level for a/d converter output. when the a/d converter is not used, connect this pin to the system power supply (+5 v). vt ref 92 95 input dtmf and multitone generator reference level: this is a power supply pin for the reference level for dtmf and multitone output. power source pins 8
table 1-2 pin functions (cont) pin no. fp-100b type symbol tfp-100b fp-100a i/o name and functions system clock: these pins connect to a crystal or ceramic oscillator, or can be used to input an external clock. see section 4, clock pulse generators, for a typical connection diagram. subclock: these pins connect to a 32.768-khz crystal oscillator. see section 4, clock pulse generators, for a typical connection diagram. system res 9 12 input reset: when this pin is driven low, the chip control is reset test 3 6 input test: this is a test pin, not for use in applica-tion systems. it should be connected to v ss . interrupt nmi 10 13 input nonmaskable interrupt: this is an input pin pins for the nonmaskable interrupt. rising or falling edge sensing can be selected. irq 0 18 21 input external interrupt request 0 to 4: these irq 1 21 24 are input pins for external interrupts for irq 2 20 23 which there is a choice between rising and irq 3 19 22 falling edge sensing irq 4 11 14 wkp 7 to 43 to 36 46 to 39 input wakeup interrupt request 0 to 7: these wkp 0 are input pins for external interrupts that are detected at the falling edge timer tmow 26 29 output clock output: this is an output pin for pins wave-forms generated by the timer a output circuit tmif 19 22 input timer f event counter input: this is an event input pin for input to the timer f counter tmofl 25 28 output timer fl output: this is an output pin for waveforms generated by the timer fl output compare function tmofh 24 27 output timer fh output: this is an output pin for waveforms generated by the timer fh output compare function tmig 23 26 input timer g capture input: this is an input pin for the timer g input capture function x 1 5 8 input x 2 4 7 output clock osc 1 7 10 input pins osc 2 8 11 output 9
table 1-2 pin functions (cont) pin no. fp-100b type symbol tfp-100b fp-100a i/o name and functions i/o ports pb 7 to 94 to 100, 97 to 100 input port b: this is an 8-bit input port pb 0 1 1 to 4 pa 3 to 32 to 35 35 to 38 i/o port a: this is a 4-bit i/o port. input or pa 0 output can be designated for each bit by means of port control register a (pcra). pd 7 to 84 to 77 87 to 80 i/o port d: this is an 8-bit i/o port. input or pd 0 output can be designated for each bit by means of port control register d (pcrd). pe 3 to 88 to 85 91 to 88 i/o port e: this is a 4-bit i/o port. input or pe 0 output can be designated for each bit by means of port control register e (pcre). p1 7 to 19 to 26 22 to 29 i/o port 1: this is an 8-bit i/o port. input or p1 0 output can be designated for each bit be means of port control register 1 (pcr1). p2 7 to 18 to 11 21 to 14 i/o port 2: this is an 8-bit i/o port. input or p2 0 output can be designated for each bit by means of port control register 2 (pcr2). p5 7 to 43 to 36 46 to 39 i/o port 5: this is an 8-bit i/o port. input or p5 0 output can be designated for each bit by means of port control register 5 (pcr5). p6 7 to 51 to 44 54 to 47 i/o port 6: this is an 8-bit i/o port. input or p6 0 output can be designated for each bit by means of port control register 6 (pcr6). p7 7 to 59 to 52 62 to 55 i/o port 7: this is an 8-bit i/o port. input or p7 0 output can be designated for each bit by means of port control register 7 (pcr7). p8 7 to 67 to 60 70 to 63 i/o port 8: this is an 8-bit i/o port. input or p8 0 output can be designated for each bit by means of port control register 8 (pcr8). p9 7 to 75 to 68 78 to 71 i/o port 9: this is an 8-bit i/o port. input or p9 0 output can be designated for each bit by means of port control register 9 (pcr9). si 1 13 16 input sci1 receive data input: this is the sci1 data input pin so 1 14 17 output sci1 send data output: this is the sci1 data output pin sck 1 12 15 i/o sci1 clock i/o : this is the sci1 clock i/o pin serial communi- cation interface (sci) 10
table 1-2 pin functions (cont) pin no. fp-100b type symbol tfp-100b fp-100a i/o name and functions rxd 16 19 input sci3 receive data input: this is the sci3 data input pin txd 17 20 output sci3 send data output: this is the sci3 data output pin sck 3 15 18 i/o sci3 clock i/o: this is the sci3 clock i/o pin a/d an 7 to 94 to 100, 97 to 100 input analog input channels 0 to 7: converter an 0 1 1 to 4 these are analog data input channels to the a/d converter adtrg 11 14 input a/d converter trigger input: this is the external trigger input pin to the a/d converter dtmf toned 91 94 output dtmf signal: this is the output pin for the generator dtmf signal multitone tonem 90 93 output multitone signal: this is the output pin for generator the multitone signal others nc 28 to 30 31 to 33 no connection: do not connect to this pin serial communi- cation interface (sci) 11
section 2 cpu 2.1 overview the h8/300l cpu has sixteen 8-bit general registers, which can also be paired as eight 16-bit registers. its concise, optimized instruction set is designed for high-speed operation. 2.1.1 features features of the h8/300l cpu are listed below. general-register architecture sixteen 8-bit general registers, also usable as eight 16-bit general registers instruction set with 55 basic instructions, including: multiply and divide instructions powerful bit-manipulation instructions eight addressing modes register direct register indirect register indirect with displacement register indirect with post-increment or pre-decrement absolute address immediate program-counter relative memory indirect 64-kbyte address space high-speed operation all frequently used instructions are executed in two to four states high-speed arithmetic and logic operations 8- or 16-bit register-register add or subtract: 0.4 ?* 8 8-bit multiply: 2.8 ?* 16 8-bit divide: 2.8 ?* low-power operation modes sleep instruction for transition to low-power operation note: * these values are at ?= 5 mhz. 13
2.1.2 address space the h8/300l cpu supports an address space of up to 64 kbytes for storing program code and data. see 2.8, memory map, for details of the memory map. 2.1.3 register configuration figure 2-1 shows the register structure of the h8/300l cpu. there are two groups of registers: the general registers and control registers. figure 2-1 cpu registers 7070 15 0 pc r0h r1h r2h r3h r4h r5h r6h r7h r0l r1l r2l r3l r4l r5l r6l r7l (sp) sp: stack pointer pc: program counter ccr: condition code register carry flag overflow flag zero flag negative flag half-carry flag interrupt mask bit user bit user bit ccr i u h u n z v c general registers (rn) control registers (cr) 753210 64 14
2.2 register descriptions 2.2.1 general registers all the general registers can be used as both data registers and address registers. when used as data registers, they can be accessed as 16-bit registers (r0 to r7), or the high bytes (r0h to r7h) and low bytes (r0l to r7l) can be accessed separately as 8-bit registers. when used as address registers, the general registers are accessed as 16-bit registers (r0 to r7). r7 also functions as the stack pointer (sp), used implicitly by hardware in exception handling and subroutine calls. when it functions as the stack pointer, as indicated in figure 2-2, sp (r7) points to the top of the stack. figure 2-2 stack pointer 2.2.2 control registers the cpu control registers include a 16-bit program counter (pc) and an 8-bit condition code register (ccr). program counter (pc): this 16-bit register indicates the address of the next instruction the cpu will execute. all instructions are fetched 16 bits (1 word) at a time, so the least significant bit of the pc is ignored (always regarded as 0). lower address side [h'0000] upper address side [h'ffff] unused area stack area sp (r7) 15
condition code register (ccr): this 8-bit register contains internal status information, including the interrupt mask bit (i) and half-carry (h), negative (n), zero (z), overflow (v), and carry (c) flags. these bits can be read and written by software (using the ldc, stc, andc, orc, and xorc instructions). the n, z, v, and c flags are used as branching conditions for conditional branching (bcc) instructions. bit 7?nterrupt mask bit (i): when this bit is set to 1, interrupts are masked. this bit is set to 1 automatically at the start of exception handling. the interrupt mask bit may be read and written by software. for further details, see section 3, interrupts. bit 6?ser bit (u): can be used freely by the user. bit 5?alf-carry flag (h): when the add.b, addx.b, sub.b, subx.b, cmp.b, or neg.b instruction is executed, this flag is set to 1 if there is a carry or borrow at bit 3, and is cleared to 0 otherwise. the h flag is used implicitly by the daa and das instructions. when the add.w, sub.w, or cmp.w instruction is executed, the h flag is set to 1 if there is a carry or borrow at bit 11, and is cleared to 0 otherwise. bit 4?ser bit (u): can be used freely by the user. bit 3?egative flag (n): indicates the most significant bit (sign bit) of the result of an instruction. bit 2?ero flag (z): set to 1 to indicate a zero result, and cleared to 0 to indicate a non-zero result. bit 1?verflow flag (v): set to 1 when an arithmetic overflow occurs, and cleared to 0 at other times. bit 0?arry flag (c): set to 1 when a carry occurs, and cleared to 0 otherwise. used by: add instructions, to indicate a carry subtract instructions, to indicate a borrow shift and rotate instructions, to store the value shifted out of the end bit the carry flag is also used as a bit accumulator by bit manipulation instructions. some instructions leave some or all of the flag bits unchanged. refer to the h8/300l series programming manual for the action of each instruction on the flag bits. 16
2.2.3 initial register values when the cpu is reset, the program counter (pc) is initialized to the value stored at address h'0000 in the vector table, and the i bit in the ccr is set to 1. the other ccr bits and the general registers are not initialized. in particular, the stack pointer (r7) is not initialized. to prevent program crashes the stack pointer should be initialized by software, by the first instruction executed after a reset. 2.3 data formats the h8/300l cpu can process 1-bit data, 4-bit (bcd) data, 8-bit (byte) data, and 16-bit (word) data. bit manipulation instructions operate on 1-bit data specified as bit n in a byte operand (n = 0, 1, 2, ..., 7). all arithmetic and logic instructions except adds and subs can operate on byte data. the mov.w, add.w, sub.w, cmp.w, adds, subs, mulxu (8 bits 8 bits), and divxu (16 bits 8 bits) instructions operate on word data. the daa and das instructions perform decimal arithmetic adjustments on byte data in two- digit 4-bit bcd form. 17
2.3.1 data formats in general registers data of all the sizes above can be stored in general registers as shown in figure 2-3. figure 2-3 register data formats 76543210 don? care data type register no. data format 70 1-bit data rnh 76543210 don? care 70 1-bit data rnl msb lsb don? care 70 byte data rnh byte data rnl word data rn 4-bit bcd data rnh 4-bit bcd data rnl notation: rnh: rnl: msb: lsb: upper byte of general register lower byte of general register most significant bit least significant bit msb lsb don? care 70 msb lsb 15 0 upper digit lower digit don? care 70 3 4 don? care upper digit lower digit 70 3 4 18
2.3.2 memory data formats figure 2-4 indicates the data formats in memory. for access by the h8/300l cpu, word data stored in memory must always begin at an even address. in word access the least significant bit of the address is regarded as 0. if an odd address is specified, the access is performed at the preceding even address. this rule affects the mov.w instruction, and also applies to instruction fetching. figure 2-4 memory data formats when the stack is accessed using r7 as an address register, word access should always be performed. when the ccr is pushed on the stack, two identical copies of the ccr are pushed to make a complete word. when they are restored, the lower byte is ignored. data format 76543210 address data type 70 address n msb lsb msb lsb upper 8 bits lower 8 bits msb lsb ccr ccr * msb lsb msb lsb address n even address odd address even address odd address even address odd address 1-bit data byte data word data byte data (ccr) on stack word data on stack ccr: condition code register note: ignored on return * 19
2.4 addressing modes 2.4.1 addressing modes the h8/300l cpu supports the eight addressing modes listed in table 2-1. each instruction uses a subset of these addressing modes. table 2-1 addressing modes no. address modes symbol 1 register direct rn 2 register indirect @rn 3 register indirect with displacement @(d:16, rn) 4 register indirect with post-increment @rn+ register indirect with pre-decrement @?n 5 absolute address @aa:8 or @aa:16 6 immediate #xx:8 or #xx:16 7 program-counter relative @(d:8, pc) 8 memory indirect @@aa:8 1. register direct?n: the register field of the instruction specifies an 8- or 16-bit general register containing the operand. only the mov.w, add.w, sub.w, cmp.w, adds, subs, mulxu (8 bits 8 bits), and divxu (16 bits 8 bits) instructions have 16-bit operands. 2. register indirect?rn: the register field of the instruction specifies a 16-bit general register containing the address of the operand in memory. 3. register indirect with displacement?(d:16, rn): the instruction has a second word (bytes 3 and 4) containing a displacement which is added to the contents of the specified general register to obtain the operand address in memory. this mode is used only in mov instructions. for the mov.w instruction, the resulting address must be even. 20
4. register indirect with post-increment or pre-decrement?rn+ or @?n: register indirect with post-increment?rn+ the @rn+ mode is used with mov instructions that load registers from memory. the register field of the instruction specifies a 16-bit general register containing the address of the operand. after the operand is accessed, the register is incremented by 1 for mov.b or 2 for mov.w. for mov.w, the original contents of the 16-bit general register must be even. register indirect with pre-decrement??n the @?n mode is used with mov instructions that store register contents to memory. the register field of the instruction specifies a 16-bit general register which is decremented by 1 or 2 to obtain the address of the operand in memory. the register retains the decremented value. the size of the decrement is 1 for mov.b or 2 for mov.w. for mov.w, the original contents of the register must be even. 5. absolute address?aa:8 or @aa:16: the instruction specifies the absolute address of the operand in memory. the absolute address may be 8 bits long (@aa:8) or 16 bits long (@aa:16). the mov.b and bit manipulation instructions can use 8-bit absolute addresses. the mov.b, mov.w, jmp, and jsr instructions can use 16-bit absolute addresses. for an 8-bit absolute address, the upper 8 bits are assumed to be 1 (h'ff). the address range is h'ff00 to h'ffff (65280 to 65535). 6. immediate?xx:8 or #xx:16: the instruction contains an 8-bit operand (#xx:8) in its second byte, or a 16-bit operand (#xx:16) in its third and fourth bytes. only mov.w instructions can contain 16-bit immediate values. the adds and subs instructions implicitly contain the value 1 or 2 as immediate data. some bit manipulation instructions contain 3-bit immediate data in the second or fourth byte of the instruction, specifying a bit number. 7. program-counter relative?(d:8, pc): this mode is used in the bcc and bsr instructions. an 8-bit displacement in byte 2 of the instruction code is sign-extended to 16 bits and added to the program counter contents to generate a branch destination address. the possible branching range is ?26 to +128 bytes (?3 to +64 words) from the current address. the result of the addition should be an even number. 21
8. memory indirect?@aa:8: this mode can be used by the jmp and jsr instructions. the second byte of the instruction code specifies an 8-bit absolute address. the word located at this address contains the branch destination address. the upper 8 bits of the absolute address are assumed to be 0 (h'00), so the address range is h'0000 to h'00ff (0 to 255). note that with the h8/300l series, the lower end of the address area is also used as a vector area. see 3.3, interrupts, for details on the vector area. if an odd address is specified as a branch destination or as the operand address of a mov.w instruction, the least significant bit is regarded as 0, causing word access to be performed at the address preceding the specified address. see 2.3.2, memory data formats, for further information. 2.4.2 effective address calculation table 2-2 shows how effective addresses are calculated in each of the addressing modes. arithmetic and logic instructions use register direct addressing (1). the add.b, addx, subx, cmp.b, and, or, and xor instructions can also use immediate addressing (6). data transfer instructions can use all addressing modes except program-counter relative (7) and memory indirect (8). bit manipulation instructions use register direct (1), register indirect (2), or absolute addressing (5) to specify a byte operand, and 3-bit immediate addressing (6) to specify a bit position in that byte. the bset, bclr, bnot, and btst instructions can also use register direct addressing (1) to specify the bit position. 22
table 2-2 effective address calculation addressing mode and instruction format op rm 76 3 40 15 no. effective address calculation method effective address (ea) 1 register direct, rn operand is contents of registers indicated by rm/rn register indirect, @rn contents (16 bits) of register indicated by rm 0 15 register indirect with displacement, @(d:16, rn) op rm rn 87 3 40 15 op rm 76 3 40 15 disp op rm 76 3 40 15 register indirect with post-increment, @rn+ op rm 76 3 40 15 register indirect with pre-decrement, @ern 2 3 4 incremented or decremented by 1 if operand is byte size, and by 2 if word size 0 15 disp 0 15 0 15 0 15 1 or 2 0 15 0 15 1 or 2 0 15 rm 30 rn 30 contents (16 bits) of register indicated by rm contents (16 bits) of register indicated by rm contents (16 bits) of register indicated by rm 23
table 2-2 effective address calculation (cont) addressing mode and instruction format no. effective address calculation method effective address (ea) 5 absolute address @aa:8 operand is 1- or 2-byte immediate data @aa:16 op 87 0 15 op 0 15 imm op disp 70 15 program-counter relative @(d:8, pc) 6 7 0 15 pc contents 0 15 0 15 abs h'ff 87 0 15 0 15 abs op #xx:16 op 87 0 15 imm immediate #xx:8 8 sign extension disp 24
table 2-2 effective address calculation (cont) addressing mode and instruction format no. effective address calculation method effective address (ea) 8 memory indirect, @@aa:8 op 87 0 15 memory contents (16 bits) 0 15 abs h'00 87 0 15 notation: rm, rn: op: disp: imm: abs: register field operation field displacement immediate data absolute address abs 25
2.5 instruction set the h8/300l series can use a total of 55 instructions, which are grouped by function in table 2-3. table 2-3 instruction set function instructions number data transfer mov, push * 1 , pop * 1 1 arithmetic operations add, sub, addx, subx, inc, dec, adds, 14 subs, daa, das, mulxu, divxu, cmp, neg logic operations and, or, xor, not 4 shift shal, shar, shll, shlr, rotl, rotr, 8 rotxl, rotxr bit manipulation bset, bclr, bnot, btst, band, biand, bor, 14 bior, bxor, bixor, bld, bild, bst, bist branch bcc *2 , jmp, bsr, jsr, rts 5 system control rte, sleep, ldc, stc, andc, orc, xorc, nop 8 block data transfer eepmov 1 total: 55 notes: 1. push rn is equivalent to mov.w rn, @?p. pop rn is equivalent to mov.w @sp+, rn. 2. bcc is a conditional branch instruction in which cc represents a condition code. the following sections give a concise summary of the instructions in each category, and indicate the bit patterns of their object code. the notation used is defined next. 26
notation rd general register (destination) rs general register (source) rn general register (ead), destination operand (eas), source operand ccr condition code register n n (negative) flag of ccr z z (zero) flag of ccr v v (overflow) flag of ccr c c (carry) flag of ccr pc program counter sp stack pointer #imm immediate data disp displacement + addition subtraction multiplication ? division and logical or logical ? exclusive or logical ? move ~ logical negation (logical complement) :3 3-bit length :8 8-bit length :16 16-bit length ( ), < > contents of operand indicated by effective address 27
2.5.1 data transfer instructions table 2-4 describes the data transfer instructions. figure 2-5 shows their object code formats. table 2-4 data transfer instructions instruction size * function mov b/w (eas) ? rd, rs ? (ead) moves data between two general registers or between a general register and memory, or moves immediate data to a general register. the rn, @rn, @(d:16, rn), @aa:16, #xx:16, @?n, and @rn+ addressing modes are available for byte or word data. the @aa:8 addressing mode is available for byte data only. the @?7 and @r7+ modes require word operands. do not specify byte size for these two modes. pop w @sp+ ? rn pops a 16-bit general register from the stack. equivalent to mov.w @sp+, rn. push w rn ? @?p pushes a 16-bit general register onto the stack. equivalent to mov.w rn, @?p. notes: * size: operand size b: byte w: word certain precautions are required in data access. see 2.9.1, notes on data access, for details. 28
figure 2-5 data transfer instruction codes 15 0 87 op rm rn mov rm ? rn 15 0 87 op rm rn @rm ?? rn 15 0 87 op rm rn @(d:16, rm) ?? rn disp 15 0 87 op rm rn @rm+ ? rn, or rn ? @erm 15 0 87 op rn abs @aa:8 ?? rn 15 0 87 op rn @aa:16 ?? rn abs 15 0 87 op rn imm #xx:8 ? rn 15 0 87 op rn #xx:16 ? rn imm 15 0 87 op rn push, pop notation: op: rm, rn: disp: abs: imm: operation field register field displacement absolute address immediate data @sp+ rn, or rn @esp ? ? 111 29
2.5.2 arithmetic operations table 2-5 describes the arithmetic instructions. table 2-5 arithmetic instructions instruction size * function add b/w rd rs ? rd, rd + #imm ? rd sub performs addition or subtraction on data in two general registers, or addition on immediate data and data in a general register. immediate data cannot be subtracted from data in a general register. word data can be added or subtracted only when both words are in general registers. addx b rd rs c ? rd, rd #imm c ? rd subx performs addition or subtraction with carry or borrow on byte data in two general registers, or addition or subtraction on immediate data and data in a general register. inc b rd 1 ? rd dec increments or decrements a general register adds w rd 1 ? rd, rd 2 ? rd subs adds or subtracts immediate data to or from data in a general register. the immediate data must be 1 or 2. daa b rd decimal adjust ? rd das decimal-adjusts (adjusts to packed bcd) an addition or subtraction result in a general register by referring to the ccr mulxu b rd rs ? rd performs 8-bit 8-bit unsigned multiplication on data in two general registers, providing a 16-bit result divxu b rd rs ? rd performs 16-bit 8-bit unsigned division on data in two general registers, providing an 8-bit quotient and 8-bit remainder cmp b/w rd ?rs, rd ?#imm compares data in a general register with data in another general register or with immediate data, and the result is stored in the ccr. word data can be compared only between two general registers. neg b 0 ?rd ? rd obtains the twos complement (arithmetic complement) of data in a general register notes: * size: operand size b: byte w: word 30
2.5.3 logic operations table 2-6 describes the four instructions that perform logic operations. table 2-6 logic operation instructions instruction size * function and b rd rs ? rd, rd #imm ? rd performs a logical and operation on a general register and another general register or immediate data or b rd rs ? rd, rd #imm ? rd performs a logical or operation on a general register and another general register or immediate data xor b rd ? rs ? rd, rd ? #imm ? rd performs a logical exclusive or operation on a general register and another general register or immediate data not b ~ rd ? rd obtains the ones complement (logical complement) of general register contents notes: * size: operand size b: byte 2.5.4 shift operations table 2-7 describes the eight shift instructions. table 2-7 shift instructions instruction size * function b rd shift ? rd performs an arithmetic shift operation on general register contents b rd shift ? rd performs a logical shift operation on general register contents b rd rotate ? rd rotates general register contents b rd rotate through carry ? rd rotates general register contents through the c (carry) bit notes: * size: operand size b: byte shal shar shll shlr rotl rotr rotxl rotxr 31
figure 2-6 shows the instruction code format of arithmetic, logic, and shift instructions. figure 2-6 arithmetic, logic, and shift instruction codes 15 0 87 op rm rn add, sub, cmp, addx, subx (rm) notation: op: rm, rn: imm: operation field register field immediate data 15 0 87 op rn adds, subs, inc, dec, daa, das, neg, not 15 0 87 op rn mulxu, divxu rm 15 0 87 rn imm add, addx, subx, cmp (#xx:8) op 15 0 87 op rn and, or, xor (rm) rm 15 0 87 rn imm and, or, xor (#xx:8) op 15 0 87 rn shal, shar, shll, shlr, rotl, rotr, rotxl, rotxr op 32
2.5.5 bit manipulations table 2-8 describes the bit-manipulation instructions. figure 2-7 shows their object code formats. table 2-8 bit-manipulation instructions instruction size * function bset b 1 ? ( of ) sets a specified bit in a general register or memory to 1. the bit number is specified by 3-bit immediate data or the lower three bits of a general register. bclr b 0 ? ( of ) clears a specified bit in a general register or memory to 0. the bit number is specified by 3-bit immediate data or the lower three bits of a general register. bnot b ~ ( of ) ? ( of ) inverts a specified bit in a general register or memory. the bit number is specified by 3-bit immediate data or the lower three bits of a general register. btst b ~ ( of ) ? z tests a specified bit in a general register or memory and sets or clears the z flag accordingly. the bit number is specified by 3-bit immediate data or the lower three bits of a general register. band b c ( of ) ? c ands the c flag with a specified bit in a general register or memory, and stores the result in the c flag. biand b c [~ ( of )] ? c ands the c flag with the inverse of a specified bit in a general register or memory, and stores the result in the c flag. the bit number is specified by 3-bit immediate data. bor b c ( of ) ? c ors the c flag with a specified bit in a general register or memory, and stores the result in the c flag. bior b c [~ ( of )] ? c ors the c flag with the inverse of a specified bit in a general register or memory, and stores the result in the c flag. the bit number is specified by 3-bit immediate data. notes: * size: operand size b: byte 33
table 2-8 bit-manipulation instructions (cont) instruction size * function bxor b c ? ( of ) ? c xors the c flag with a specified bit in a general register or memory, and stores the result in the c flag. bixor b c ? [~( of )] ? c xors the c flag with the inverse of a specified bit in a general register or memory, and stores the result in the c flag. the bit number is specified by 3-bit immediate data. bld b ( of ) ? c copies a specified bit in a general register or memory to the c flag. bild b ~ ( of ) ? c copies the inverse of a specified bit in a general register or memory to the c flag. the bit number is specified by 3-bit immediate data. bst b c ? ( of ) copies the c flag to a specified bit in a general register or memory. bist b ~ c ? ( of ) copies the inverse of the c flag to a specified bit in a general register or memory. the bit number is specified by 3-bit immediate data. notes: * size: operand size b: byte certain precautions are required in bit manipulation. see 2.9.2, notes on bit manipulation, for details. 34
figure 2-7 bit manipulation instruction codes 15 0 87 op imm rn operand: bit no.: notation: op: rm, rn: abs: imm: operation field register field absolute address immediate data 15 0 87 op rn bset, bclr, bnot, btst register direct (rn) immediate (#xx:3) operand: bit no.: register direct (rn) register direct (rm) rm 15 0 87 op 0 operand: bit no.: register indirect (@rn) immediate (#xx:3) rn 0 0 0 0 0 0 0 imm 15 0 87 op 0 operand: bit no.: register indirect (@rn) register direct (rm) rn 0 0 0 0 0 0 0 rm op 15 0 87 op operand: bit no.: absolute (@aa:8) immediate (#xx:3) abs 0000 imm op op 15 0 87 op operand: bit no.: absolute (@aa:8) register direct (rm) abs 0000 rm op 15 0 87 op imm rn operand: bit no.: register direct (rn) immediate (#xx:3) band, bor, bxor, bld, bst 15 0 87 op 0 operand: bit no.: register indirect (@rn) immediate (#xx:3) rn 0 0 0 0 0 0 0 imm op 15 0 87 op operand: bit no.: absolute (@aa:8) immediate (#xx:3) abs 0000 imm op 35
figure 2-7 bit manipulation instruction codes (cont) notation: op: rm, rn: abs: imm: operation field register field absolute address immediate data 15 0 87 op imm rn operand: bit no.: register direct (rn) immediate (#xx:3) biand, bior, bixor, bild, bist 15 0 87 op 0 operand: bit no.: register indirect (@rn) immediate (#xx:3) rn 0 0 0 0 0 0 0 imm op 15 0 87 op operand: bit no.: absolute (@aa:8) immediate (#xx:3) abs 0000 imm op 36
2.5.6 branching instructions table 2-9 describes the branching instructions. figure 2-8 shows their object code formats. table 2-9 branching instructions instruction size function bcc branches to the designated address if condition cc is true. the branching conditions are given below. mnemonic description condition bra (bt) always (true) always brn (bf) never (false) never bhi high c z = 0 bls low or same c z = 1 bcc (bhs) carry clear (high or same) c = 0 bcs (blo) carry set (low) c = 1 bne not equal z = 0 beq equal z = 1 bvc overflow clear v = 0 bvs overflow set v = 1 bpl plus n = 0 bmi minus n = 1 bge greater or equal n ? v = 0 blt less than n ? v = 1 bgt greater than z (n ? v) = 0 ble less or equal z (n ? v) = 1 jmp branches unconditionally to a specified address bsr branches to a subroutine at a specified displacement from the current address jsr branches to a subroutine at a specified address rts returns from a subroutine 37
figure 2-8 branching instruction codes notation: op: cc: rm: disp: abs: operation field condition field register field displacement absolute address 15 0 87 op cc disp bcc 15 0 87 op rm 0 jmp (@rm) 000 15 0 87 op jmp (@aa:16) abs 15 0 87 op abs jmp (@@aa:8) 15 0 87 op disp bsr 15 0 87 op rm 0 jsr (@rm) 000 15 0 87 op jsr (@aa:16) abs 15 0 87 op abs jsr (@@aa:8) 15 0 87 op rts 38
2.5.7 system control instructions table 2-10 describes the system control instructions. figure 2-9 shows their object code formats. table 2-10 system control instructions instruction size * function rte returns from an exception-handling routine sleep causes a transition from active mode to a power-down mode. see section 5, power-down modes, for details ldc b rs ? ccr, #imm ? ccr moves immediate data or general register contents to the condition code register stc b ccr ? rd copies the condition code register to a specified general register andc b ccr #imm ? ccr logically ands the condition code register with immediate data orc b ccr #imm ? ccr logically ors the condition code register with immediate data xorc b ccr ? #imm ? ccr logically exclusive-ors the condition code register with immediate data nop pc + 2 ? pc only increments the program counter notes: * size: operand size b: byte 39
figure 2-9 system control instruction codes 2.5.8 block data transfer instruction table 2-11 describes the block data transfer instruction. figure 2-10 shows its object code format. table 2-11 block data transfer instruction instruction size function eepmov if r4l 0 then repeat @r5+ ? @r6+ r4l ?1 ? r4l until r4l = 0 else next; moves a data block according to parameters set in general registers r4l, r5, and r6. r4l: size of block (bytes) r5: starting source address r6: starting destination address execution of the next instruction starts as soon as the block transfer is completed. certain precautions are required in using the eepmov instruction. see 2.9.3, notes on use of the eepmov instruction, for details. notation: op: rn: imm: operation field register field immediate data 15 0 87 op rte, sleep, nop 15 0 87 op rn ldc, stc (rn) 15 0 87 op imm andc, orc, xorc, ldc (#xx:8) 40
figure 2-10 block data transfer instruction code notation: op: operation field 15 0 87 op op 41
2.6 basic operational timing cpu operation is synchronized by a system clock (? or a subclock ( sub ). for details on these clock signals see section 4, clock pulse generators. the period from a rising edge of ?or sub to the next rising edge is called one state. a bus cycle consists of two states or three states. the cycle differs depending on whether access is to on-chip memory or to on-chip peripheral modules. 2.6.1 access to on-chip memory (ram, rom) acess to on-chip memory takes place in two states. the data bus width is 16 bits, allowing access in byte or word size. figure 2-11 shows the on-chip memory access cycle. figure 2-11 on-chip memory access cycle t 1 state bus cycle t 2 state internal address bus internal read signal internal data bus (read access) internal write signal read data address write data internal data bus (write access) sub ?or 42
2.6.2 access to on-chip peripheral modules on-chip peripheral modules are accessed in two states or three states. the data bus width is 8 bits, so access is by byte size only. this means that for accessing word data, two instructions must be used. two-state access to on-chip peripheral modules figure 2-12 shows operation timings for accessing on-chip peripheral modules in 2 states. figure 2-12 on-chip peripheral module access cycle (2-state access) t 1 state bus cycle t 2 state ?or internal address bus internal read signal internal data bus (read access) internal write signal read data address write data internal data bus (write access) sub 43
three-state access to on-chip peripheral modules figure 2-13 shows operation timings for accessing on-chip peripheral modules in 3 states. figure 2-13 on-chip peripheral module access cycle (3-state access) t 1 state bus cycle internal address bus internal read signal internal data bus (read access) internal write signal read data address internal data bus (write access) t 2 state t 3 state write data sub ?or 44
2.7 cpu states 2.7.1 overview there are four cpu states: the reset state, program execution state, program halt state, and exception-handling state. the program execution state includes active (high-speed or medium- speed) mode and subactive mode. in the program halt state there are a sleep mode, standby mode, watch mode, and sub-sleep mode. these states are shown in figure 2-14. figure 2-15 shows the state transitions. figure 2-14 cpu operation states cpu state reset state program execution state program halt state exception- handling state active (high speed) mode active (medium speed) mode subactive mode sleep mode standby mode watch mode subsleep mode low-power modes the cpu executes successive program instructions at high speed, synchronized by the system clock the cpu executes successive program instructions at reduced speed, synchronized by the system clock the cpu executes successive program instructions at reduced speed, synchronized by the subclock a state in which some or all of the chip functions are stopped to conserve power a transient state in which the cpu changes the processing flow due to a reset or an interrupt the cpu is initialized. note: see section 5, power-down modes, for details on the modes and their transitions. 45
figure 2-15 state transitions 2.7.2 program execution state in the program execution state the cpu executes program instructions in sequence. there are three modes in this state, two active modes (high speed and medium speed) and one subactive mode. operation is synchronized with the system clock in active mode (high speed and medium speed), and with the subclock in subactive mode. see section 5, power-down modes for details on these modes. 2.7.3 program halt state in the program halt state there are four modes: sleep mode, standby mode, watch mode, and subsleep mode. see section 5, power-down modes for details on these modes. 2.7.4 exception-handling state the exception-handling state is a transient state occurring when exception handling is started by a reset or interrupt and the cpu changes its normal processing flow. in exception handling caused by an interrupt, sp (r7) is referenced and the pc and ccr values are saved on the stack. for details on interrupt handling, see 3.3, interrupts. reset state program halt state exception-handling state program execution state reset cleared sleep instruction executed reset occurs interrupt source reset occurs exception- handling request exception- handling complete reset occurs 46
2.8 memory map 2.8.1 memory map figure 2-16 shows a memory map for the h8/3877n series. figure 2-16 h8/3877n series memory map interrupt vectors (42 bytes) on-chip rom on-chip ram mtg ram (16 bytes) internal i/o registers (112 bytes) 40 kbytes h8/3875n h'0000 h'0029 h'002a h'9fff h'ffff h'bfff h'edff h'f77f h'f780 h'ff7f h'ff80 h'ff8f h'ff90 reserved h8/3877n h8/3876n 48 kbytes 60 kbytes 2 kbytes 47
2.9 application notes 2.9.1 notes on data access 1. access to empty area the address space of the h8/300l cpu includes empty areas in addition to the ram, registers, and rom areas available to the user. if these empty areas are mistakenly accessed by an application program, the following results will occur. data transfer from cpu to empty area: the transferred data will be lost. this action may also cause the cpu to misoperate. data transfer from empty area to cpu: unpredictable data is transferred. 2. access to the internal i/o register internal data transfer to or from on-chip modules other than the rom and ram areas makes use of an 8-bit data width. if word access is attempted to these areas, the following results will occur. word access from cpu to i/o register area: upper byte: will be written to i/o register. lower byte: transferred data will be lost. word access from i/o register to cpu: upper byte: will be written to upper part of cpu register. lower byte: unpredictable data will be written to lower part of cpu register. byte size instructions should therefore be used when transferring data to or from i/o registers other than the on-chip rom and ram areas. figure 2-17 shows the data size and number of states in which on-chip peripheral modules can be accessed. 48
figure 2-17 data size and number of states for access to and from on-chip peripheral modules word byte access states 2 or 3 2 2 : access possible : not possible interrupt vectors (42 bytes) on-chip rom on-chip ram mtg ram (16 bytes) internal i/o registers (112 bytes) 40 kbytes h'0000 h'0029 h'002a h'9fff h'ffff h'bfff h'edff h'f77f h'f780 h'ff7f h'ff80 h'ff8f h'ff90 reserved 48 kbytes 60 kbytes 2 kbytes 2 h8/3875n h8/3877n h8/3876n 49
2.9.2 notes on bit manipulation the bset, bclr, bnot, bst, and bist instructions read one byte of data, modify the data, then write the data byte again. special care is required when using these instructions in cases where two registers are assigned to the same address, in the case of registers that include write- only bits, and when the instruction accesses an i/o. order of operation operation 1 read read byte data at the designated address 2 modify modify a designated bit in the read data 3 write write the altered byte data to the designated address 1. bit manipulation in two registers assigned to the same address example 1: bit manipulation to the timer load register and the timer counter figure 2-18 shows an example in which two timer registers share the same address. when a bit manipulation instruction accesses the timer load register and timer counter of a reloadable timer, since these two registers share the same address, the following operations take place. order of operation operation 1 read timer counter data is read (one byte) 2 modify the cpu modifies (sets or resets) the bit designated in the instruction 3 write the altered byte data is written to the timer load register the timer counter is counting, so the value read is not necessarily the same as the value in the timer load register. as a result, bits other than the intended bit in the timer load register may be modified to the timer counter value. figure 2-18 timer configuration example this example does not apply to the on-chip timers in the h8/3877n series. r w r: w: read write count clock timer counter timer load register reload internal bus 50
example 2 here a bset instruction is executed designating port 2. p2 7 and p2 6 are designated as input pins, with a low-level signal input at p2 7 and a high-level signal at p2 6 . the remaining pins, p2 5 to p2 0 , are output pins and output low-level signals. in this example, the bset instruction is used to change pin p2 0 to high-level output. [a: prior to executing bset] p2 7 p2 6 p2 5 p2 4 p2 3 p2 2 p2 1 p2 0 input/output input input output output output output output output pin state low high low low low low low low level level level level level level level level pcr2 00111111 pdr2 10000000 [b: bset instruction executed] bset #0 , @pdr2 the bset instruction is executed designating port 2. [c: after executing bset] p2 7 p2 6 p2 5 p2 4 p2 3 p2 2 p2 1 p2 0 input/output input input output output output output output output pin state low high low low low low low high level level level level level level level level pcr2 00111111 pdr2 01000001 [d: explanation of how bset operates] when the bset instruction is executed, first the cpu reads port 2. since p2 7 and p2 6 are input pins, the cpu reads the pin states (low-level and high-level input). p2 5 to p2 0 are output pins, so the cpu reads the value in pdr2. in this example pdr2 has a value of h'80, but the value read by the cpu is h'40. next, the cpu sets bit 0 of the read data to 1, changing the pdr2 data to h'41. finally, the cpu writes this value (h'41) to pdr2, completing execution of bset. 51
as a result of this operation, bit 0 in pdr2 becomes 1, and p2 0 outputs a high-level signal. however, bits 7 and 6 of pdr2 end up with different values. to avoid this problem, store a copy of the pdr2 data in a work area in memory. perform the bit manipulation on the data in the work area, then write this data to pdr2. [a: prior to executing bset] mov. b #80, r0l the pdr2 value (h'80) is written to a work area in memory mov. b r0l, @ram0 (ram0) as well as to pdr2. mov. b r0l, @pdr2 p2 7 p2 6 p2 5 p2 4 p2 3 p2 2 p2 1 p2 0 input/output input input output output output output output output pin state low high low low low low low low level level level level level level level level pcr2 00111111 pdr2 10000000 ram0 10000000 [b: bset instruction executed] bset #0 , @ram0 the bset instruction is executed designating the pdr2 work area (ram0). [c: after executing bset] mov. b @ram0, r0l the work area (ram0) value is written to pdr2. mov. b r0l, @pdr2 p2 7 p2 6 p2 5 p2 4 p2 3 p2 2 p2 1 p2 0 input/output input input output output output output output output pin state low high low low low low low high level level level level level level level level pcr2 00111111 pdr2 10000001 ram0 10000001 52
2. bit manipulation in a register containing a write-only bit example 3 in this example, the port 2 control register pcr2 is accessed by a bclr instruction. as in the examples above, p2 7 and p2 6 are input pins, with a low-level signal input at p2 7 and a high-level signal at p2 6 . the remaining pins, p2 5 to p2 0 , are output pins that output low-level signals. in this example, the bclr instruction is used to change pin p2 0 to an input port. it is assumed that a high-level signal will be input to this input pin. [a: prior to executing bclr] p2 7 p2 6 p2 5 p2 4 p2 3 p2 2 p2 1 p2 0 input/output input input output output output output output output pin state low high low low low low low low level level level level level level level level pcr2 00111111 pdr2 10000000 [b: bclr instruction executed] bclr #0 , @pcr2 the bclr instruction is executed designating pcr2. [c: after executing bclr] p2 7 p2 6 p2 5 p2 4 p2 3 p2 2 p2 1 p2 0 input/output output output output output output output output input pin state low high low low low low low high level level level level level level level level pcr2 11111110 pdr2 10000000 53
[d: explanation of how bclr operates] when the bclr instruction is executed, first the cpu reads port 2. since pcr2 is a write-only register, the cpu reads a value of h'ff, even though the pcr2 value is actually h'3f. next, the cpu clears bit 0 in the read data to 0, changing the data to h'fe. finally, this value (h'fe) is written to pcr2 and bclr instruction execution ends. as a result of this operation, bit 0 in pcr2 becomes 0, making p2 0 an input port. however, bits 7 and 6 in pcr2 change to 1, so that p2 7 and p2 6 change from input pins to output pins. to avoid this problem, store a copy of the pcr2 data in a work area in memory. perform the bit manipulation on the data in the work area, then write this data to pcr2. [a: prior to executing bclr] mov. b #3f, r0l the pcr2 value (h'3f) is written to a work area in memory mov. b r0l, @ram0 (ram0) as well as to pcr2. mov. b r0l, @pcr2 p2 7 p2 6 p2 5 p2 4 p2 3 p2 2 p2 1 p2 0 input/output input input output output output output output output pin state low high low low low low low low level level level level level level level level pcr2 00111111 pdr2 10000000 ram0 00111111 [b: bclr instruction executed] bclr #0 , @ram0 the bclr instruction is executed designating the pcr2 work area (ram0). 54
[c: after executing bclr] mov. b @ram0, r0l the work area (ram0) value is written to pcr2. mov. b r0l, @pcr2 p2 7 p2 6 p2 5 p2 4 p2 3 p2 2 p2 1 p2 0 input/output input input output output output output output output pin state low high low low low low low high level level level level level level level level pcr2 00111110 pdr2 10000000 ram0 00111110 table 2-12 lists the registers with shared addresses. table 2-13 lists the registers that contain write- only bits. table 2-12 registers with shared addresses register name abbreviation address port data register 1 * pdr1 h'ffd4 port data register 2 * pdr2 h'ffd5 port data register 5 * pdr5 h'ffd8 port data register 6 * pdr6 h'ffd9 port data register 7 * pdr7 h'ffda port data register 8 * pdr8 h'ffdb port data register 9 * pdr9 h'ffdc port data register a * pdra h'ffdd port data register d * pdrd h'ffd2 port data register e * pdre h'ffd3 note: * the port data register addresses are also assigned directly to input pins. 55
table 2-13 registers with write-only bits register name abbreviation address port control register 1 pcr1 h'ffe4 port control register 2 pcr2 h'ffe5 port control register 5 pcr5 h'ffe8 port control register 6 pcr6 h'ffe9 port control register 7 pcr7 h'ffea port control register 8 pcr8 h'ffeb port control register 9 pcr9 h'ffec port control register a pcra h'ffed port control register d pcrd h'ffe2 port control register e pcre h'ffe3 timer control register f tcrf h'ffb6 2.9.3 notes on use of the eepmov instruction the eepmov instruction is a block data transfer instruction. it moves the number of bytes specified by r4l from the address specified by r5 to the address specified by r6. when setting r4l and r6, make sure that the final destination address (r6 + r4l) does not exceed h'ffff. the value in r6 must not change from h'ffff to h'0000 during execution of the instruction. ? r6 ? r6 + r4l r5 ? r5 + r4l ? h'ffff not allowed ? r6 ? r6 + r4l r5 ? r5 + r4l ? 56
section 3 exception handling 3.1 overview exception handling is performed in the h8/3877n series when a reset or interrupt occurs. table 3-1 shows the priorities of these two types of exception handling. table 3-1 exception handling types and priorities priority exception source time of start of exception handling high reset exception handling starts as soon as the reset state is cleared interrupt when an interrupt is requested, exception handling starts after execution of the present instruction or the exception low handling in progress is completed 3.2 reset 3.2.1 overview a reset is the highest-priority exception. the internal state of the cpu and the registers of the on- chip peripheral modules are initialized. 3.2.2 reset sequence as soon as the res pin goes low, all processing is stopped and the h8/3877 enters the reset state. to make sure the chip is reset properly, observe the following precautions. at power on: hold the res pin low until the clock pulse generator output stabilizes. resetting during operation: hold the res pin low for at least 10 system clock cycles. reset exception handling begins when the res pin is held low for a given period, then returned to the high level. reset exception handling takes place as follows. the cpu internal state and the registers of on-chip peripheral modules are initialized, with the i bit of the condition code register (ccr) set to 1. the pc is loaded from the reset exception handling vector address (h'0000 to h'0001), after which the program starts executing from the address indicated in pc. 57
when system power is turned on or off, the res pin should be held low. figure 3-1 shows the reset sequence. figure 3-1 reset sequence 3.2.3 interrupt immediately after reset after a reset, if an interrupt were to be accepted before the stack pointer (sp: r7) was initialized, pc and ccr would not be pushed onto the stack correctly, resulting in program runaway. to prevent this, immediately after reset exception handling all interrupts are masked. for this reason, the initial program instruction is always executed immediately after a reset. this instruction should initialize the stack pointer (e.g. mov.w #xx: 16, sp). vector fetch internal address bus internal read signal internal write signal internal data bus (16-bit) res internal processing program initial instruction prefetch (1) reset exception handling vector address (h'0000) (2) program start address (3) first instruction of program (2) (3) (2) reset state reset cleared (1) 58
3.3 interrupts 3.3.1 overview the interrupt sources include 14 external interrupts (nmi, wkp 0 to wkp 7 , irq 0 to irq 4 ), and 17 internal interrupts from on-chip peripheral modules. table 3-2 shows the interrupt sources, their priorities, and their vector addresses. when more than one interrupt is requested, the interrupt with the highest priority is processed. the interrupts have the following features: nmi is the highest-priority interrupt and is always accepted. internal and external interrupts other than nmi can be masked by the i bit of ccr. when this bit is set to 1, interrupt request flags are set but interrupts are not accepted, except for nmi. nmi and irq 0 to irq 4 can each be set independently to either rising edge sensing or falling edge sensing. table 3-2 interrupt sources and priorities priority interrupt source interrupt vector number vector address high res reset 0 h'0000 to h'0001 nmi nmi 3 h'0006 to h'0007 irq 0 irq 0 4 h'0008 to h'0009 irq 1 irq 1 5 h'000a to h'000b irq 2 irq 2 6 h'000c to h'000d irq 3 irq 3 7 h'000e to h'000f irq 4 irq 4 8 h'0010 to h'0011 wkp 0 wkp 0 9 h'0012 to h'0013 wkp 1 wkp 1 wkp 2 wkp 2 wkp 3 wkp 3 wkp 4 wkp 4 wkp 5 wkp 5 wkp 6 wkp 6 wkp 7 wkp 7 low sci1 sci1 transfer complete 10 h'0014 to h'0015 59
table 3-2 interrupt sources and priorities (cont) vector priority interrupt source interrupt number vector address high timer a timer a overflow 11 h'0016 to h'0017 timer fl timer fl compare match 14 h'001c to h'001d timer fl overflow timer fh timer fh compare match 15 h'001e to h'001f timer fh overflow timer g timer g input capture 16 h'0020 to h'0021 timer g overflow multitone generator multitone half-cycle 17 h'0022 to h'0023 sci3 sci3 receive data full 18 h'0024 to h'0025 sci3 transmit data empty sci3 transmit end sci3 overrun error sci3 framing error sci3 parity error a/d converter a/d conversion end 19 h'0026 to h'0027 (sleep instruction direct transfer 20 h'0028 to h'0029 low executed) note: vector addresses h'0002 to h'0005 and h'0018 to h'001b are reserved and cannot be used. 60
3.3.2 interrupt control registers table 3-3 lists the registers that control interrupts. table 3-3 interrupt control registers register name abbreviation r/w initial value address interrupt edge select register iegr r/w h'60 h'fff2 interrupt enable register 1 ienr1 r/w h'00 h'fff3 interrupt enable register 2 ienr2 r/w h'03 h'fff4 interrupt request register 1 irr1 r/w * h'20 h'fff6 interrupt request register 2 irr2 r/w * h'03 h'fff7 wakeup interrupt request register iwpr r/w * h'00 h'fff9 note: * write is enabled only for writing of 0 to clear a flag. 1. interrupt edge select register (iegr) iegr is an 8-bit read/write register, used to designate whether pins nmi and irq 0 to irq 4 are set to rising edge sensing or falling edge sensing. bit 7: nmi edge select (nmieg) bit 7 selects the input sensing of the nmi pin. bit 7 nmieg description 0 falling edge of nmi pin input is detected (initial value) 1 rising edge of nmi pin input is detected bits 6 and 5: reserved bits bits 6 and 5 are reserved: they are always read as 1, and cannot be modified. bit initial value read/write 7 nmieg 0 r/w 6 1 5 1 4 ieg4 0 r/w 3 ieg3 0 r/w 0 ieg0 0 r/w 2 ieg2 0 r/w 1 ieg1 0 r/w 61
bit 4: irq 4 edge select (ieg4) bit 4 selects the input sensing of pin irq 4 /adtrg. bit 4 ieg4 description 0 falling edge of irq 4 /adtrg pin input is detected (initial value) 1 rising edge of irq 4 /adtrg pin input is detected bit 3: irq 3 edge select (ieg3) bit 3 selects the input sensing of pin irq 3 /tmif. bit 3 ieg3 description 0 falling edge of irq 3 /tmif pin input is detected (initial value) 1 rising edge of irq 3 /tmif pin input is detected bit 2: irq 2 edge select (ieg2) bit 2 selects the input sensing of pin irq 2 . bit 2 ieg2 description 0 falling edge of irq 2 pin input is detected (initial value) 1 rising edge of irq 2 pin input is detected bit 1: irq 1 edge select (ieg1) bit 1 selects the input sensing of pin irq 1 . bit 1 ieg1 description 0 falling edge of irq 1 pin input is detected (initial value) 1 rising edge of irq 1 pin input is detected bit 0: irq 0 edge select (ieg0) bit 0 selects the input sensing of pin irq 0 . bit 0 ieg0 description 0 falling edge of irq 0 pin input is detected (initial value) 1 rising edge of irq 0 pin input is detected 62
2. interrupt enable register 1 (ienr1) ienr1 is an 8-bit read/write register that enables or disables interrupt requests. bit 7: timer a interrupt enable (ienta) bit 7 enables or disables timer a overflow interrupt requests. bit 7 ienta description 0 disables timer a interrupts (initial value) 1 enables timer a interrupts bit 6: sci1 interrupt enable (iens1) bit 6 enables or disables sci1 transfer complete interrupt requests. bit 6 iens1 description 0 disables sci1 interrupts (initial value) 1 enables sci1 interrupts bit 5: wakeup interrupt enable (ienwp) bit 5 enables or disables wkp 7 to wkp 0 interrupt requests. bit 5 ienwp description 0 disables interrupt requests from wkp 7 to wkp 0 (initial value) 1 enables interrupt requests from wkp 7 to wkp 0 bit initial value read/write 7 ienta 0 r/w 6 iens1 0 r/w 5 ienwp 0 r/w 4 ien4 0 r/w 3 ien3 0 r/w 0 ien0 0 r/w 2 ien2 0 r/w 1 ien1 0 r/w 63
bits 4 to 0: irq 4 to irq 0 interrupt enable (ien4 to ien0) bits 4 to 0 enable or disable irq 4 to irq 0 interrupt requests. bits 4 to 0 ien4 to ien0 description 0 disables interrupt requests from irq 4 to irq 0 (initial value) 1 enables interrupt requests from irq 4 to irq 0 3. interrupt enable register 2 (ienr2) ienr2 is an 8-bit read/write register that enables or disables interrupt requests. bit 7: direct transfer interrupt enable (iendt) bit 7 enables or disables direct transfer interrupt requests. bit 7 iendt description 0 disables direct transfer interrupt requests (initial value) 1 enables direct transfer interrupt requests bit 6: a/d converter interrupt enable (ienad) bit 6 enables or disables a/d converter interrupt requests. bit 6 ienad description 0 disables a/d converter interrupt requests (initial value) 1 enables a/d converter interrupt requests bit initial value read/write 7 iendt 0 r/w 6 ienad 0 r/w 5 ienmt 0 r/w 4 ientg 0 r/w 3 ientfh 0 r/w 0 1 2 ientfl 0 r/w 1 1 64
bit 5: multitone generator interrupt enable (ienmt) bit 5 enables or disables multitone half-cycle interrupt requests. bit 5 ienmt description 0 disables multitone half-cycle interrupts (initial value) 1 enables multitone half-cycle interrupts bit 4: timer g interrupt enable (ientg) bit 4 enables or disables timer g input capture and overflow interrupt requests. bit 4 ientg description 0 disables timer g interrupts (initial value) 1 enables timer g interrupts bit 3: timer fh interrupt enable (ientfh) bit 3 enables or disables timer fh compare match and overflow interrupt requests. bit 3 ientfh description 0 disables timer fh interrupts (initial value) 1 enables timer fh interrupts bit 2: timer fl interrupt enable (ientfl) bit 2 enables or disables timer fl compare match and overflow interrupt requests. bit 2 ientfl description 0 disables timer fl interrupts (initial value) 1 enables timer fl interrupts 65
bits 1 and 0: reserved bits bits 1 and 0 are reserved: they are always read as 1, and cannot be modified. sci3 interrupt control is covered in 10.3.2, in the description of serial control register 3. 4. interrupt request register 1 (irr1) note: * only a write of 0 for flag clearing is possible. irr1 is an 8-bit read/write register, in which the corresponding bit is set to 1 when a timer a, sci1, or irq 4 to irq 0 interrupt is requested. the flags are not cleared automatically when an interrupt is accepted. it is necessary to write 0 to clear each flag. bit 7: timer a interrupt request flag (irrta) bit 7 irrta description 0 clearing conditions: (initial value) when irrta = 1, it is cleared by writing 0 1 setting conditions: when the timer a counter value overflows (goes from h'ff to h'00) bit 6: sci1 interrupt request flag (irrs1) bit 6 irrs1 description 0 clearing conditions: (initial value) when irrs1 = 1, it is cleared by writing 0 1 setting conditions: when an sci1 transfer is completed bit 5: reserved bit bit 5 is reserved; it is always read as 1, and cannot be modified. bit initial value read/write 7 irrta 0 r/w 6 irrs1 0 r/w 5 1 4 irri4 0 r/w 3 irri3 0 r/w 0 irri0 0 r/w 2 irri2 0 r/w 1 irri1 0 r/w ** ** * ** 66
bits 4 to 0: irq 4 to irq 0 interrupt request flags (irri4 to irri0) bits 4 to 0 irri4 to irri0 description 0 clearing conditions: (initial value) when irrin = 1, it is cleared by writing 0 to irrin. 1 setting conditions: irrin is set when pin irq n is set to interrupt input, and the designated signal edge is detected. (n = 4 to 0) 5. interrupt request register 2 (irr2) note: * only a write of 0 for flag clearing is possible. irr2 is an 8-bit read/write register, in which the corresponding bit is set to 1 when a direct transfer, a/d converter, multitone generator, timer g, timer fh, timer fl, timer c, or timer b interrupt is requested. the flags are not cleared automatically when an interrupt is accepted. it is necessary to write 0 to clear each flag. bit 7: direct transfer interrupt request flag (irrdt) bit 7 irrdt description 0 clearing conditions: (initial value) when irrdt = 1, it is cleared by writing 0 1 setting conditions: when dton = 1 and a direct transfer is made immediately after a sleep instruction is executed bit 6: a/d converter interrupt request flag (irrad) bit 6 irrad description 0 clearing conditions: (initial value) when irrad = 1, it is cleared by writing 0 1 setting conditions: when a/d conversion is completed and adsf is reset bit initial value read/write 7 irrdt 0 r/w 6 irrad 0 r/w 5 irrmt 0 r/w 4 irrtg 0 r/w 3 irrtfh 0 r/w 0 1 2 irrtfl 0 r/w 1 1 ****** 67
bit 5: multitone generator interrupt request flag (irrmt) bit 5 irrmt description 0 clearing conditions: (initial value) when irrmt = 1, it is cleared by writing 0 1 setting conditions: when the mulitone generator has output one half-cycle of data bit 4: timer g interrupt request flag (irrtg) bit 4 irrtg description 0 clearing conditions: (initial value) when irrtg = 1, it is cleared by writing 0 1 setting conditions: when pin tmig is set to tmig input and the designated signal edge is detected bit 3: timer fh interrupt request flag (irrtfh) bit 3 irrtfh description 0 clearing conditions: (initial value) when irrtfh = 1, it is cleared by writing 0 1 setting conditions: when counter fh matches output compare register fh in 8-bit timer mode, or when 16-bit counter f (tcfl, tcfh) matches output compare register f (ocrfl, ocrfh) in 16-bit timer mode bit 2: timer fl interrupt request flag (irrtfl) bit 2 irrtfl description 0 clearing conditions: (initial value) when irrtfl = 1, it is cleared by writing 0 1 setting conditions: when counter fl matches output compare register fl in 8-bit timer mode bits 1 and 0: reserved bits bits 1 and 0 are reserved: they are always read as 1, and cannot be modified. 68
6. wakeup interrupt request register (iwpr) note: * only a write of 0 for flag clearing is possible. iwpr is an 8-bit read/write register, in which the corresponding bit is set to 1 when pins wkp 7 to wkp 0 are set to wakeup input and a pin receives a falling edge input. the flags are not cleared automatically when an interrupt is accepted. it is necessary to write 0 to clear each flag. bits 7 to 0: wakeup interrupt request flags (iwpf7 to iwpf0) bits 7 to 0 iwpf7 to iwpf0 description 0 clearing conditions: when iwpfn = 1, it is cleared by writing 0 to iwpfn. 1 setting conditions: iwpfn is set when pin wkp n is set to wakeup interrupt input, and a falling edge input is detected at the pin. (n = 7 to 0) 3.3.3 external interrupts there are 14 external interrupts, nmi, wkp 0 to wkp 7 and irq 0 to irq 4 . 1. nmi interrupt the nmi interrupt is requested by input at the nmi pin. this interrupt can be detected by either rising edge sensing or falling edge sensing, depending on the setting of bit nmieg in iegr. the nmi interrupt has highest priority and is always accepted, regardless of the setting of the i bit in ccr. the nmi interrupt has exception vector 3. when this exception is recognized, the i bit is set to 1 in ccr. bit initial value read/write 7 iwpf7 0 r/w 6 iwpf6 0 r/w 5 iwpf5 0 r/w 4 iwpf4 0 r/w 3 iwpf3 0 r/w 0 iwpf0 0 r/w 2 iwpf2 0 r/w 1 iwpf1 0 r/w ***** * ** 69
2. interrupts wkp 0 to wkp 7 interrupts wkp 0 to wkp 7 are requested by falling edge inputs at pins wkp 0 to wkp 7 . when these pins are designated as wkp 0 to wkp 7 pins in port mode register 5 (pmr5) and falling edge input is detected, the corresponding bit in the wakeup interrupt request register (iwpr) is set to 1, requesting an interrupt. wakeup interrupt requests can be disabled by clearing the ienwp bit in ienr1 to 0. it is also possible to mask all interrupts by setting the ccr i bit to 1. when an interrupt exception handling request is received for interrupts wkp0 to wkp7, the ccr i bit is set to 1. the vector number for interrupts wkp0 to wkp7 is 9. since all eight interrupts are assigned the same vector number, the interrupt source must be determined by the exception handling routine. 3. interrupts irq 0 to irq 4 interrupts irq 0 to irq 4 are requested by inputs into pins irq 0 to irq 4 . these interrupts are detected by either rising edge sensing or falling edge sensing, depending on the settings of bits ieg0 to ieg4 in the edge select register (iegr). when these pins are designated as pins irq 0 to irq 4 in port mode registers 1 and 2 (pmr1 and pmr2) and the designated edge is input, the corresponding bit in irr1 is set to 1, requesting an interrupt. interrupts irq 0 to irq 4 can be disabled by clearing bits ien0 to ien4 in ienr1 to 0. all interrupts can be masked by setting the i bit in ccr to 1. when irq 0 to irq 4 interrupt exception handling is initiated, the i bit is set to 1. vector numbers 4 to 8 are assigned to interrupts irq 0 to irq 4 . the order of priority is from irq 0 (high) to irq 4 (low). table 3-2 gives details. 3.3.4 internal interrupts there are 17 internal interrupts that can be requested by the on-chip peripheral modules. when a peripheral module requests an interrupt, the corresponding bit in irr1 or irr2 is set to 1. individual interrupt requests can be disabled by clearing the corresponding bit in ienr1 or ienr2 to 0. all interrupts can be masked by setting the i bit in ccr to 1. when an internal interrupt request is accepted, the i bit is set to 1. vector numbers 10 to 20 are assigned to these interrupts. table 3-2 shows the order of priority of interrupts from on-chip peripheral modules. 70
3.3.5 interrupt operations interrupts are controlled by an interrupt controller. figure 3-2 shows a block diagram of the interrupt controller. figure 3-3 shows the flow up to interrupt acceptance. figure 3-2 block diagram of interrupt controller interrupt operation is described as follows. when an interrupt condition is met while the interrupt enable register bit is set to 1, an interrupt request signal is sent to the interrupt controller. when the interrupt controller receives an interrupt request, it sets the interrupt request flag. from among the interrupts with interrupt request flags set to 1, the interrupt controller selects the interrupt request with the highest priority and holds the others pending. (refer to table 3-2 for a list of interrupt priorities.) interrupt controller priority decision logic interrupt request ccr (cpu) i external or internal interrupts external interrupts or internal interrupt enable signals 71
the interrupt controller checks the i bit of ccr. if the i bit is 0, the selected interrupt request is accepted; if the i bit is 1, the interrupt request is held pending. if the interrupt is accepted, after processing of the current instruction is completed, both pc and ccr are pushed onto the stack. the state of the stack at this time is shown in figure 3-4. the pc value pushed onto the stack is the address of the first instruction to be executed upon return from interrupt handling. the i bit of ccr is set to 1, masking all further interrupts. the vector address corresponding to the accepted interrupt is generated, and the interrupt handling routine located at the address indicated by the contents of the vector address is executed. notes: 1. when disabling interrupts by clearing bits in an interrupt enable register, or when clearing bits in an interrupt request register, always do so while interrupts are masked (i = 1). 2. if the above clear operations are performed while i = 0, and as a result a conflict arises between the clear instruction and an interrupt request, exception processing for the interrupt will be executed after the clear instruction has been executed. 72
figure 3-3 flow up to interrupt acceptance pc contents saved ccr contents saved i ? 1 i = 0 program execution state no yes yes no notation: pc: ccr: i: program counter condition code register i bit of ccr ien0 = 1 no yes iendt = 1 no yes irrdt = 1 no yes branch to interrupt handling routine irri0 = 1 no yes ien1 = 1 no yes irri1 = 1 no yes ien2 = 1 no yes irri2 = 1 73
figure 3-4 stack state after completion of interrupt exception handling figure 3-5 shows a typical interrupt sequence where the program area is in the on-chip rom and the stack area is in the on-chip ram. pc and ccr saved to stack sp (r7) sp ?1 sp ?2 sp ?3 sp ?4 stack area sp + 4 sp + 3 sp + 2 sp + 1 sp (r7) even address prior to start of interrupt exception handling after completion of interrupt exception handling notation: pc h : pc l : ccr: sp: upper 8 bits of program counter (pc) lower 8 bits of program counter (pc) condition code register stack pointer * ignored on return from interrupt. notes: ccr ccr * pc h pc l 1. 2. pc shows the address of the first instruction to be executed upon return from the interrupt handling routine. register contents must always be saved and restored by word access, starting from an even-numbered address. 74
figure 3-5 interrupt sequence vector fetch internal address bus internal read signal internal write signal (2) internal data bus (16 bits) interrupt request signal (9) (1) internal processing prefetch instruction of interrupt-handling routine (1) instruction prefetch address (instruction is not executed. address is saved as pc contents, becoming return address.) (2)(4) instruction code (not executed) (3) instruction prefetch address (instruction is not executed.) (5) sp ?2 (6) sp ?4 (7) ccr (8) vector address (9) starting address of interrupt-handling routine (contents of vector) (10) first instruction of interrupt-handling routine (3) (9) (8) (6) (5) (4) (1) (7) (10) stack access internal processing instruction prefetch interrupt level decision and wait for end of instruction interrupt is accepted 75
3.3.6 interrupt response time table 3-4 shows the number of wait states after an interrupt request flag is set until the first instruction of the interrupt handler is executed. table 3-4 interrupt wait states item states waiting time for completion of executing instruction * 1 to 13 saving of pc and ccr to stack 4 vector fetch 2 instruction fetch 4 internal processing 4 total 15 to 27 note: * not including eepmov instruction. 76
3.4 application notes 3.4.1 notes on stack area use when word data is accessed in the h8/3877n series, the least significant bit of the address is regarded as 0. access to the stack always takes place in word size, so the stack pointer (sp: r7) should never indicate an odd address. use push rn (mov.w rn, @esp) or pop rn (mov.w @sp+, rn) to save or restore register values. setting an odd address in sp may cause a program to crash. an example is shown in figure 3-6. figure 3-6 operation when odd address is set in sp when ccr contents are saved to the stack during interrupt exception handling or restored when rte is executed, this also takes place in word size. both the upper and lower bytes of word data are saved to the stack; on return, the even address contents are restored to ccr while the odd address contents are ignored. pc pc r1l pc sp sp sp h'fefc h'fefd h'feff ? ? ? h l l mov. b r1l, @?7 sp set to h'feff stack accessed beyond sp bsr instruction contents of pc are lost h notation: pc h : pc l : r1l: sp: upper byte of program counter lower byte of program counter general register r1l stack pointer 77
3.4.2 notes on rewriting port mode registers when a port mode register is rewritten to switch the functions of external interrupt pins, the following points should be observed. when an external interrupt pin function is switched by rewriting the port mode register that controls these pins (irq 4 to irq 0 , and wkp 7 to wkp 0 ), the interrupt request flag may be set to 1 at the time the pin function is switched, even if no valid interrupt is input at the pin. be sure to clear the interrupt request flag to 0 after switching pin functions. table 3-5 shows the conditions under which interrupt request flags are set to 1 in this way. table 3-5 conditions under which interrupt request flag is set to 1 interrupt request flags set to 1 conditions irr1 irri4 when pmr2 bit irq4 is changed from 0 to 1 while pin irq 4 is low and iegr bit ieg4 = 0. when pmr2 bit irq4 is changed from 1 to 0 while pin irq 4 is low and iegr bit ieg4 = 1. irri3 when pmr1 bit irq3 is changed from 0 to 1 while pin irq 3 is low and iegr bit ieg3 = 0. when pmr1 bit irq3 is changed from 1 to 0 while pin irq 3 is low and iegr bit ieg3 = 1. irri2 when pmr1 bit irq2 is changed from 0 to 1 while pin irq 2 is low and iegr bit ieg2 = 0. when pmr1 bit irq2 is changed from 1 to 0 while pin irq 2 is low and iegr bit ieg2 = 1. irri1 when pmr1 bit irq1 is changed from 0 to 1 while pin irq 1 is low and iegr bit ieg1 = 0. when pmr1 bit irq1 is changed from 1 to 0 while pin irq 1 is low and iegr bit ieg1 = 1. irri0 when pmr2 bit irq0 is changed from 0 to 1 while pin irq 0 is low and iegr bit ieg0 = 0. when pmr2 bit irq0 is changed from 1 to 0 while pin irq 0 is low and iegr bit ieg0 = 1. 78
table 3-5 conditions under which interrupt request flag is set to 1 (cont) interrupt request flags set to 1 conditions iwpr iwpf7 when pmr5 bit wkp7 is changed from 0 to 1 while pin wkp 7 is low iwpf6 when pmr5 bit wkp6 is changed from 0 to 1 while pin wkp 6 is low iwpf5 when pmr5 bit wkp5 is changed from 0 to 1 while pin wkp 5 is low iwpf4 when pmr5 bit wkp4 is changed from 0 to 1 while pin wkp 4 is low iwpf3 when pmr5 bit wkp3 is changed from 0 to 1 while pin wkp 3 is low iwpf2 when pmr5 bit wkp2 is changed from 0 to 1 while pin wkp 2 is low iwpf1 when pmr5 bit wkp1 is changed from 0 to 1 while pin wkp 1 is low iwpf0 when pmr5 bit wkp0 is changed from 0 to 1 while pin wkp 0 is low figure 3-7 shows the procedure for setting a bit in a port mode register and clearing the interrupt request flag. when switching a pin function, mask the interrupt before setting the bit in the port mode register. after accessing the port mode register, execute at least one instruction (e.g., nop), then clear the interrupt request flag from 1 to 0. if the instruction to clear the flag is executed immediately after the port mode register access without executing an intervening instruction, the flag will not be cleared. an alternative method is to avoid the setting of interrupt request flags when pin functions are switched by keeping the pins at the high level so that the conditions in table 3-5 do not occur. figure 3-7 port mode register setting and interrupt request flag clearing procedure ccr i bit 1 set port mode register bit execute nop instruction interrupts masked. (another possibility is to disable the relevant interrupt in interrupt enable register 1.) after setting the port mode register bit, first execute at least one instruction (e.g., nop), then clear the interrupt request flag to 0 interrupt mask cleared clear interrupt request flag to 0 ? ccr i bit 0 ? 79
section 4 clock pulse generators 4.1 overview clock oscillator circuitry (cpg: clock pulse generator) is provided on-chip, including both a system clock pulse generator and a subclock pulse generator. the system clock pulse generator consists of a system clock oscillator and system clock dividers. the subclock pulse generator consists of a subclock oscillator circuit and a subclock divider. 4.1.1 block diagram figure 4-1 shows a block diagram of the clock pulse generators. figure 4-1 block diagram of clock pulse generators 4.1.2 system clock and subclock the basic clock signals that drive the cpu and on-chip peripheral modules are ?and sub . four of the clock signals have names: ?is the system clock, sub is the subclock, osc is the oscillator clock, and w is the watch clock. the clock signals available for use by peripheral modules are osc , ?2, ?4, ?8, ?16, ?32, ?64, ?128, ?256, ?512, ?1024, ?2048, ?4096, ?8192, w , w /2, w /4, w /8, w /16, w /32, w /64, and w /128. the clock requirements differ from one module to another. system clock oscillator system clock divider (1/2) subclock oscillator subclock divider (1/2, 1/4, 1/8) system clock divider (1/8) system clock pulse generator subclock pulse generator prescaler s (13 bits) prescaler w (5 bits) osc osc 1 2 x x 1 2 osc (f ) osc w (f ) w ? /2 osc ? /2 w ? /8 w sub ?2 to ?8192 ? /2 w ? /4 w ? /8 to ? /128 w w ? /16 osc ? /4 w w osc 81
4.2 system clock generator clock pulse can be supplied to the system clock divider either by connecting a crystal or ceramic oscillator, or by providing external clock input. 1. connecting a crystal oscillator figure 4-2 shows a typical method of connecting a crystal oscillator. figure 4-2 typical connection to crystal oscillator figure 4-3 shows the equivalent circuit of a crystal oscillator. an oscillator having the characteristics given in table 4-1 should be used. figure 4-3 equivalent circuit of crystal oscillator table 4-1 crystal oscillator parameters frequency (mhz) 24810 rs max ( ) 500 100 50 30 co max (pf) 7 1 2 c 1 c 2 osc osc r = 1 m ?0% c = c = 12 pf ?0% f 12 w r f c s c 0 r s osc 1 osc 2 l s 82
2. connecting a ceramic oscillator figure 4-4 shows a typical method of connecting a ceramic oscillator. figure 4-4 typical connection to ceramic oscillator 3. notes on board design when generating clock pulses by connecting a crystal or ceramic oscillator, pay careful attention to the following points. avoid running signal lines close to the oscillator circuit, since the oscillator may be adversely affected by induction currents. (see figure 4-5.) the board should be designed so that the oscillator and load capacitors are located as close as possible to pins osc 1 and osc 2 . figure 4-5 board design of oscillator circuit 1 2 c 1 c 2 osc osc r f = 1 m w ?20% c 1 = 30 pf ?10% c 2 = 30 pf ?10% ceramic oscillator: murata r f osc osc c 2 c 1 signal a signal b 2 1 to be avoided 83
4. external clock input method connect an external clock signal to pin osc 1 , and leave pin osc 2 open. figure 4-6 shows a typical connection. figure 4-6 external clock input (example) frequency oscillator clock ( osc ) duty cycle 45% to 55% 1 2 osc osc external clock input open 84
4.3 subclock generator 1. connecting a 32.768-khz crystal oscillator clock pulses can be supplied to the subclock divider by connecting a 32.768-khz crystal oscillator, as shown in figure 4-7. follow the same precautions as noted under 4.2.3 for the system clock. figure 4-7 typical connection to 32.768-khz crystal oscillator (subclock) figure 4-8 shows the equivalent circuit of the 32.768-khz crystal oscillator. figure 4-8 equivalent circuit of 32.768-khz crystal oscillator x x c 1 c 2 1 2 c = c = 15 pf (typ.) 12 c s c 0 lr s x 1 x 2 c = 1.5 pf typ r = 14 k typ f = 32.768 khz crystal oscillator: mx38t (nihon denpa kogyo) 0 s w w s 85
2. pin connection when not using subclock when the subclock is not used, connect pin x 1 to v cc and leave pin x 2 open, as shown in figure 4-9. figure 4-9 pin connection when not using subclock x x 1 2 v cc open 86
4.4 prescalers the h8/3877n series is equipped with two on-chip prescalers having different input clocks (prescaler s and prescaler w). prescaler s is a 13-bit counter using the system clock (? as its input clock. its prescaled outputs provide internal clock signals for on-chip peripheral modules. prescaler w is a 5-bit counter using a 32.768-khz signal divided by 4 ( w /4) as its input clock. its prescaled outputs are used by timer a as a time base for timekeeping. 1. prescaler s (pss) prescaler s is a 13-bit counter using the system clock (? as its input clock. it is incremented once per clock period. prescaler s is initialized to h'0000 by a reset, and starts counting on exit from the reset state. in standby mode, watch mode, subactive mode, and subsleep mode, the system clock pulse generator stops. prescaler s also stops and is initialized to h'0000. the cpu cannot read or write prescaler s. the output from prescaler s is shared by the on-chip peripheral modules. the divider ratio can be set separately for each on-chip peripheral function. in active (medium-speed) mode the clock input to prescaler s is osc /16. 2. prescaler w (psw) prescaler w is a 5-bit counter using a 32.768 khz signal divided by 4 ( w /4) as its input clock. prescaler w is initialized to h'00 by a reset, and starts counting on exit from the reset state. even in standby mode, watch mode, subactive mode, or subsleep mode, prescaler w continues functioning so long as clock signals are supplied to pins x 1 and x 2 . prescaler w can be reset by setting 1s in bits tma3 and tma2 of timer mode register a (tma). output from prescaler w can be used to drive timer a, in which case timer a functions as a time base for timekeeping. 87
4.5 note on oscillators oscillator characteristics of both the masked rom and ztat tm versions are closely related to board design and should be carefully evaluated by the user, referring to the examples shown in this section. oscillator circuit constants will differ depending on the oscillator element, stray capacitance in its interconnecting circuit, and other factors. suitable constants should be determined in consultation with the oscillator element manufacturer. design the circuit so that the oscillator element never receives voltages exceeding its maximum rating. 88
section 5 power-down modes 5.1 overview the h8/3877n series has seven modes of operation after a reset. these include six power-down modes, in which power dissipation is significantly reduced. table 5-1 gives a summary of the seven operation modes. all but the active (high-speed) mode are power-down modes. table 5-1 operation modes operating mode description active (high-speed) mode the cpu runs on the system clock, executing program instructions at high speed active (medium-speed) mode the cpu runs on the system clock, executing program instructions at reduced speed subactive mode the cpu runs on the subclock, executing program instructions at reduced speed sleep mode the cpu halts. on-chip peripheral modules continue to operate on the system clock. subsleep mode the cpu halts. timer a, and timer g, continue to operate on the subclock. watch mode the cpu halts. the time-base function of timer a continues to operate on the subclock. standby mode the cpu and all on-chip peripheral modules stop operating in this section the two active modes (high-speed and medium-speed) are referred to collectively as active mode. 89
figure 5-1 shows the transitions among these operation modes. table 5-2 indicates the internal states in each mode. figure 5-1 operation mode transition diagram reset state program executing program execution stopped program execution stopped active (high-speed) mode power-down mode sleep instruction sleep instruction sleep instruction sleep instruction sleep instruction sleep instruction notes: timer a interrupt, irq interrupt, wkp to wkp interrupts timer a interrupt, timer g interrupt, irq 0 to irq 4 interrupts, wkp 0 to wkp 7 interrupts all interrupts 1. 2. 3. 4. 5. 007 01 07 2 * 1 * 5 * 4 * 4 * 5 * 3 * 3 * lson = 1, tma3 = 1 lson = 0, mson = 1 lson = 0, mson = 0 ssby = 0, lson = 1, tma3 = 1 ssby = 0, lson = 0 ssby = 1, tma3 = 0, lson = 0 ssby = 1, tma3 = 1 sleep instruction dton = 1 dton = 1 dton = 1 sleep instruction a transition between different modes cannot be made to occur simply because an interrupt request is generated. make sure that the interrupt is accepted and interrupt handling is performed. : transition caused by exception handling ? subsleep mode subactive mode watch mode active (medium-speed) mode standby mode details on the mode transition conditions are given in the explanations of each mode, in sections 5.2 through 5.8. sleep mode irq interrupt, irq interrupt, wkp to wkp interrupts and nmi interrupt timer a interrupt, irq 0 interrupt, wkp 0 to wkp 7 interrupts and nmi interrupt 90
table 5-2 internal state in each operation mode active mode high medium sleep watch subactive subsleep standby function speed speed mode mode mode mode mode system clock oscillator functional functional functional stopped stopped stopped stopped subclock oscillator functional functional functional functional functional functional functional instructions functional functional stopped stopped functional stopped stopped ram retained retained retained retained registers i/o retained * 1 nmi functional functional functional functional functional functional functional irq 0 irq 1 retained * 4 irq 2 retained * 4 irq 3 irq 4 wkp 0 functional functional functional functional functional functional functional wkp 1 wkp 2 wkp 3 wkp 4 wkp 5 wkp 6 wkp 7 timer a functional functional functional functional * 3 functional * 3 functional * 3 retained timer f retained retained retained timer g functional/ functional/ retained * 2 retained * 2 sci1 functional functional functional retained retained retained retained sci3 reset reset reset reset dtmf functional functional functional reset reset reset reset a/d functional functional functional retained retained retained retained multitone functional functional functional reset reset reset reset generator notes: 1. register contents held; high-impedance output. 2. functional only if w /2 internal clock is selected; otherwise stopped and retained. 3. functional when timekeeping time-base function is selected. 4. external interrupt requests are ignored. the interrupt request register contents are not affected. external interrupts cpu operation peripheral module functions 91
5.1.1 system control registers the operation mode is selected using the system control registers described in table 5-3. table 5-3 system control register name abbreviation r/w initial value address system control register 1 syscr1 r/w h'07 h'fff0 system control register 2 syscr2 r/w h'e0 h'fff1 1. system control register 1 (syscr1) syscr1 is an 8-bit read/write register for control of the power-down modes. upon reset, syscr1 is initialized to h'07. bit 7: software standby (ssby) this bit designates transition to standby mode or watch mode. bit 7 ssby description 0 when a sleep instruction is executed in active mode, a transition (initial value) is made to sleep mode. when a sleep instruction is executed in subactive mode, a transition is made to subsleep mode. 1 when a sleep instruction is executed in active mode, a transition is made to standby mode or watch mode. when a sleep instruction is executed in subactive mode, a transition is made to watch mode. bits 6 to 4: standby timer select 2 to 0 (sts2 to sts0) these bits designate the time the cpu and peripheral modules wait for stable clock operation after exiting from standby mode or watch mode to active mode due to an interrupt. the designation should be made according to the clock frequency so that the waiting time is at least 10 ms. bit initial value read/write 7 ssby 0 r/w 6 sts2 0 r/w 5 sts1 0 r/w 4 sts0 0 r/w 3 lson 0 r/w 0 1 2 1 1 1 92
bit 6 bit 5 bit 4 sts2 sts1 sts0 description 0 0 0 wait time = 8,192 states (initial value) 0 0 1 wait time = 16,384 states 0 1 0 wait time = 32,768 states 0 1 1 wait time = 65,536 states 1 ** wait time = 131,072 states note: * don? care bit 3: low speed on flag (lson) this bit chooses the system clock (? or subclock ( sub ) as the cpu operating clock when watch mode is cleared. the resulting operation mode depends on the combination of other control bits and interrupt input. bit 3 lson description 0 the cpu operates on the system clock (? (initial value) 1 the cpu operates on the subclock ( sub ) bits 2 to 0: reserved bits these bits are reserved; they are always read as 1, and cannot be modified. 2. system control register 2 (syscr2) syscr2 is an 8-bit read/write register for power-down mode control. upon reset, syscr2 is initialized to h'e0. bits 7 to 5: reserved bits these bits are reserved; they are always read as 1, and cannot be modified. bit initial value read/write 7 1 6 1 5 1 4 nesel 0 r/w 3 dton 0 r/w 0 sa0 0 r/w 2 mson 0 r/w 1 sa1 0 r/w 93
bit 4: noise elimination sampling frequency select (nesel) this bit selects the frequency at which the watch clock signal (? w ) generated by the subclock pulse generator is sampled, in relation to the oscillator clock (? osc ) generated by the system clock pulse generator. when ? osc = 2 to 10 mhz, clear nesel to 0. bit 4 nesel description 0 sampling rate is osc /16 (initial value) 1 sampling rate is osc /4 bit 3: direct transfer on flag (dton) this bit designates whether or not to make direct transitions among active (high-speed), active (medium-speed) and subactive mode when a sleep instruction is executed. the mode to which the transition is made after the sleep instruction is executed depends on a combination of this and other control bits. bit 3 dton description 0 when a sleep instruction is executed in active mode, a transition (initial value) is made to standby mode, watch mode, or sleep mode. when a sleep instruction is executed in subactive mode, a transition is made to watch mode or subsleep mode. 1 when a sleep instruction is executed in active (high-speed) mode, a direct transition is made to active (medium-speed) mode if ssby = 0, mson = 1, and lson = 0, or to subactive mode if ssby = 1, tma3 = 1, and lson = 1. when a sleep instruction is executed in active (medium-speed) mode, a direct transition is made to active (high-speed) mode if ssby = 0, mson = 0, and lson = 0, or to subactive mode if ssby = 1, tma3 = 1, and lson = 1. when a sleep instruction is executed in subactive mode, a direct transition is made to active (high-speed) mode if ssby = 1, tma3 = 1, lson = 0, and mson = 0, or to active (medium-speed) mode if ssby = 1, tma3 = 1, lson = 0, and mson = 1. bit 2: medium speed on flag (mson) after standby, watch, or sleep mode is cleared, this bit selects active (high-speed) or active (medium-speed) mode. bit 2 mson description 0 operation is in active (high-speed) mode (initial value) 1 operation is in active (medium-speed) mode 94
bits 1 and 0: subactive mode clock select (sa1 and sa0) these bits select the cpu clock rate (? w /2, ? w /4, or ? w /8) in subactive mode. sa1 and sa0 cannot be modified in subactive mode. bit 1 bit 0 sa1 sa0 description 00 w /8 (initial value) 01 w /4 1 * w /2 note: * don? care 5.2 sleep mode 5.2.1 transition to sleep mode the system goes from active mode to sleep mode when a sleep instruction is executed while the ssby and lson bits in system control register 1 (syscr1) are cleared to 0. in sleep mode cpu operation is halted but the on-chip peripheral functions are operational. the cpu register contents are retained. 5.2.2 clearing sleep mode sleep mode is cleared by an interrupt (timer a, timer f, timer g, nmi, irq 0 to irq 4 , wkp 0 to wkp 7 , sci1, sci3, a/d converter, multitone generator) or by input at the res pin. clearing by interrupt when an interrupt is requested, sleep mode is cleared and interrupt exception handling starts. operation resumes in active (high-speed) mode if mson = 0 in syscr2, or active (medium- speed) mode if mson = 1. sleep mode is not cleared if the i bit of the condition code register (ccr) is set to 1 or the particular interrupt is disabled in the interrupt enable register. clearing by res input when the res pin goes low, the cpu goes into the reset state and sleep mode is cleared. 95
5.3 standby mode 5.3.1 transition to standby mode the system goes from active mode to standby mode when a sleep instruction is executed while the ssby bit in syscr1 is set to 1, the lson bit is cleared to 0, and bit tma3 in timer register a (tma) is cleared to 0. in standby mode the clock pulse generator stops, so the cpu and on-chip peripheral modules stop functioning. as long as a minimum required voltage is applied, the cpu register contents and data in the on-chip ram will be retained. the i/o ports go to the high-impedance state. 5.3.2 clearing standby mode standby mode is cleared by an interrupt (nmi, irq 0 , irq 1 , wkp 0 to wkp 7 ) or by input at the res pin. clearing by interrupt when an interrupt is requested, the system clock pulse generator starts. after the time set in bits sts2ests0 in syscr1 has elapsed, a stable system clock signal is supplied to the entire chip, standby mode is cleared, and interrupt exception handling starts. operation resumes in active (high-speed) mode if mson = 0 in syscr2, or active (medium-speed) mode if mson = 1. standby mode is not cleared if the i bit of ccr is set to 1 or the particular interrupt is disabled in the interrupt enable register. clearing by res input when the res pin goes low, the system clock pulse generator starts and standby mode is cleared. after the pulse generator output has stabilized, if the res pin is driven high, the cpu starts reset exception handling. since system clock signals are supplied to the entire chip as soon as the system clock pulse generator starts functioning, the res pin should be kept at the low level until the pulse generator output stabilizes. 96
5.3.3 oscillator settling time after standby mode is cleared bits sts2 to sts0 in syscr1 should be set as follows. when a crystal oscillator is used table 5-4 gives settings for various operating frequencies. set bits sts2 to sts0 for a waiting time of at least 10 ms. when an external clock is used any values may be set. normally the minimum time (sts2 = sts1 = sts0 = 0) should be set. table 5-4 clock frequency and settling time (times are in ms) sts2 sts1 sts0 waiting time 5 mhz 4 mhz 2 mhz 1 mhz 0.5 mhz 0 0 0 8,192 states 1.6 2.0 4.1 8.2 16.4 0 0 1 16,384 states 3.2 4.1 8.2 16.4 32.8 0 1 0 32,768 states 6.6 8.2 16.4 32.8 65.5 0 1 1 65,536 states 13.1 16.4 32.8 65.5 131.1 1 ** 131,072 states 26.2 32.8 65.5 131.1 262.1 note: * don? care 97
5.4 watch mode 5.4.1 transition to watch mode the system goes from active or subactive mode to watch mode when a sleep instruction is executed while the ssby bit in syscr1 is set to 1 and bit tma3 in tma is set to 1. in watch mode, operation of on-chip peripheral modules other than timer a is halted. as long as a minimum required voltage is applied, the contents of cpu registers and some registers of the on- chip peripheral modules * , and the on-chip ram contents, are retained. i/o ports keep the same states as before the transition. note: * the contents of sci3, dtmf generator, and multi-tone generator registers are reset. 5.4.2 clearing watch mode watch mode is cleared by an interrupt (timer a, nmi, irq 0 , wkp 0 to wkp 7 ) or by a low input at the res pin. clearing by interrupt when watch mode is cleared by a timer a, irq 0 , or wkp 0 to wkp 7 interrupt request, the mode to which a transition is made depends on the settings of lson in syscr1 and mson in syscr2. if both lson and mson are cleared to 0, transition is to active (high-speed) mode; if lson = 0 and mson = 1, transition is to active (medium-speed) mode; if lson = 1, transition is to subactive mode. when watch mode is cleared by an nmi interrupt request, the transition is to active (high-speed) mode if mson = 0 or to active (medium-speed) mode if mson = 1, but never to subactive mode. when the transition is to active mode, after the time set in syscr1 bits sts2 to sts0 has elapsed, a stable clock signal is supplied to the entire chip, watch mode is cleared, and interrupt exception handling starts. watch mode is not cleared if the i bit of ccr is set to 1 or the particular interrupt is disabled in the interrupt enable register. clearing by res input clearing by res pin is the same as for standby mode; see 5.3.2, clearing standby mode. 5.4.3 oscillator settling time after watch mode is cleared the waiting time is the same as for standby mode; see 5.3.3, oscillator settling time after standby mode is cleared. 98
5.5 subsleep mode 5.5.1 transition to subsleep mode the system goes from subactive mode to subsleep mode when a sleep instruction is executed while the ssby bit in syscr1 is cleared to 0, lson is set to 1, and bit tma3 in tma is set to 1. in subsleep mode, operation of on-chip peripheral modules other than timer a and timer g is halted. as long as a minimum required voltage is applied, the contents of cpu registers and some registers of the on-chip peripheral modules * , and the on-chip ram contents, are retained. i/o ports keep the same states as before the transition. note: * the contents of sci3, dtmf generator, and multi-tone generator registers are reset. 5.5.2 clearing subsleep mode subsleep mode is cleared by an interrupt (timer a, timer g, nmi, irq 0 to irq 4 , wkp 0 to wkp 7 ) or by a low input at the res pin. clearing by interrupt when an interrupt is requested, subsleep mode is cleared and interrupt exception handling starts. subsleep mode is not cleared if the i bit of ccr is set to 1 or the particular interrupt is disabled in the interrupt enable register. clearing by res input clearing by res input is the same as for standby mode; see 5.3.2, clearing standby mode. 99
5.6 subactive mode 5.6.1 transition to subactive mode subactive mode is entered from watch mode if a timer a, irq 0 , or wkp 0 to wkp 7 interrupt is requested while the lson bit in syscr1 is set to 1. from subsleep mode, subactive mode is entered if a timer a, timer g, nmi, irq 0 to irq 4 , or wkp 0 to wkp 7 interrupt is requested. a transition to subactive mode does not take place if the i bit of ccr is set to 1 or the particular interrupt is disabled in the interrupt enable register. the contents of sci3, dtmf generator, and multi-tone generator registers are reset. 5.6.2 clearing subactive mode subactive mode is cleared by a sleep instruction or by a low input at the res pin. clearing by sleep instruction if a sleep instruction is executed while the ssby bit in syscr1 is set to 1 and bit tma3 in tma is set to 1, subactive mode is cleared and watch mode is entered. if a sleep instruction is executed while ssby = 0 and lson = 1 in syscr1 and tma3 = 1 in tma, subsleep mode is entered. direct transfer to active mode is also possible; see 5.8, direct transfer, below. clearing by res pin clearing by res pin is the same as for standby mode; see 5.3.2, clearing standby mode. 5.6.3 operating frequency in subactive mode the operating frequency in subactive mode is set in bits sa1 and sa0 in syscr2. the choices are ? w /2, ? w /4, and ? w /8. 100
5.7 active (medium-speed) mode 5.7.1 transition to active (medium-speed) mode if the mson bit in syscr2 is set to 1 while the lson bit in syscr1 is cleared to 0, a transition to active (medium-speed) mode results from nmi, irq 0 , irq 1 , or wkp 0 to wkp 7 interrupts in standby mode, timer a, nmi, irq 0 , or wkp 0 to wkp 7 interrupts in watch mode, or any interrupt in sleep mode. a transition to active (medium-speed) mode does not take place if the i bit of ccr is set to 1 or the particular interrupt is disabled in the interrupt enable register. 5.7.2 clearing active (medium-speed) mode active (medium-speed) mode is cleared by a sleep instruction or by a low input at the res pin. clearing by sleep instruction a transition to standby mode takes place if a sleep instruction is executed while the ssby bit in syscr1 is set to 1, the lson bit in syscr1 is cleared to 0, and bit tma3 in tma is cleared to 0. the system goes to watch mode if the ssby bit in syscr1 is set to 1 and bit tma3 in tma is set to 1 when a sleep instruction is executed. sleep mode is entered if both ssby and lson are cleared to 0 when a sleep instruction is executed. direct transfer to active (high-speed) mode or to subactive mode is also possible. see 5.8, direct transfer, below for details. clearing by res pin when the res pin goes low, the cpu enters the reset state and active (medium-speed) mode is cleared. 5.7.3 operating frequency in active (medium-speed) mode in active (medium-speed) mode, the cpu is clocked at 1/8 the frequency in active (high-speed) mode. the dtmf generator and multitone generator, however, continue to operate on the osc clock (? osc ). 101
5.8 direct transfer the cpu can execute programs in three modes: active (high-speed) mode, active (medium-speed) mode, and subactive mode. a direct transfer is a transition among these three modes without the stopping of program execution. a direct transfer can be made by executing a sleep instruction while the dton bit in syscr2 is set to 1. after the mode transition, direct transfer interrupt exception handling starts. if the direct transfer interrupt is disabled in interrupt enable register 2, a transition is made instead to sleep mode or watch mode. note that if a direct transition is attempted while the i bit in ccr is set to 1, sleep mode or watch mode will be entered, and it will be impossible to clear the resulting mode by means of an interrupt. direct transfer from active (high-speed) mode to active (medium-speed) mode when a sleep instruction is executed in active (high-speed) mode while the ssby and lson bits in syscr1 are cleared to 0, the mson bit in syscr2 is set to 1, and the dton bit in syscr2 is set to 1, a transition is made to active (medium-speed) mode via sleep mode. direct transfer from active (medium-speed) mode to active (high-speed) mode when a sleep instruction is executed in active (medium-speed) mode while the ssby and lson bits in syscr1 are cleared to 0, the mson bit in syscr2 is cleared to 0, and the dton bit in syscr2 is set to 1, a transition is made to active (high-speed) mode via sleep mode. direct transfer from active (high-speed) mode to subactive mode when a sleep instruction is executed in active (high-speed) mode while the ssby and lson bits in syscr1 are set to 1, the dton bit in syscr2 is set to 1, and bit tma3 in tma is set to 1, a transition is made to subactive mode via watch mode. direct transfer from subactive mode to active (high-speed) mode when a sleep instruction is executed in subactive mode while the ssby bit in syscr1 is set to 1, the lson bit in syscr1 is cleared to 0, the mson bit in syscr2 is cleared to 0, the dton bit in syscr2 is set to 1, and bit tma3 in tma is set to 1, a transition is made directly to active (high-speed) mode via watch mode after the waiting time set in syscr1 bits sts2 to sts0 has elapsed. 102
direct transfer from active (medium-speed) mode to subactive mode when a sleep instruction is executed in active (medium-speed) mode while the ssby and lson bits in syscr1 are set to 1, the dton bit in syscr2 is set to 1, and bit tma3 in tma is set to 1, a transition is made to subactive mode via watch mode. direct transfer from subactive mode to active (medium-speed) mode when a sleep instruction is executed in subactive mode while the ssby bit in syscr1 is set to 1, the lson bit in syscr1 is cleared to 0, the mson bit in syscr2 is set to 1, the dton bit in syscr2 is set to 1, and bit tma3 in tma is set to 1, a transition is made directly to active (medium-speed) mode via watch mode after the waiting time set in syscr1 bits sts2 to sts0 has elapsed. 103
section 6 rom 6.1 overview the h8/3877n has 60 kbytes of on-chip rom, while the h8/3876n has 48 kbytes and the h8/3875n has 40 kbytes. the rom is connected to the cpu by a 16-bit data bus, allowing high- speed 2-state access for both byte data and word data. 6.1.1 block diagram figure 6-1 shows a block diagram of the on-chip rom. figure 6-1 rom block diagram h'9ffe h'9fff internal data bus (upper 8 bits) internal data bus (lower 8 bits) even-numbered address odd-numbered address h'9ffe h'0002 h'0000 h'0000 h'0002 h'0001 h'0003 on-chip rom h'bffe h'bfff h'edfe h'edff 40 k h8/3875n 48 k h8/3876n 60 k h8/3877n h'bffe h'edfe 105
6.2 prom mode 6.2.1 selection of prom mode if the on-chip rom is prom, setting the chip to prom mode stops operation as a microcomputer and allows the on-chip prom to be programmed in the same way as the hn27c101, except that page programming is not supported. table 6-1 shows how to select prom mode. table 6-1 selection of prom mode pin name setting test high level pb 7 /an 7 low level pb 6 /an 6 pb 5 /an 5 high level 6.2.2 socket adapter pin arrangement and memory map a standard prom programmer can be used to program the prom. a socket adapter is required for conversion to 32 pins, as listed in table 6-2. figure 6-2 shows the pin-to-pin wiring of the socket adapter. figure 6-3 shows a memory map. table 6-2 socket adapter package socket adapter 100-pin (fp100b) hs3877esh01h 100-pin (fp100a) hs3877esf01h 100-pin (tfp100b) hs3877esn01h 106
figure 6-2 socket adapter pin correspondence h8/3877n eprom socket res p6 0 p6 1 p6 2 p6 3 p6 4 p6 5 p6 6 p6 7 p8 7 p8 6 p8 5 p8 4 p8 3 p8 2 p8 1 p8 0 p7 0 nmi p7 2 p7 3 p7 4 p7 5 p7 6 p1 4 p1 5 v cc av cc test x 1 pb 5 p1 1 p1 2 p1 6 v ss av ss pb 7 pb 6 hn27c101 (32 pins) 1 13 14 15 17 18 19 20 21 12 11 10 9 8 7 6 5 27 26 23 25 4 28 29 3 2 22 24 31 32 16 fp-100b tfp-100b 9 44 45 46 47 48 49 50 51 67 66 65 64 63 62 61 60 52 10 54 55 56 57 58 22 21 59 53 23 31, 76 89 3 5 96 25 24 20 6, 27 2 94 95 12 47 48 49 50 51 52 53 54 70 69 68 67 66 65 64 63 55 13 57 58 59 60 61 25 24 62 56 26 34, 79 92 6 8 99 28 27 23 9, 30 5 97 98 pin v pp eo 0 eo 1 eo 2 eo 3 eo 4 eo 5 eo 6 eo 7 ea 0 ea 1 ea 2 ea 3 ea 4 ea 5 ea 6 ea 7 ea 8 ea 9 ea 10 ea 11 ea 12 ea 13 ea 14 ce oe pgm v cc v ss note: pins not indicated in the figure should be left open. p7 7 p7 1 p1 3 ea 15 ea 16 pin fp-100a 107
figure 6-3 memory map in prom mode on-chip prom unused area h'0000 h'edff h'0000 h'edff h'1ffff address in mcu mode address in prom mode * note: * unpredictable data may be output if this area is read in prom mode. when programming with a prom programmer, be sure to specify addresses from h'0000 to h'edff. if h'ee00 and higher addresses are programmed by mistake, it may become impossible to program or verify the prom. when programming, specify h'ff for this address area (h'ee00 to h'1ffff). 108
6.3 programming the program, verify, and other modes are selected as shown in table 6-3 in prom mode. table 6-3 mode selection in prom mode pin mode ce oe pgm v pp v cc eo 7 to eo 0 ea 16 to ea 0 write l h l v pp v cc data input address input verify l l h v pp v cc data output address input lll v pp v cc high impedance address input lhh hl l hhh notation: l: low level h: high level v pp :v pp level v cc :v cc level the programming and verifying specifications in prom mode are the same as the specifications of the standard hn27c101 eprom. page programming is not supported, however. the prom programmer must not be set to page mode. prom programmers that support only page programming cannot be used. when selecting a prom programmer, make sure that it supports a byte-by-byte high-speed, high-reliability programming method. be sure to set the address range to h'0000 to h'edff. programming disabled 109
6.3.1 programming and verification an efficient, high-speed, high-reliability programming procedure can be used to program and verify data. this procedure programs the chip quickly without subjecting it to voltage stress and without sacrificing data reliability. figure 6-4 shows the basic high-speed, high-reliability programming flow chart. figure 6-4 high-speed, high-reliability programming flow chart start set program/verify mode v = 6.0 v ?0.25 v, v = 12.5 v ?0.3 v cc pp address = 0 n = 0 n + 1 n program with t = 0.2 ms ?% pw verification ok? overprogram with t = 0.2n ms opw last address? set read mode v = 5.0 v ?0.25 v, v = v cc pp cc all addresses read? end fail n 25 < address + 1 address no yes no yes yes no no yes 110
table 6-4 and table 6-5 give the electrical characteristics in programming mode. table 6-4 dc characteristics (preliminary) (conditions: v cc = 6.0 v ?.25 v, v pp = 12.5 v ?.3 v, v ss = 0 v, t a = 25? ??) test item symbol min typ max unit conditions input high- eo 7 to eo 0 , ea 16 to ea 0 v ih 2.4 v cc + 0.3 v level voltage oe, ce, pgm input low- eo 7 to eo 0 , ea 16 to ea 0 v il ?.3 0.8 v level voltage oe, ce, pgm output high- eo 7 to eo 0 v oh 2.4 v i oh = ?00 ? level voltage output low- eo 7 to eo 0 v ol 0.45 v i ol = 0.8 ma level voltage input leakage eo 7 to eo 0 , ea 16 to ea 0 |i li | 2 av in = 5.25 v/ current oe, ce, pgm 0.5 v v cc current i cc 40 ma v pp current i pp 40 ma 111
table 6-5 ac characteristics (preliminary) (conditions: v cc = 6.0 v ?.25 v, v pp = 12.5 v ?.3 v, t a = 25? ??) test item symbol min typ max unit conditions address setup time t as 2 s figure 6-5 * 1 oe setup time t oes 2 s data setup time t ds 2 s address hold time t ah 0 s data hold time t dh 2 s data output disable time t df * 2 130 ns v pp setup time t vps 2 s programming pulse width t pw 0.19 0.20 0.21 ms pgm pulse width for over- t opw * 3 0.19 5.25 ms programming v cc setup time t vcs 2 s ce setup time t ces 2 s data output delay time t oe 0 200 ns notes: 1. input pulse level: 0.45 v to 2.4 v input rise time/fall time 20 ns timing reference levels input: 0.8 v, 2.0 v output: 0.8 v, 2.0 v 2. t df is defined at the point at which the output is floating and the output level cannot be read. 3. t opw is defined by the value given in the hi-speed, hi-reliability programming flow chart in figure 6-4. 112
figure 6-5 shows a program/verify timing diagram. figure 6-5 prom program/verify timing address data v pp v cc ce pgm oe v pp v cc v cc v cc program verify input data output data t as t ds t vps t vcs t ces t pw t opw * t dh t oes t oe t df t ah note: * t opw is defined by the value given in the high-speed, high-reliability programming flow chart in figure 6-4. +1 113
6.3.2 programming precautions use the specified programming voltage and timing. the programming voltage in prom mode (v pp ) is 12.5 v. use of a higher voltage can permanently damage the chip. be especially careful with respect to prom programmer overshoot. setting the prom programmer to hitachi specifications for the hn27c101 will result in correct v pp of 12.5 v. make sure the index marks on the prom programmer socket, socket adapter, and chip are properly aligned. if they are not, the chip may be destroyed by excessive current flow. before programming, be sure that the chip is properly mounted in the prom programmer. avoid touching the socket adapter or chip while programming, since this may cause contact faults and write errors. select the programming mode carefully. the chip cannot be programmed in page programming mode. when programming with a prom programmer, be sure to specify addresses from h'0000 to h'edff. if address h'ee00 and higher addresses are programmed by mistake, it may become impossible to program the prom or verify the programmed data. when programming, assign h'ff data to the address area from h'ee00 to h'1ffff. 114
6.4 reliability of programmed data a highly effective way of assuring data retention characteristics after programming is to screen the chips by baking them at a temperature of 150?. this quickly eliminates prom memory cells causing initial data retention failure. figure 6-6 shows a flowchart of this screening procedure. figure 6-6 recommended screening procedure if write errors occur repeatedly while the same prom programmer is being used, stop programming and check for problems in the prom programmer and socket adapter, etc. please notify your hitachi representative of any problems occurring during programming or in screening after high-temperature baking. install write program and verify contents bake at high temperature with power off 125? to 150?, 24 hrs to 48 hrs read and check program 115
section 7 ram 7.1 overview the h8/3877n series has 2 kbytes of high-speed static ram on-chip. the ram is connected to the cpu by a 16-bit data bus, allowing high-speed 2-state access for both byte data and word data. 7.1.1 block diagram figure 7-1 shows a block diagram of the on-chip ram. figure 7-1 ram block diagram h'ff7e h'ff7f internal data bus (upper 8 bits) internal data bus (lower 8 bits) even-numbered address odd-numbered address h'ff7e h'f782 h'f780 h'f780 h'f782 h'f781 h'f783 on-chip ram 117
section 8 i/o ports 8.1 overview the h8/3877n series is provided with eight 8-bit i/o ports, two 4-bit i/o ports, and one 8-bit input-only port. table 8-1 indicates the functions of each port. each port has of a port control register (pcr) that controls input and output, and a port data register (pdr) for storing output data. input or output can be controlled by individual bits. see 2.9.2, notes on bit manipulation, for information on executing bit-manipulation instructions to write data in pcr or pdr. block diagrams of each port are given in appendix c. table 8-1 port functions function switching port description pins other functions register port 1 p1 7 to p1 5 / external interrupts 3 to 1 pmr1 irq 3 to irq 1 /tmif timer event input tmif tcrf p1 4 none p1 3 /tmig timer g input capture pmr1 p1 2 , p1 1 / timer f output compare pmr1 tmofh, tmofl p1 0 /tmow timer a clock output pmr1 port 2 p2 7 /irq 0 external interrupt 0 pmr2 p2 6 /txd sci3 data output (txd), data input scr3 p2 5 /rxd (rxd), clock input/output (sck3) smr3 p2 4 /sck 3 p2 3 /so 1 sci1 data output (so1), data input pmr2 p2 2 /si 1 (si1), clock input/output (sck1) p2 1 /sck 1 p2 0 /irq 4 / external interrupt 4 and a/d pmr2 adtrg converter external trigger ?8-bit i/o port ?input pull-up mos option ?8-bit i/o port input pull-up mos option 119
table 8-1 port functions (cont) function switching port description pins other functions register port 5 8-bit i/o port p5 7 to p5 0 / wakeup input (wkp 7 to wkp 0 ) pmr5 ?input pull-up mos wkp 7 to wkp 0 option port 6 8-bit i/o port p6 7 to p6 0 none ?input pull-up mos option port 7 8-bit i/o port p7 7 to p7 0 none port 8 8-bit i/o port p8 7 to p8 0 none port 9 8-bit i/o port p9 7 to p9 0 none port a 4-bit i/o port pa 3 to pa 0 none port b 8-bit input port pb 7 to pb 0 / a/d converter analog input amr an 7 to an 0 port d 8-bit i/o port pd 7 to pd 0 none port e 4-bit i/o port pe 3 to pe 0 none 120
8.2 port 1 8.2.1 overview port 1 is an 8-bit i/o port. figure 8-1 shows its pin configuration. figure 8-1 port 1 pin configuration 8.2.2 register configuration and description table 8-2 shows the port 1 register configuration. table 8-2 port 1 registers name abbrev. r/w initial value address port data register 1 pdr1 r/w h'00 h'ffd4 port control register 1 pcr1 w h'00 h'ffe4 port pull-up control register 1 pucr1 r/w h'00 h'ff9c port mode register 1 pmr1 r/w h'10 h'ff98 p1 7 /irq 3 /tmif p1 6 /irq 2 p1 5 /irq 1 p1 4 p1 3 /tmig p1 2 /tmofh p1 1 /tmofl p1 0 /tmow port 1 121
1. port data register 1 (pdr1) pdr1 is an 8-bit register that stores data for pins p1 7 to p1 0 of port 1. if port 1 is read while pcr1 bits are set to 1, the values stored in pdr1 are directly read, regardless of the actual pin states. if port 1 is read while pcr1 bits are cleared to 0, the pin states are read. upon reset, pdr1 is initialized to h'00. 2. port control register 1 (pcr1) pcr1 is an 8-bit register for controlling whether each of the port 1 pins p1 7 to p1 0 functions as an input pin or output pin. setting a pcr1 bit to 1 makes the corresponding pin an output pin, while clearing the bit to 0 makes the pin an input pin. the settings in pcr1 and in pdr1 are valid only when the corresponding pin is designated in pmr1 as a general i/o pin. upon reset, pcr1 is initialized to h'00. pcr1 is a write-only register. all bits are read as 1. 3. port pull-up control register 1 (pucr1) pucr1 controls whether the mos pull-up of each port 1 pin is on or off. when a pcr1 bit is cleared to 0, setting the corresponding pucr1 bit to 1 turns on the mos pull-up for the corresponding pin, while clearing the bit to 0 turns off the mos pull-up. upon reset, pucr1 is initialized to h'00. bit initial value read/write 7 p1 0 r/w 6 p1 0 r/w 5 p1 0 r/w 4 p1 0 r/w 3 p1 0 r/w 0 p1 0 r/w 2 p1 0 r/w 1 p1 0 r/w 76543210 bit initial value read/write 7 pcr1 0 w 6 pcr1 0 w 5 pcr1 0 w 4 pcr1 0 w 3 pcr1 0 w 0 pcr1 0 w 2 pcr1 0 w 1 pcr1 0 w 76543210 bit initial value read/write 7 pucr1 0 r/w 6 pucr1 0 r/w 5 pucr1 0 r/w 4 pucr1 0 r/w 3 pucr1 0 r/w 0 pucr1 0 r/w 2 pucr1 0 r/w 1 pucr1 0 r/w 76543210 122
4. port mode register 1 (pmr1) pmr1 is an 8-bit read/write register, controlling the selection of pin functions for port 1 pins. upon reset, pmr1 is initialized to h'10. bit 7: p1 7 /irq 3 /tmif pin function switch (irq3) this bit selects whether pin p1 7 /irq 3 /tmif is used as p1 7 or as irq 3 /tmif. bit 7 irq3 description 0 functions as p1 7 i/o pin (initial value) 1 functions as irq 3 /tmif input pin note: rising or falling edge sensing can be designated for irq 3 /tmif. for information about tmif pin settings, see 9.3.2 (3), timer control register f (tcrf). bit 6: p1 6 /irq 2 pin function switch (irq2) this bit selects whether pin p1 6 /irq 2 is used as p1 6 or as irq 2 . bit 6 irq2 description 0 functions as p1 6 i/o pin (initial value) 1 functions as irq 2 input pin note: rising or falling edge sensing can be designated for irq 2 . bit 5: p1 5 /irq 1 pin function switch (irq1) this bit selects whether pin p1 5 /irq 1 is used as p1 5 or as irq 1 . bit 5 irq1 description 0 functions as p1 5 i/o pin (initial value) 1 functions as irq 1 input pin note: rising or falling edge sensing can be designated for irq 1 . bit initial value read/write 7 irq3 0 r/w 6 irq2 0 r/w 5 irq1 0 r/w 4 1 3 tmig 0 r/w 0 tmow 0 r/w 2 tmofh 0 r/w 1 tmofl 0 r/w 123
bit 4: reserved bit bit 4 is reserved: it is always read as 1, and cannot be modified. bit 3: p1 3 /tmig pin function switch (tmig) this bit selects whether pin p1 3 /tmig is used as p1 3 or as tmig. bit 3 tmig description 0 functions as p1 3 i/o pin (initial value) 1 functions as tmig input pin bit 2: p1 2 /tmofh pin function switch (tmofh) this bit selects whether pin p1 2 /tmofh is used as p1 2 or as tmofh. bit 2 tmofh description 0 functions as p1 2 i/o pin (initial value) 1 functions as tmofh output pin bit 1: p1 1 /tmofl pin function switch (tmofl) this bit selects whether pin p1 1 /tmofl is used as p1 1 or as tmofl. bit 1 tmofl description 0 functions as p1 1 i/o pin (initial value) 1 functions as tmofl output pin bit 0: p1 0 /tmow pin function switch (tmow) this bit selects whether pin p1 0 /tmow is used as p1 0 or as tmow. bit 0 tmow descrition 0 functions as p1 0 i/o pin (initial value) 1 functions as tmow output pin 124
8.2.3 pin functions table 8-3 shows the port 1 pin functions. table 8-3 port 1 pin functions pin pin functions and selection method p1 7 /irq 3 / the pin function depends on bit irq3 in pmr1, bits cksl2 to cksl0 in tcrf, tmif and bit pcr1 7 in pcr1. irq3 0 1 pcr1 7 01 * cksl2 to cksl0 * not 0 ** 0 ** pin function p1 7 input p1 7 output irq 3 input irq 3 /tmif input note: when using this pin for tmif input, clear bit ien3 to 0 in ienr1 to disable irq 3 interrupts. p1 6 /irq 2 the pin function depends on bit irq2 in pmr1 and bit pcr1 6 in pcr1. irq2 0 1 pcr1 6 01 * pin function p1 6 input pin p1 6 output pin irq 2 iutput pin p1 5 /irq 1 the pin function depends on bit irq1 in pmr1 and bit pcr1 5 in pcr1. irq1 0 1 pcr1 5 01 * pin function p1 5 input pin p1 5 output pin irq 1 iutput pin p1 4 the pin function depends on bit pcr1 4 in pcr1. pcr1 4 01 pin function p1 4 input pin p1 4 output pin p1 3 /tmig the pin function depends on bit tmig in pmr1 and bit pcr1 3 in pcr1. tmig 0 1 pcr1 3 01 * pin function p1 3 input pin p1 3 output pin tmig input pin p1 2 /tmofh the pin function depends on bit tmofh in pmr1 and bit pcr1 2 in pcr1. tmofh 0 1 pcr1 2 01 * pin function p1 2 input pin p1 2 output pin tmofh output pin note: * don? care 125
table 8-3 port 1 pin functions (cont) pin pin functions and selection method p1 1 /tmofl the pin function depends on bit tmofl in pmr1 and bit pcr1 1 in pcr1. tmofl 0 1 pcr1 1 01 * pin function p1 1 input pin p1 1 output pin tmofl output pin p1 0 /tmow the pin function depends on bit tmow in pmr1 and bit pcr1 0 in pcr1. tmow 0 1 pcr1 0 01 * pin function p1 0 input pin p1 0 output pin tmow output pin note: * don? care 8.2.4 pin states table 8-4 shows the port 1 pin states in each operating mode. table 8-4 port 1 pin states pins reset sleep subsleep standby watch subactive active p1 7 /irq 3 /tmif high- retains retains high- retains functional functional p1 6 /irq 2 impedance previous previous impedance * previous p1 5 /irq 1 state state state p1 4 p1 3 /tmig p1 2 /tmofh p1 1 /tmofl p1 0 /tmow note: * a high-level signal is output when the mos pull-up is in the on state. 8.2.5 mos input pull-up port 1 has a built-in mos input pull-up function that can be controlled by software. when a pcr1 bit is cleared to 0, setting the corresponding pucr1 bit to 1 turns on the mos pull-up for that pin. the mos input pull-up function is in the off state after a reset. pcr1 n 01 pucr1 n 01 * mos input pull-up off on off note: * don? care (n = 7 to 0) 126
8.3 port 2 8.3.1 overview port 2 is an 8-bit i/o port. figure 8-2 shows its pin configuration. figure 8-2 port 2 pin configuration 8.3.2 register configuration and description table 8-5 shows the port 2 register configuration. table 8-5 port 2 registers name abbrev. r/w initial value address port data register 2 pdr2 r/w h'00 h'ffd5 port control register 2 pcr2 w h'00 h'ffe5 port mode register 2 pmr2 r/w h'40 h'ff99 port pull-up control register 2 pucr2 r/w h'00 h'ff9d p2 7 /irq 0 p2 6 /txd p2 5 /rxd p2 4 /sck 3 p2 3 /so 1 p2 2 /si 1 p2 1 /sck 1 p2 0 /irq 4 /adtrg port 2 127
1. port data register 2 (pdr2) pdr2 is an 8-bit register that stores data for pins p2 7 to p2 0 of port 2. if port 2 is read while pcr2 bits are set to 1, the values stored in pdr2 are directly read, regardless of the actual pin states. if port 2 is read while pcr2 bits are cleared to 0, the pin states are read. upon reset, pdr2 is initialized to h'00. 2. port control register 2 (pcr2) pcr2 is an 8-bit register for controlling whether each of the port 2 pins p2 7 to p2 0 functions as an input pin or output pin. setting a pcr2 bit to 1 makes the corresponding pin an output pin, while clearing the bit to 0 makes the pin an input pin. the settings in pcr2 and in pdr2 are valid only when the corresponding pin is designated in pmr2 as a general i/o pin. upon reset, pcr2 is initialized to h'00. pcr2 is a write-only register, which always reads all 1s. 3. port mode register 2 (pmr2) pmr2 is an 8-bit read/write register for controlling the selection of pin functions for pins p2 0 to p2 3 and p2 7 , controlling the pmos on/off option for pin p2 3 /so 1 , and controlling the tmig input noise canceller. upon reset, pmr2 is initialized to h'40. bit initial value read/write 7 p2 0 r/w 6 p2 0 r/w 5 p2 0 r/w 4 p2 0 r/w 3 p2 0 r/w 0 p2 0 r/w 2 p2 0 r/w 1 p2 0 r/w 76543210 bit initial value read/write 7 pcr2 0 w 6 pcr2 0 w 5 pcr2 0 w 4 pcr2 0 w 3 pcr2 0 w 0 pcr2 0 w 2 pcr2 0 w 1 pcr2 0 w 76543210 bit initial value read/write 7 irq0 0 r/w 6 1 5 pof1 0 r/w 4 ncs 0 r/w 3 so1 0 r/w 0 irq4 0 r/w 2 si1 0 r/w 1 sck1 0 r/w 128
bits 7: p2 7 /irq 0 pin function switch (irq0) this bit selects whether pin p2 7 /irq 0 is used as p2 7 or as irq 0 . bit 7 irq0 description 0 functions as p2 7 i/o pin (initial value) 1 functions as irq 0 input pin bit 6: reserved bit bit 6 is reserved: it is always read as 1, and cannot be modified. bit 5: p2 3 /so 1 pin pmos control (pof1) this bit turns on and off the pmos transistor in the p2 3 /so 1 pin output buffer. bit 5 pof1 description 0 cmos output (initial value) 1 nmos open-drain output bit 4: tmig noise canceller select (ncs) this bit controls the noise canceller circuit for input capture at pin tmig. bit 4 ncs description 0 noise canceller function not selected (initial value) 1 noise canceller function selected bit 3: p2 3 /so 1 pin function switch (so1) this bit selects whether pin p2 3 /so 1 is used as p2 3 or as so 1 . bit 3 so1 description 0 functions as p2 3 i/o pin (initial value) 1 functions as so 1 output pin 129
bit 2: p2 2 /si 1 pin function switch (si1) this bit selects whether pin p2 2 /si 1 is used as p2 2 or as si 1 . bit 2 si1 description 0 functions as p2 2 i/o pin (initial value) 1 functions as si 1 input pin bit 1: p2 1 /sck 1 pin function switch (sck1) this bit selects whether pin p2 1 /sck 1 is used as p2 1 or as sck 1 . bit 1 sck1 description 0 functions as p2 1 i/o pin (initial value) 1 functions as sck 1 i/o pin bit 0: p2 0 /irq 4 /adtrg pin function switch (irq4) this bit selects whether pin p2 0 /irq 4 is used as p2 0 or as irq 4 /adtrg. bit 0 irq4 description 0 functions as p2 0 i/o pin (initial value) 1 functions as irq 4 /adtrg input pin note: for information about adtrg pin settings, see 12.3.2, start of a/d conversion by external trigger input. 4. port pull-up control register 2 (pucr2) pucr2 controls whether the mos pull-up of each port 2 pin is on or off. when a pcr2 bit is cleared to 0, setting the corresponding pucr2 bit to 1 turns on the mos pull-up for the corresponding pin, while clearing the bit to 0 turns off the mos pull-up. upon reset, pucr2 is initialized to h'00. bit initial value read/write 7 pucr2 0 r/w 6 pucr2 0 r/w 5 pucr2 0 r/w 4 pucr2 0 r/w 3 pucr2 0 r/w 0 pucr2 0 r/w 2 pucr2 0 r/w 1 pucr2 0 r/w 76543210 130
8.3.3 pin functions table 8-6 shows the port 2 pin functions. table 8-6 port 2 pin functions pin pin functions and selection method p2 7 /irq 0 the pin function depends on bit irq0 in pcr2 and bit pcr2 7 in pcr2. irq0 0 1 pcr2 7 01 * pin function p2 7 input pin p2 7 output pin irq 0 input pin p2 6 /txd the pin function depends on bit te in scr of sci3 and bit pcr2 6 in pcr2. te 0 1 pcr2 6 01 * pin function p2 6 input pin p2 6 output pin txd output pin p2 5 /rxd the pin function depends on bit re in scr of sci3 and bit pcr2 5 in pcr2. re 0 1 pcr2 5 01 * pin function p2 5 input pin p2 5 output pin rxd input pin p2 4 /sck 3 the pin function depends on bits cke1 and cke0 in scr of sci3, bit com in smr of sci3, and bit pcr2 4 in pcr2. cke1 0 1 cke0 0 0 1 * com 0 1 ** pcr2 4 01 ** pin function p2 4 input pin p2 4 output pin sck 3 output pin sck 3 input pin p2 3 /so 1 the pin function depends on bit so1 in pmr2 and bit pcr2 3 in pcr2. so1 0 1 pcr2 3 01 * pin function p2 3 input pin p2 3 output pin so 1 output pin note: * don? care 131
table 8-6 port 2 pin functions (cont) pin pin functions and selection method p2 2 /si 1 the pin function depends on bit si1 in pmr2 and bit pcr2 2 in pcr2. si1 0 1 pcr2 2 01 * pin function p2 2 input pin p2 2 output pin si 1 input pin p2 1 /sck 1 the pin function depends on bit sck1 in pmr2, bit cks3 in scr1, and bit pcr2 1 in pcr2. sck1 0 1 cks3 * 01 pcr2 1 01 ** pin function p2 1 input pin p2 1 output pin sck 1 output pin sck 1 input pin p2 0 /irq 4 / the pin function depends on bit irq4 in pmr2, bit trge in amr, and bit adtrg pcr2 0 in pcr2. irq4 0 1 pcr2 0 01 * trge * 01 pin function p2 0 input p2 0 output irq 4 input irq 4 /adtrg input note: when using this pin for adtrg input, clear bit ien4 to 0 in ienr1 to disable irq 4 interrupts. note: * don? care 8.3.4 pin states table 8-7 shows the port 2 pin states in each operating mode. table 8-7 port 2 pin states pins reset sleep subsleep standby watch subactive active p2 7 /irq 0 high- retains retains high- retains functional functional p2 6 /txd impedance previous previous impedance previous p2 5 /rxd state * state state p2 4 /sck 3 p2 3 /so 1 p2 2 /si 1 p2 1 /sck 1 p2 0 /irq 4 /adtrg note: * high level output if the mos pull-up is on. 132
8.3.5 mos input pull-up port 2 has a built-in mos input pull-up function that can be controlled by software. when a pcr2 bit is cleared to 0, setting the corresponding pucr2 bit to 1 turns on the mos pull-up for that pin. the mos input pull-up function is in the off state after a reset. pcr2 n 01 pucr2 n 01 * mos input pull-up off on off note: * don? care (n = 7 to 0) 133
8.4 port 5 8.4.1 overview port 5 is an 8-bit i/o port, configured as shown in figure 8-3. figure 8-3 port 5 pin configuration 8.4.2 register configuration and description table 8-8 shows the port 5 register configuration. table 8-8 port 5 registers name abbrev. r/w initial value address port data register 5 pdr5 r/w h'00 h'ffd8 port control register 5 pcr5 w h'00 h'ffe8 port pull-up control register 5 pucr5 r/w h'00 h'ff9e port mode register 5 pmr5 r/w h'00 h'ff9b p5 /wkp p5 /wkp p5 /wkp p5 /wkp p5 /wkp p5 /wkp p5 /wkp p5 /wkp 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 port 5 134
1. port data register 5 (pdr5) pdr5 is an 8-bit register that stores data for port 5 pins p5 7 to p5 0 . if port 5 is read while pcr5 bits are set to 1, the values stored in pdr5 are directly read, regardless of the actual pin states. if port 5 is read while pcr5 bits are cleared to 0, the pin states are read. upon reset, pdr5 is initialized to h'00. 2. port control register 5 (pcr5) pcr5 is an 8-bit register for controlling whether each of the port 5 pins p5 7 to p5 0 functions as an input pin or output pin. setting a pcr5 bit to 1 makes the corresponding pin an output pin, while clearing the bit to 0 makes the pin an input pin. the settings in pcr5 and in pdr5 are valid only when the corresponding pin is designated as a general i/o pin in pmr5. upon reset, pcr5 is initialized to h'00. pcr5 is a write-only register. all bits are read as 1. 3. port pull-up control register 5 (pucr5) pucr5 controls whether the mos pull-up of each port 5 pin is on or off. when a pcr5 bit is cleared to 0, setting the corresponding pucr5 bit to 1 turns on the mos pull-up for the corresponding pin, while clearing the bit to 0 turns off the mos pull-up. upon reset, pucr5 is initialized to h'00. bit initial value read/write 7 p5 0 r/w 6 p5 0 r/w 5 p5 0 r/w 4 p5 0 r/w 3 p5 0 r/w 0 p5 0 r/w 2 p5 0 r/w 1 p5 0 r/w 76543210 bit initial value read/write 7 pcr5 0 w 6 pcr5 0 w 5 pcr5 0 w 4 pcr5 0 w 3 pcr5 0 w 0 pcr5 0 w 2 pcr5 0 w 1 pcr5 0 w 76543210 bit initial value read/write 7 pucr5 0 r/w 6 pucr5 0 r/w 5 pucr5 0 r/w 4 pucr5 0 r/w 3 pucr5 0 r/w 0 pucr5 0 r/w 2 pucr5 0 r/w 1 pucr5 0 r/w 76543210 135
4. port mode register 5 (pmr5) pmr5 is an 8-bit read/write register, controlling the selection of pin functions for port 5 pins. upon reset, pmr5 is initialized to h'00. bit n: p5 n /wkp n pin function switch (wkpn) this bit selects whether it is used as p5 n or as wkp n . bit n wkpn description 0 functions as p5 n i/o pin (initial value) 1 functions as wkp n input pin (n = 7 to 0) 8.4.3 pin functions table 8-9 shows the port 5 pin functions. table 8-9 port 5 pin functions pin pin functions and selection method p5 7 /wkp 7 the pin function depends on bit wkpn in pmr5 and bit pcr5 n in pcr5. to p5 0 /wkp 0 (n = 7 to 0) wkp n 01 pcr5 n 01 * pin function p5 n input pin p5 n output pin wkp n input pin note: * don? care bit initial value read/write 7 wkp7 0 r/w 6 wkp6 0 r/w 5 wkp5 0 r/w 4 wkp4 0 r/w 3 wkp3 0 r/w 0 wkp0 0 r/w 2 wkp2 0 r/w 1 wkp1 0 r/w 136
8.4.4 pin states table 8-10 shows the port 5 pin states in each operating mode. table 8-10 port 5 pin states pins reset sleep subsleep standby watch subactive active p5 7 /wkp 7 high- retains retains high- retains functional functional to p5 0 / impedance previous previous impedance * previous wkp 0 state state state note: * a high-level signal is output when the mos pull-up is in the on state. 8.4.5 mos input pull-up port 5 has a built-in mos input pull-up function that can be controlled by software. when a pcr5 bit is cleared to 0, setting the corresponding pucr5 bit to 1 turns on the mos pull-up for that pin. the mos pull-up function is in the off state after a reset. pcr5 n 01 pucr5 n 01 * mos input pull-up off on off note: * don? care (n = 7 to 0) 137
8.5 port 6 8.5.1 overview port 6 is an 8-bit i/o port, configured as shown in figure 8-4. figure 8-4 port 6 pin configuration 8.5.2 register configuration and description table 8-11 shows the port 6 register configuration. table 8-11 port 6 registers name abbrev. r/w initial value address port data register 6 pdr6 r/w h'00 h'ffd9 port control register 6 pcr6 w h'00 h'ffe9 port pull-up control register 6 pucr6 r/w h'00 h'ff9f p6 p6 p6 p6 p6 p6 p6 p6 7 6 5 4 3 2 1 0 port 6 138
1. port data register 6 (pdr6) pdr6 is an 8-bit register that stores data for port 6 pins p6 7 to p6 0 . if port 6 is read while pcr6 bits are set to 1, the values stored in pdr6 are directly read, regardless of the actual pin states. if port 6 is read while pcr6 bits are cleared to 0, the pin states are read. upon reset, pdr6 is initialized to h'00. 2. port control register 6 (pcr6) pcr6 is an 8-bit register for controlling whether each of the port 6 pins p6 7 to p6 0 functions as an input pin or output pin. setting a pcr6 bit to 1 makes the corresponding pin an output pin, while clearing the bit to 0 makes the pin an input pin. upon reset, pcr6 is initialized to h'00. pcr6 is a write-only register. all bits are read as 1. 3. port pull-up control register 6 (pucr6) pucr6 controls whether the mos pull-up of each port 6 pin is on or off. when a pcr6 bit is cleared to 0, setting the corresponding pucr6 bit to 1 turns on the mos pull-up for the corresponding pin, while clearing the bit to 0 turns off the mos pull-up. upon reset, pucr6 is initialized to h'00. bit initial value read/write 7 p6 0 r/w 6 p6 0 r/w 5 p6 0 r/w 4 p6 0 r/w 3 p6 0 r/w 0 p6 0 r/w 2 p6 0 r/w 1 p6 0 r/w 76543210 bit initial value read/write 7 pcr6 0 w 6 pcr6 0 w 5 pcr6 0 w 4 pcr6 0 w 3 pcr6 0 w 0 pcr6 0 w 2 pcr6 0 w 1 pcr6 0 w 76543210 bit initial value read/write 7 pucr6 0 r/w 6 pucr6 0 r/w 5 pucr6 0 r/w 4 pucr6 0 r/w 3 pucr6 0 r/w 0 pucr6 0 r/w 2 pucr6 0 r/w 1 pucr6 0 r/w 76543210 139
8.5.3 pin functions table 8-12 shows the port 6 pin functions. table 8-12 port 6 pin functions pin pin functions and selection method p6 7 to p6 0 the pin function depends on bit pcr6 n in pcr6. (n = 7 to 0) pcr6 n 01 pin function p6 n input pin p6 n output pin 8.5.4 pin states table 8-13 shows the port 6 pin states in each operating mode. table 8-13 port 6 pin states pins reset sleep subsleep standby watch subactive active p6 7 to p6 0 high- retains retains high- retains functional functional impedance previous previous impedance * previous state state state note: * a high-level signal is output when the mos pull-up is in the on state. 8.5.5 mos input pull-up port 6 has a built-in mos input pull-up function that can be controlled by software. when a pcr6 bit is cleared to 0, setting the corresponding pucr6 bit to 1 turns on the mos pull-up for that pin. the mos pull-up function is in the off state after a reset. pcr6 n 01 puc6 n 01 * mos input pull-up off on off note: * don? care (n = 7 to 0) 140
8.6 port 7 8.6.1 overview port 7 is an 8-bit i/o port, configured as shown in figure 8-5. figure 8-5 port 7 pin configuration 8.6.2 register configuration and description table 8-14 shows the port 7 register configuration. table 8-14 port 7 registers name abbrev. r/w initial value address port data register 7 pdr7 r/w h'00 h'ffda port control register 7 pcr7 w h'00 h'ffea p7 p7 p7 p7 p7 p7 p7 p7 7 6 5 4 3 2 1 0 port 7 141
1. port data register 7 (pdr7) pdr7 is an 8-bit register that stores data for port 7 pins p7 7 to p7 0 . if port 7 is read while pcr7 bits are set to 1, the values stored in pdr7 are directly read, regardless of the actual pin states. if port 7 is read while pcr7 bits are cleared to 0, the pin states are read. upon reset, pdr7 is initialized to h'00. 2. port control register 7 (pcr7) pcr7 is an 8-bit register for controlling whether each of the port 7 pins p7 7 to p7 0 functions as an input pin or output pin. setting a pcr7 bit to 1 makes the corresponding pin an output pin, while clearing the bit to 0 makes the pin an input pin. upon reset, pcr7 is initialized to h'00. pcr7 is a write-only register. all bits are read as 1. bit initial value read/write 7 p7 0 r/w 6 p7 0 r/w 5 p7 0 r/w 4 p7 0 r/w 3 p7 0 r/w 0 p7 0 r/w 2 p7 0 r/w 1 p7 0 r/w 76543210 bit initial value read/write 7 pcr7 0 w 6 pcr7 0 w 5 pcr7 0 w 4 pcr7 0 w 3 pcr7 0 w 0 pcr7 0 w 2 pcr7 0 w 1 pcr7 0 w 76543210 142
8.6.3 pin functions table 8-15 shows the port 7 pin functions. table 8-15 port 7 pin functions pin pin functions and selection method p7 7 to p7 0 the pin function depends on bit pcr7 n in pcr7. (n = 7 to 0) pcr7 n 01 pin function p7 n input pin p7 n output pin 8.6.4 pin states table 8-16 shows the port 7 pin states in each operating mode. table 8-16 port 7 pin states pins reset sleep subsleep standby watch subactive active p7 7 to p7 0 high- retains retains high- retains functional functional impedance previous previous impedance previous state state state 143
8.7 port 8 8.7.1 overview port 8 is an 8-bit i/o port configured as shown in figure 8-6. figure 8-6 port 8 pin configuration 8.7.2 register configuration and description table 8-17 shows the port 8 register configuration. table 8-17 port 8 registers name abbrev. r/w initial value address port data register 8 pdr8 r/w h'00 h'ffdb port control register 8 pcr8 w h'00 h'ffeb p8 p8 p8 p8 p8 p8 p8 p8 7 6 5 4 3 2 1 0 port 8 144
1. port data register 8 (pdr8) pdr8 is an 8-bit register that stores data for port 8 pins p8 7 to p8 0 . if port 8 is read while pcr8 bits are set to 1, the values stored in pdr8 are directly read, regardless of the actual pin states. if port 8 is read while pcr8 bits are cleared to 0, the pin states are read. upon reset, pdr8 is initialized to h'00. 2. port control register 8 (pcr8) pcr8 is an 8-bit register for controlling whether each of the port 8 pins p8 7 to p8 0 functions as an input or output pin. setting a pcr8 bit to 1 makes the corresponding pin an output pin, while clearing the bit to 0 makes the pin an input pin. upon reset, pcr8 is initialized to h'00. pcr8 is a write-only register. all bits are read as 1. bit initial value read/write 7 p8 0 r/w 6 p8 0 r/w 5 p8 0 r/w 4 p8 0 r/w 3 p8 0 r/w 0 p8 0 r/w 2 p8 0 r/w 1 p8 0 r/w 76543210 bit initial value read/write 7 pcr8 0 w 6 pcr8 0 w 5 pcr8 0 w 4 pcr8 0 w 3 pcr8 0 w 0 pcr8 0 w 2 pcr8 0 w 1 pcr8 0 w 76543210 145
8.7.3 pin functions table 8-18 gives the port 8 pin functions. table 8-18 port 8 pin functions pin pin functions and selection method p8 7 to p8 0 the pin function depends on bit pcr8 n in pcr8. (n = 7 to 0) pcr8 n 01 pin function p8 n input pin p8 n output pin 8.7.4 pin states table 8-19 shows the port 8 pin states in each operating mode. table 8-19 port 8 pin states pins reset sleep subsleep standby watch subactive active p8 7 to p8 0 high- retains retains high- retains functional functional impedance previous previous impedance previous state state state 146
8.8 port 9 8.8.1 overview port 9 is an 8-bit i/o port configured as shown in figure 8-7. figure 8-7 port 9 pin configuration 8.8.2 register configuration and description table 8-20 shows the port 9 register configuration. table 8-20 port 9 registers name abbrev. r/w initial value address port data register 9 pdr9 r/w h'00 h'ffdc port control register 9 pcr9 w h'00 h'ffec p9 p9 p9 p9 p9 p9 p9 p9 7 6 5 4 3 2 1 0 port 9 147
1. port data register 9 (pdr9) pdr9 is an 8-bit register that stores data for port 9 pins p9 7 to p9 0 . if port 9 is read while pcr9 bits are set to 1, the values stored in pdr9 are directly read, regardless of the actual pin states. if port 9 is read while pcr9 bits are cleared to 0, the pin states are read. upon reset, pdr9 is initialized to h'00. 2. port control register 9 (pcr9) pcr9 is an 8-bit register for controlling whether each of the port 9 pins p9 7 to p9 0 functions as an input or output pin. setting a pcr9 bit to 1 makes the corresponding pin an output pin, while clearing the bit to 0 makes the pin an input pin. upon reset, pcr9 is initialized to h'00. pcr9 is a write-only register. all bits are read as 1. bit initial value read/write 7 p9 0 r/w 6 p9 0 r/w 5 p9 0 r/w 4 p9 0 r/w 3 p9 0 r/w 0 p9 0 r/w 2 p9 0 r/w 1 p9 0 r/w 76543210 bit initial value read/write 7 pcr9 0 w 6 pcr9 0 w 5 pcr9 0 w 4 pcr9 0 w 3 pcr9 0 w 0 pcr9 0 w 2 pcr9 0 w 1 pcr9 0 w 76543210 148
8.8.3 pin functions table 8-21 gives the port 9 pin functions. table 8-21 port 9 pin functions pin pin functions and selection method p9 7 to p9 0 the pin function depends on bit pcr9 n in pcr9. (n = 7 to 0) pcr9 n 01 pin function p9 n input pin p9 n output pin 8.8.4 pin states table 8-22 shows the port 9 pin states in each operating mode. table 8-22 port 9 pin states pins reset sleep subsleep standby watch subactive active p9 7 to p9 0 high- retains retains high- retains functional functional impedance previous previous impedance previous state state state 149
8.9 port a 8.9.1 overview port a is a 4-bit i/o port configured as shown in figure 8-8. figure 8-8 port a pin configuration 8.9.2 register configuration and description table 8-23 shows the port a register configuration. table 8-23 port a registers name abbrev. r/w initial value address port data register a pdra r/w h'f0 h'ffdd port control register a pcra w h'f0 h'ffed pa pa pa pa 3 2 1 0 port a 150
1. port data register a (pdra) pdra is an 8-bit register that stores data for port a pins pa 3 to pa 0 . if port a is read while pcra bits are set to 1, the values stored in pdra are directly read, regardless of the actual pin states. if port a is read while pcra bits are cleared to 0, the pin states are read. upon reset, pdra is initialized to h'f0. 2. port control register a (pcra) pcra is an 8-bit register for controlling whether each of the port a pins pa 3 to pa 0 functions as an input or output pin. setting a pcra bit to 1 makes the corresponding pin an output pin, while clearing the bit to 0 makes the pin an input pin. upon reset, pcra is initialized to h'f0. pcra is a write-only register. all bits are read as 1. bit initial value read/write 7 1 6 1 5 1 4 1 3 pa 0 r/w 0 pa 0 r/w 2 pa 0 r/w 1 pa 0 r/w 32 1 0 bit initial value read/write 7 1 6 1 5 1 4 1 3 pcra 0 w 0 pcra 0 w 2 pcra 0 w 1 pcra 0 w 210 3 151
8.9.3 pin functions table 8-24 gives the port a pin functions. table 8-24 port a pin functions pin pin functions and selection method pa 3 to pa 0 the pin function depends on bit pcra 3 in pcra. pcra n 01 pin function pa n input pin pa n output pin 8.9.4 pin states table 8-25 shows the port a pin states in each operating mode. table 8-25 port a pin states pins reset sleep subsleep standby watch subactive active pa 3 to pa 0 high- retains retains high- retains functional functional impedance previous previous impedance previous state state state 152
8.10 port b 8.10.1 overview port b is an 8-bit input-only port configured as shown in figure 8-9. figure 8-9 port b pin configuration 8.10.2 register configuration and description table 8-26 shows the port b register configuration. table 8-26 port b register name abbrev. r/w address port data register b pdrb r h'ffde port data register b (pdrb) reading pdrb always gives the pin states. however, if a port b pin is selected as an analog input channel for the a/d converter by amr bits ch3 to ch0, that pin reads 0 regardless of the input voltage. pb /an pb /an pb /an pb /an pb /an pb /an pb /an pb /an 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 port b bit read/write 7 pb r 6 pb r 5 pb r 4 pb r 3 pb r 0 pb r 2 pb r 1 pb r 32 1 0 7654 153
8.11 port d 8.11.1 overview port d is an 8-bit i/o port, configured as shown in figure 8-10. figure 8-10 port d pin configuration 8.11.2 register configuration and description table 8-27 shows the port d register configuration. table 8-27 port d registers name abbrev. r/w initial value address port data register d pdrd r/w h'00 h'ffd2 port control register d pcrd w h'00 h'ffe2 1. port data register d (pdrd) pdrd is an 8-bit register that stores data for port d pins pd 7 to pd 0 . if port d is read while pcrd bits are set to 1, the values stored in pdrd are directly read, regardless of the actual pin states. if port d is read while pcrd bits are cleared to 0, the pin states are read. upon reset, pdrd is initialized to h'00. pd pd pd pd pd pd pd pd 7 6 5 4 3 2 1 0 port d 7 pd 0 r/w 6 pd 0 r/w 5 pd 0 r/w 4 pd 0 r/w 3 pd 0 r/w 0 pd 0 r/w 2 pd 0 r/w 1 pd 0 r/w 32 1 0 bit initial value read/write 7654 154
2. port control register d (pcrd) pcrd is an 8-bit register for controlling whether each of the port d pins pd 7 to pd 0 functions as an input pin or output pin. setting a pcrd bit to 1 makes the corresponding pin an output pin, while clearing the bit to 0 makes the pin an input pin. upon reset, pcrd is initialized to h'00. pcrd is a write-only register. all bits are read as 1. 8.11.3 pin functions table 8-28 shows the port d pin functions. table 8-28 port d pin functions pin pin functions and selection method pd 7 to pd 0 the pin function depends on bit pcrd n in pcrd. (n = 7 to 0) pcrd n 01 pin function pd n input pin pd n output pin 8.11.4 pin states table 8-29 shows the port d pin states in each operating mode. table 8-29 port d pin states pin reset sleep subsleep standby watch subactive active pd 7 to pd 0 high- retains retains high- retains functional functional impedance previous previous impedance previous state state state 7 pcrd 0 r/w 6 pcrd 0 r/w 5 pcrd 0 r/w 4 pcrd 0 r/w 3 pcrd 0 r/w 0 pcrd 0 r/w 2 pcrd 0 r/w 1 pcrd 0 r/w 3210 bit initial value read/write 7654 155
8.12 port e 8.12.1 overview port e is a 4-bit i/o port, configured as shown in figure 8-11. figure 8-11 port e pin configuration 8.12.2 register configuration and description table 8-30 shows the port e register configuration. table 8-30 port e registers name abbrev. r/w initial value address port data register e pdre r/w h'f0 h'ffd3 port control register e pcre w h'f0 h'ffe3 1. port data register e (pdre) pdre is a 4-bit register that stores data for port e pins pe 3 to pe 0 . if port e is read while pcre bits are set to 1, the values stored in pdre are directly read, regardless of the actual pin states. if port e is read while pcre bits are cleared to 0, the pin states are read. upon reset, pdre is initialized to h'f0. pe pe pe pe 3 2 1 0 port e 7 1 6 1 5 1 4 1 3 pe 0 r/w 0 pe 0 r/w 2 pe 0 r/w 1 pe 0 r/w 3210 bit initial value read/write 156
2. port control register e (pcre) pcre is a 4-bit register for controlling whether each of the port e pins pe 3 to pe 0 functions as an input pin or output pin. setting a pcre bit to 1 makes the corresponding pin an output pin, while clearing the bit to 0 makes the pin an input pin. upon reset, pcre is initialized to h'f0. pcre is a write-only register. all bits are read as 1. 8.12.3 pin functions table 8-31 shows the port e pin functions. table 8-31 port e pin functions pin pin functions and selection method pe 3 to pe 0 the pin function depends on bit pcre 3 in pcre. pcre 3 01 pin function pe 3 input pin pe 3 output pin 8.12.4 pin states table 8-32 shows the port e pin states in each operating mode. table 8-32 port e pin states pin reset sleep subsleep standby watch subactive active pe 3 to pe 0 high- retains retains high- retains functional functional impedance previous previous impedance previous state state state 7 1 6 1 5 1 4 1 3 pcre 0 w 0 pcre 0 w 2 pcre 0 w 1 pcre 0 w 3210 bit initial value read/write 157
section 9 timers 9.1 overview the h8/3877n series provides three timers (timers a, f, and g) on-chip. table 9-1 outlines the functions of timers a, f, and g. table 9-1 timer functions event waveform name functions internal clock input pin output pin remarks timer a 8-bit timer ?8 to ?8192 interval timer (8 choices) time base w /128 (choice of 4 overflow periods) clock output ?4 to ?32, tmow w /4 to w /32 (8 choices) timer f 16-bit free-running timer ?2 to ?32 tmif tmofl event counter (4 choices) tmofh can be used as two independent 8-bit timers output compare timer g 8-bit timer ?2 to ?64, w /2 tmig counter clear input capture (4 choices) designation interval timer possible built-in noise canceller circuit for input capture 159
9.2 timer a 9.2.1 overview timer a is an 8-bit timer with interval timing and real-time clock time-base functions. the clock time-base function is available when a 32.768-khz crystal oscillator is connected. a clock signal divided from 32.768 khz or from the system clock can be output at the tmow pin. 1. features features of timer a are given below. choice of eight internal clock sources (?8192, ?4096, ?2048, ?512, ?256, ?128, ?32, ?8). choice of four overflow periods (1 s, 0.5 s, 0.25 s, 31.25 ms) when timer a is used as a clock time base (using a 32.768 khz crystal oscillator). an interrupt is requested when the counter overflows. any of eight clock signals can be output from pin tmow: 32.768 khz divided by 32, 16, 8, or 4 (1 khz, 2 khz, 4 khz, 8 khz), or the system clock divided by 32, 16, 8, or 4. 160
2. block diagram figure 9-1 shows a block diagram of timer a. figure 9-1 block diagram of timer a 3. pin configuration table 9-2 shows the timer a pin configuration. table 9-2 pin configuration name abbrev. i/o function clock output tmow output output of waveform generated by timer a output circuit psw internal data bus pss notation: tmow 1/4 tma tca ? /32 ? /16 ? /8 ? /4 w w w w ?32 ?16 ?8 ?4 ? /128 w ?8192, ?4096, ?2048, ?512, ?256, ?128, ?32, ?8 irrta 8 64 128 256 * * * * ? /4 w tma: tca: irrta: psw: pss: note: can be selected only when the prescaler w output (? /128) is used as the tca input clock. timer mode register a timer counter a timer a overflow interrupt request flag prescaler w prescaler s w w ? ? ? 161
4. register configuration table 9-3 shows the register configuration of timer a. table 9-3 timer a registers name abbrev. r/w initial value address timer mode register a tma r/w h'10 h'ffb0 timer counter a tca r h'00 h'ffb1 9.2.2 register descriptions 1. timer mode register a (tma) tma is an 8-bit read/write register for selecting the prescaler, input clock, and output clock. upon reset, tma is initialized to h'10. bits 7 to 5: clock output select (tma7 to tma5) bits 7 to 5 choose which of eight clock signals is output at the tmow pin. the system clock divided by 32, 16, 8, or 4 can be output in active mode and sleep mode. a 32.768 khz signal divided by 32, 16, 8, or 4 can be output in active mode, sleep mode, and subactive mode. bit 7 bit 6 bit 5 tma7 tma6 tma5 clock output 0 0 0 ?32 (initial value) 1 ?16 1 0 ?8 1 ?4 100 w /32 1 w /16 10 w /8 1 w /4 bit initial value read/write 7 tma7 0 r/w 6 tma6 0 r/w 5 tma5 0 r/w 4 1 3 tma3 0 r/w 0 tma0 0 r/w 2 tma2 0 r/w 1 tma1 0 r/w 162
bit 4: reserved bit bit 4 is reserved; it is always read as 1, and cannot be modified. bits 3 to 0: internal clock select (tma3 to tma0) bits 3 to 0 select the clock input to tca. the selection is made as follows. description bit 3 bit 2 bit 1 bit 0 prescaler and divider ratio tma3 tma2 tma1 tma0 or overflow period function 0000 pss, ?8192 (initial value) interval timer 1 pss, ?4096 1 0 pss, ?2048 1 pss, ?512 1 0 0 pss, ?256 1 pss, ?128 1 0 pss, ?32 1 pss, ?8 1000 psw, 1 s 1 psw, 0.5 s 1 0 psw, 0.25 s 1 psw, 0.03125 s 1 0 0 psw and tca are reset 1 10 1 clock time base 163
2. timer counter a (tca) tca is an 8-bit read-only up-counter, which is incremented by internal clock input. the clock source for input to this counter is selected by bits tma3 to tma0 in timer mode register a (tma). tca values can be read by the cpu in active mode, but cannot be read in subactive mode. when tca overflows, the irrta bit in interrupt request register 1 (irr1) is set to 1. tca is cleared by setting bits tma3 and tma2 of tma to 11. upon reset, tca is initialized to h'00. 9.2.3 timer operation 1. interval timer operation when bit tma3 in timer mode register a (tma) is cleared to 0, timer a functions as an 8-bit interval timer. upon reset, tca is cleared to h'00 and bit tma3 is cleared to 0, so up-counting and interval timing resume immediately. the clock input to timer a is selected by bits tma2 to tma0 in tma; any of eight internal clock signals output by prescaler s can be selected. after the count value in tca reaches h'ff, the next clock signal input causes timer a to overflow, setting bit irrta to 1 in interrupt request register 1 (irr1). if ienta = 1 in interrupt enable register 1 (ienr1), a cpu interrupt is requested.* at overflow, tca returns to h'00 and starts counting up again. in this mode timer a functions as an interval timer that generates an overflow output at intervals of 256 input clock pulses. note: * for details on interrupts, see 3.3, interrupts. bit initial value read/write 7 tca7 0 r 6 tca6 0 r 5 tca5 0 r 4 tca4 0 r 3 tca3 0 r 0 tca0 0 r 2 tca2 0 r 1 tca1 0 r 164
2. real-time clock time base operation when bit tma3 in tma is set to 1, timer a functions as a real-time clock time base by counting clock signals output by prescaler w. the overflow period of timer a is set by bits tma1 and tma0 in tma. a choice of four periods is available. in time base operation (tma3 = 1), setting bit tma2 to 1 clears both tca and prescaler w to their initial values of h'00. 3. clock output setting bit tmow in port mode register 1 (pmr1) to 1 causes a clock signal to be output at pin tmow. eight different clock output signals can be selected by means of bits tma7 to tma5 in tma. the system clock divided by 32, 16, 8, or 4 can be output in active mode and sleep mode. a 32.768 khz signal divided by 32, 16, 8, or 4 can be output in active mode, sleep mode, and subactive mode. 9.2.4 timer a operation states table 9-4 summarizes the timer a operation states. table 9-4 timer a operation states sub- sub- operation mode reset active sleep watch active sleep standby tca interval reset functions functions halted halted halted halted clock time base reset functions functions functions functions functions halted tma reset functions retained retained functions retained retained note: when real-time clock time-base functions are selected as the internal clock of tca in active mode or sleep mode, the internal clock is not synchronous with the system clock, so it is synchronized by a synchronizing circuit. this may result in a maximum error of 1/?(s) in the count cycle. 165
9.3 timer f 9.3.1 overview timer f is a 16-bit timer with an output compare function. compare match signals can be used to reset the counter, request an interrupt, or toggle the output. timer f can also be used for external event counting, and can operate as two independent 8-bit timers, timer fh and timer fl. 1. features features of timer f are given below. choice of four internal clock sources (?32, ?16, ?4, ?2) or an external clock (can be used as an external event counter). output from pin tmofh is toggled by one compare match signal (the initial value of the toggle output can be set). counter can be reset by the compare match signal. two interrupt sources: counter overflow and compare match. can operate as two independent 8-bit timers (timer fh and timer fl) in 8-bit mode. timer fh 8-bit timer (clocked by timer fl overflow signals when timer f operates as a 16-bit timer). choice of four internal clocks (?32, ?16, ?4, ?2). output from pin tmofh is toggled by one compare match signal (the initial value of the toggle output can be set). counter can be reset by the compare match signal. two interrupt sources: counter overflow and compare match. timer fl 8-bit timer/event counter choice of four internal clocks (?32, ?16, ?4, ?2) or event input at pin tmif. output from pin tmofl is toggled by one compare match signal (the initial value of the toggle output can be set). counter can be reset by the compare match signal. two interrupt sources: counter overflow and compare match. 166
2. block diagram figure 9-2 shows a block diagram of timer f. figure 9-2 block diagram of timer f pss internal data bus compare circuit ocrfh toggle circuit toggle circuit match notation: tcrf: tcsrf: tcfh: tcfl: ocrfh: ocrfl: timer control register f timer control status register f 8-bit timer counter fh 8-bit timer counter fl output compare register fh output compare register fl irrtfh: irrtfl: pss: timer fh interrupt request flag timer fl interrupt request flag prescaler s irrtfh irrtfl tmif tmofl tmofh tcfl tcrf ocrfl tcfh compare circuit tcsrf 167
3. pin configuration table 9-5 shows the timer f pin configuration. table 9-5 pin configuration name abbrev. i/o function timer f event input tmif input event input to tcfl timer fh output tmofh output timer fh toggle output timer fl output tmofl output timer fl toggle output 4. register configuration table 9-6 shows the register configuration of timer f. table 9-6 timer f registers name abbrev. r/w initial value address timer control register f tcrf w h'00 h'ffb6 timer control/status register f tcsrf r/w h'00 h'ffb7 8-bit timer counter fh tcfh r/w h'00 h'ffb8 8-bit timer counter fl tcfl r/w h'00 h'ffb9 output compare register fh ocrfh r/w h'ff h'ffba output compare register fl ocrfl r/w h'ff h'ffbb 9.3.2 register descriptions 1. 16-bit timer counter (tcf) 8-bit timer counter (tcfh) 8-bit timer counter (tcfl) bit initial value read/write 15 0 r/w 14 0 r/w 13 0 r/w 12 0 r/w 11 0 r/w 10 0 r/w 9 0 r/w 8 0 r/w 7 0 r/w 6 0 r/w 5 0 r/w 4 0 r/w 3 0 r/w 2 0 r/w 1 0 r/w 0 0 r/w tcfh tcfl tcf 168
tcf is a 16-bit read/write up-counter consisting of two cascaded 8-bit timer counters, tcfh and tcfl. tcf can be used as a 16-bit counter, with tcfh as the upper 8 bits and tcfl as the lower 8 bits of the counter, or tcfh and tcfl can be used as independent 8-bit counters. tcfh and tcfl can be read and written by the cpu, but in 16-bit mode, data transfer with the cpu takes place via a temporary register (temp). for details see 9.3.3, interface with the cpu. upon reset, tcfh and tcfl are each initialized to h'00. 16-bit mode (tcf) 16-bit mode is selected by clearing bit cksh2 to 0 in timer control register f (tcrf). the tcf input clock is selected by tcrf bits cksl2 to cksl0. timer control status register f (tcsrf) can be set so that counter tcf will be cleared by compare match. when tcf overflows from h'ffff to h'0000, the overflow flag (ovfh) in tcsrf is set to 1. if bit ovieh in tcsrf is set to 1 when an overflow occurs, bit irrtfh in interrupt request register 2 (irr2) will be set to 1; and if bit ientfh in interrupt enable register 2 (ienr2) is set to 1, a cpu interrupt will be requested. 8-bit mode (tcfh, tcfl) when bit cksh2 in timer control register f (tcrf) is set to 1, timer f functions as two separate 8-bit counters, tcfh and tcfl. the tcfh (tcfl) input clock is selected by tcrf bits cksh2 to cksh0 (cksl2 to cksl0). tcfh (tcfl) can be cleared by a compare match signal. this designation is made in bit cclrh (cclrl) in tcsrf. when tcfh (tcfl) overflows from h'ff to h'00, the overflow flag ovfh (ovfl) in tcsrf is set to 1. if bit ovieh (oviel) in tcsrf is set to 1 when an overflow occurs, bit irrtfh (irrthl) in interrupt request register 2 (irr2) will be set to 1; and if bit ientfh (ientfl) in interrupt enable register 2 (ienr2) is set to 1, a cpu interrupt will be requested. 169
2. 16-bit output compare register (ocrf) 8-bit output compare register (ocrfh) 8-bit output compare register (ocrfl) ocrf is a 16-bit read/write output compare register consisting of two 8-bit read/write registers ocrfh and ocrfl. it can be used as a 16-bit output compare register, with ocrfh as the upper 8 bits and ocrfl as the lower 8 bits of the register, or ocrfh and ocrfl can be used as independent 8-bit registers. ocrfh and ocrfl can be read and written by the cpu, but in 16-bit mode, data transfer with the cpu takes place via a temporary register (temp). for details see 9.3.3, interface with the cpu. upon reset, ocrfh and ocrfl are each initialized to h'ff. 16-bit mode (ocrf) 16-bit mode is selected by clearing bit cksh2 to 0 in timer control register f (tcrf). the ocrf contents are always compared with the 16-bit timer counter (tcf). when the contents match, the compare match flag (cmfh) in tcsrf is set to 1. also, irrtfh in interrupt request register 2 (irr2) is set to 1. if bit ientfh in interrupt enable register 2 (ienr2) is set to 1, a cpu interrupt is requested. output for pin tmofh can be toggled by compare match. the output level can also be set to high or low by bit tolh of timer control register f (tcrf). 8-bit mode (ocrfh, ocrfl) setting bit cksh2 in tcrf to 1 results in two 8-bit independent registers, ocrfh and ocrfl. the ocrfh contents are always compared with tcfh, and the ocrfl contents are always compared with tcfl. when the contents match, the compare match flag (cmfh or cmfl) in tcsrf is set to 1. also, bit irrtfh (irrtfl) in interrupt request register 2 (irr2) set to 1. if bit ientfh (ientfl) in interrupt enable register 2 (ienr2) is set to 1 at this time, a cpu interrupt is requested. bit initial value read/write 15 1 r/w 14 1 r/w 13 1 r/w 12 1 r/w 11 1 r/w 10 1 r/w 9 1 r/w 8 1 r/w 7 1 r/w 6 1 r/w 5 1 r/w 4 1 r/w 3 1 r/w 2 1 r/w 1 1 r/w 0 1 r/w ocrfh ocrfl ocrf 170
the output at pin tmofh (tmofl) can be toggled by compare match. the output level can also be set to high or low by bit tolh (toll) of the timer control register (tcrf). 3. timer control register f (tcrf) tcrf is an 8-bit write-only register. it is used to switch between 16-bit mode and 8-bit mode, to select among four internal clocks and an external event, and to select the output level at pins tmofh and tmofl. upon reset, tcrf is initialized to h'00. bit 7: toggle output level h (tolh) bit 7 sets the output level at pin tmofh. the setting goes into effect immediately after this bit is written. bit 7 tolh description 0 low level (initial value) 1 high level bits 6 to 4: clock select h (cksh2 to cksh0) bits 6 to 4 select the input to tcfh from four internal clock signals or the overflow of tcfl. bit 6 bit 5 bit 4 cksh2 cksh1 cksh0 description 0 ** 16-bit mode selected. tcfl overflow signals are (initial value) counted. 1 0 0 internal clock: ?32 1 0 1 internal clock: ?16 1 1 0 internal clock: ?4 1 1 1 internal clock: ?2 note: * don? care bit initial value read/write 7 tolh 0 w 6 cksh2 0 w 5 cksh1 0 w 4 cksh0 0 w 3 toll 0 w 0 cksl0 0 w 2 cksl2 0 w 1 cksl1 0 w 171
bit 3: toggle output level l (toll) bit 3 sets the output level at pin tmofl. the setting goes into effect immediately after this bit is written. bit 3 toll description 0 low level (initial value) 1 high level bits 2 to 0: clock select l (cksl2 to cksl0) bits 2 to 0 select the input to tcfl from four internal clock signals or external event input. bit 2 bit 1 bit 0 cksl2 cksl1 cksl0 description 0 ** external event (tmif). rising or falling edge is (initial value) counted (see note). 1 0 0 internal clock: ?32 1 0 1 internal clock: ?16 1 1 0 internal clock: ?4 1 1 1 internal clock: ?2 * don? care note: the edge of the external event signal is selected by bit ieg3 in the irq edge select register (iegr). see 3.3.2, interrupt control registers, for details on the irq edge select register. note that switching the tmif pin function by changing bit irq3 in port mode register 1 (pmr1) from 0 to 1 or from 1 to 0 while the tmif pin is at the low level may cause the timer f counter to be incremented. 4. timer control/status register f (tcsrf) tcsrf is an 8-bit read/write register. it is used for counter clear selection, overflow and compare match indication, and enabling of interrupts caused by timer overflow. upon reset, tcsrf is initialized to h'00. bit initial value read/write 7 ovfh 0 r/w 6 cmfh 0 r/w 5 ovieh 0 r/w 4 cclrh 0 r/w 3 ovfl 0 r/w 0 cclrl 0 r/w 2 cmfl 0 r/w 1 oviel 0 r/w 172
bit 7: timer overflow flag h (ovfh) bit 7 is a status flag indicating tcfh overflow (h'ff to h'00). this flag is set by hardware and cleared by software. it cannot be set by software. bit 7 ovfh description 0 clearing conditions: (initial value) after reading ovfh = 1, cleared by writing 0 to ovfh 1 setting conditions: set when the value of tcfh goes from h'ff to h'00 bit 6: compare match flag h (cmfh) bit 6 is a status flag indicating a compare match between tcfh and ocrfh. this flag is set by hardware and cleared by software. it cannot be set by software. bit 6 cmfh description 0 clearing conditions: (initial value) after reading cmfh = 1, cleared by writing 0 to cmfh 1 setting conditions: set when the tcfh value matches ocrfh value bit 5: timer overflow interrupt enable h (ovieh) bit 5 enables or disables tcfh overflow interrupts. bit 5 ovieh description 0 tcfh overflow interrupt disabled (initial value) 1 tcfh overflow interrupt enabled 173
bit 4: counter clear h (cclrh) in 16-bit mode, bit 4 selects whether or not tcf is cleared when a compare match occurs between tcf and ocrf. in 8-bit mode, bit 4 selects whether or not tcfh is cleared when a compare match occurs between tcfh and ocrfh. bit 4 cclrh description 0 16-bit mode: tcf clearing by compare match disabled (initial value) 8-bit mode: tcfh clearing by compare match disabled 1 16-bit mode: tcf clearing by compare match enabled 8-bit mode: tcfh clearing by compare match enabled bit 3: timer overflow flag l (ovfl) bit 3 is a status flag indicating tcfl overflow (h'ff to h'00). this flag is set by hardware and cleared by software. it cannot be set by software. bit 3 ovfl description 0 clearing conditions: (initial value) after reading ovfl = 1, cleared by writing 0 to ovfl 1 setting conditions: set when the value of tcfl goes from h'ff to h'00 bit 2: compare match flag l (cmfl) bit 2 is a status flag indicating a compare match between tcfl and ocrfl. this flag is set by hardware and cleared by software. it cannot be set by software. bit 2 cmfl description 0 clearing conditions: (initial value) after reading cmfl = 1, cleared by writing 0 to cmfl 1 setting conditions: set when the tcfl value matches the ocrfl value 174
bit 1: timer overflow interrupt enable l (oviel) bit 1 enables or disables tcfl overflow interrupts. bit 1 oviel description 0 tcfl overflow interrupt disabled (initial value) 1 tcfl overflow interrupt enabled bit 0: counter clear l (cclrl) bit 0 selects whether or not tcfl is cleared when a compare match occurs between tcfl and ocrfl. bit 0 cclrl description 0 tcfl clearing by compare match disabled (initial value) 1 tcfl clearing by compare match enabled 9.3.3 interface with the cpu tcf and ocrf are 16-bit read/write registers, whereas the data bus between the cpu and on-chip peripheral modules has an 8-bit width. for this reason, when the cpu accesses tcf or ocrf, it makes use of an 8-bit temporary register (temp). in 16-bit mode, when reading or writing tcf or writing ocrf, always use two consecutive byte size mov instructions, and always access the upper byte first. data will not be transferred properly if only the upper byte or only the lower byte is accessed. in 8-bit mode there is no such restriction on the order of access. write access when the upper byte is written, the upper-byte data is loaded into the temp register. next when the lower byte is written, the data in temp goes to the upper byte of the register, and the lower- byte data goes directly to the lower byte of the register. figure 9-3-2 shows a tcf write operation when h'aa55 is written to tcf. 175
read access when the upper byte of tcf is read, the upper-byte data is sent directly to the cpu, and the lower byte is loaded into temp. next when the lower byte is read, the lower byte in temp is sent to the cpu. when the upper byte of ocrf is read, the upper-byte data is sent directly to the cpu. next when the lower byte is read, the lower-byte data is sent directly to the cpu. figure 9-4 shows a tcf read operation when h'aaff is read from tcf. 176
figure 9-3 tcf write operation (cpu ? tcf) bus interface cpu (h'aa) temp (h'aa) tcfh ( ) tcfl ( ) internal data bus when writing the upper byte bus interface cpu (h'55) temp (h'aa) tcfh (h'aa) tcfl (h'55) internal data bus when writing the lower byte 177
figure 9-4 tcf read operation (tcf ? cpu) bus interface cpu (h'aa) temp (h'ff) tcfh (h'aa) tcfl (h'ff) internal data bus when reading the upper byte bus interface cpu (h'ff) temp (h'ff) tcfh (ab) tcfl (00) internal data bus when reading the lower byte ** note: becomes h'ab00 if counter is incremented once. * 178
9.3.4 timer operation timer f is a 16-bit timer/counter that increments with each input clock. when the value set in output compare register f matches the count in timer f, the timer can be cleared, an interrupt can be requested, and the port output can be toggled. timer f can also be used as two independent 8-bit timers. 1. timer f operation timer f can operate in either 16-bit timer mode or 8-bit timer mode. these modes are described below. 16-bit timer mode timer f operates in 16-bit timer mode when the cksh2 bit in timer control register f (tcrf) is cleared to 0. a reset initializes timer counter f (tcf) to h'0000, output compare register f (ocrf) to h'ffff, and timer control register f (tcrf) and timer control status register f (tcsrf) to h'00. timer f begins counting external event input signals (tmif). the edge of the external event signal is selected by the ieg3 bit in the irq edge select register (iegr). the operational clock of timer f can be selected by setting bits cskl2 through cksl0 in tcrf, from four internal clocks output from prescaler s as well as from an external clock. tcf is continuously compared with the contents of ocrf. when these two values match, the cmfh bit in tcsrf is set to 1. at this time if ientfh of ienr2 is 1, a cpu interrupt is requested and the output at pin tmofh is toggled. if the cclrh bit in tcsrf is 1, tcf is cleared. the output at pin tmofh can also be set by the tolh bit in tcrf. if timer f overflows (from h'ffff to h'0000), the ovfh bit in tcsrf is set to 1. at this time, if the ovieh bit in tcsrf and the ientfh bit in ienr2 are both 1, cpu interrupt is requested. 179
8-bit timer mode when the cksh2 bit in tcrf is set to 1, timer f operates as two independent 8-bit timers, tcfh and tcfl. the input clock of tcfh/tcfl is selected by bits cksh2 to cksh0/cksl2 to cksl0 in tcrf. when tcfh/tcfl and the contents of ocrfh/ocrfl match, the cmfh/cmfl bit in tcsrf is set to 1. if the ientfh/ientfl bit in ienr2 is 1, a cpu interrupt is requested and the output at pin tmofh/tmofl is toggled. if the cclrh/cclrl bit in tcrf is 1, tcfh/tcfl is cleared. the output at pin tmofh/tmofl can also be set by the tolh/toll bit in tcrf. when tcfh/tcfl overflows from h'ff to h'00, the ovfh/ovfl bit in tcsrf is set to 1. at this time, if the ovieh/oviel bit in tcsrf and the ientfh/ientfl bit in ienr2 are both 1, a cpu interrupt is requested. 2. tcf count timing tcf is incremented by each pulse of the input clock (internal clock or external event). internal clock the settings of bits cksh2 to cksh0 or bits cksl2 to cksl0 in tcrf select one of four internal clock signals (?32, ?16, ?4, or ?2) divided from the system clock (?. external event external event input is selected by clearing bit cksl2 to 0 in tcrf. either rising or falling edges of the clock input can be counted. the edge is selected by bit ieg3 in iegr. an external clock pulse width of at least two system clock cycles (? is necessary; otherwise the counter will not operate properly. 180
3. tmofh and tmofl output timing the outputs at pins tmofh and tmofl are the values set in bits tolh and toll in tcrf. when a compare match occurs, the output value is inverted. figure 9-5 shows the output timing. figure 9-5 tmofh, tmofl output timing 4. tcf clear timing tcf can be cleared at compare match with ocrf. 5. timer overflow flag (ovf) set timing ovf is set to 1 when tcf overflows (goes from h'ffff to h'0000). 6. compare match flag set timing the compare match flags (cmfh or cmfl) are set to 1 when a compare match occurs between tcf and ocrf. a compare match signal is generated in the final state in which the values match (when tcf changes from the matching count value to the next value). when tcf and ocrf match, a compare match signal is not generated until the next counter clock pulse. tmif (when ieg3 = 1) count input clock tcf ocrf compare match signal tmofh, tmofl n n + 1 n n + 1 nn 181
7. timer f operation states table 9-7 summarizes the timer f operation states. table 9-7 timer f operation states sub- sub- operation mode reset active sleep watch active sleep standby tcf reset functions functions halted halted halted halted ocrf reset functions retained retained retained retained retained tcrf reset functions retained retained retained retained retained tcsrf reset functions retained retained retained retained retained 9.3.5 application notes the following conflicts can arise in timer f operation. 1. 16-bit timer mode the output at pin tmofh toggles when all 16 bits match and a compare match signal is generated. if the compare match signal occurs at the same time as new data is written in tcrf by a mov instruction, however, the new value written in bit tolh will be output at pin tmofh. the tmofl output in 16-bit mode is indeterminate, so this output should not be used. use the pin as a general input or output port. if an ocrfl write occurs at the same time as a compare match signal, the compare match signal is inhibited. if a compare match occurs between the written data and the counter value, however, a compare match signal will be generated at that point. the compare match signal is output in synchronization with the tcfl clock, so if this clock is stopped no compare match signal will be generated, even if a compare match occurs. compare match flag cmfh is set when all 16 bits match and a compare match signal is generated; bit cmfl is set when the setting conditions are met for the lower 8 bits. the overflow flag (ovfh) is set when tcf overflows; bit ovfl is set if the setting conditions are met when the lower 8 bits overflow. if a write to tcfl occurs at the same time as an overflow signal, the overflow signal is not output. 182
2. 8-bit timer mode tcfh and ocrfh the output at pin tmofh toggles when there is a compare match. if the compare match signal occurs at the same time as new data is written in tcrf by a mov instruction, however, the new value written in bit tolh will be output at pin tmofh. if an ocrfh write occurs at the same time as a compare match signal, the compare match signal is inhibited. if a compare match occurs between the written data and the counter value, however, a compare match signal will be generated at that point. the compare match signal is output in synchronization with the tcfh clock. if a tcfh write occurs at the same time as an overflow signal, the overflow signal is not output. tcfl and ocrfl the output at pin tmofl toggles when there is a compare match. if the compare match signal occurs at the same time as new data is written in tcrf by a mov instruction, however, the new value written in bit toll will be output at pin tmofl. if an ocrfl write occurs at the same time as a compare match signal, the compare match signal is inhibited. if a compare match occurs between the written data and the counter value, however, a compare match signal will be generated at that point. the compare match signal is output in synchronization with the tcfl clock, so if this clock is stopped no compare match signal will be generated, even if a compare match occurs. if a tcfl write occurs at the same time as an overflow signal, the overflow signal is not output. 183
9.4 timer g 9.4.1 overview timer g is an 8-bit timer, with input capture/interval functions for separately capturing the rising edge and falling edge of pulses input at the input capture pin (input capture input signal). timer g has a built-in noise canceller circuit that can eliminate high-frequency noise from the input capture signal, enabling accurate measurement of its duty cycle. when timer g is not used for input capture, it functions as an 8-bit interval timer. 1. features features of timer g are given below. choice of four internal clock sources (?64, ?32, ?2, w /2) input capture function separate input capture functions are provided for the rising and falling edges. counter overflow detection can detect whether overflow occurred when the input capture signal was high or low. choice of counter clear triggers the counter can be cleared at the rising edge, falling edge, or both edges of the input capture signal. two interrupt sources interrupts can be requested by input capture and by overflow. for input capture, the rising or falling edge can be selected. built-in noise-canceller circuit the noise canceller circuit can eliminate high-frequency noise in the input capture signal. operates in subactive and subsleep modes when w /2 is selected as the internal clock source, timer g can operate in the subactive and subsleep modes. 184
2. block diagram figure 9-6 shows a block diagram of timer g. figure 9-6 block diagram of timer g 3. pin configuration table 9-8 shows the timer g pin configuration. table 9-8 pin configuration name abbrev. i/o function input capture input pin tmig input input capture notation: pss tmg icrgf tcg icrgr irrtg internal data bus level sense circuit noise canceller circuit edge sense circuit ? /2 tmig ncs w tmg: tcg: icrgf: icrgr: irrtg: ncs: pss: timer mode register g timer counter g input capture register gf input capture register gr timer g interrupt request flag noise canceller select prescaler s 185
4. register configuration table 9-9 shows the register configuration of timer g. table 9-9 timer g registers name abbrev. r/w initial value address timer mode register g tmg r/w h'00 h'ffbc timer counter g tcg h'00 input capture register gf icrgf r h'00 h'ffbd input capture register gr icrgr r h'00 h'ffbe 9.4.2 register descriptions 1. timer counter g (tcg) timer counter g (tcg) is an 8-bit up-counter which is incremented by an input clock. the input clock signal is selected by bits cks1 and cks0 in timer mode register g (tmg). to use tcg as an input capture timer, set bit tmig to 1 in pmr1; to use tcg as an interval timer, clear bit tmig to 0.* when tcg is used as an input capture timer, the tcg value can be cleared at the rising edge, falling edge, or both edges of the input capture signal, depending on settings in tmg. when tcg overflows (goes from h'ff to h'00), if the timer overflow interrupt enable bit (ovie) is set to 1 in tmg, bit irrtg in interrupt request register 2 (irr2) is set to 1. if in addition bit ientg in interrupt enable register 2 (ienr2) is set to 1, a cpu interrupt is requested. details on interrupts are given in 3.3, interrupts. tcg cannot be read or written by the cpu. upon reset, tcg is initialized to h'00. note: * an input capture signal may be generated when tmig is rewritten. bit initial value read/write 7 tcg7 0 6 tcg6 0 5 tcg5 0 4 tcg4 0 3 tcg3 0 0 tcg0 0 2 tcg2 0 1 tcg1 0 186
2. input capture register gf (icrgf) icrgf is an 8-bit read-only register. when the falling edge of the input capture signal is detected, the tcg value at that time is transferred to icrgf. if the input capture interrupt select bit (iiegs) is set to 1 in tmg, bit irrtg in interrupt request register 2 (irr2) is set to 1. if in addition bit ientg in interrupt enable register 2 (ienr2) is set to 1, a cpu interrupt is requested. details on interrupts are given in 3.3, interrupts. to ensure proper input capture when the noise canceller is not used, the pulse width of the input capture signal should be at least 2?or 2 sub . upon reset, icrgf is initialized to h'00. 3. input capture register gr (icrgr) icrgr is an 8-bit read-only register. when the rising edge of the input capture signal is detected, the tcg value at that time is sent to icrgr. if the iiegs bit is cleared to 0 in tmg, bit irrtg in interrupt request register 2 (irr2) is set to 1. if in addition bit ientg in interrupt enable register 2 (ienr2) is set to 1, a cpu interrupt is requested. details on interrupts are given in 3.3, interrupts. to ensure proper input capture when the noise canceller is not used, the pulse width of the input capture signal should be at least 2?or 2 sub . upon reset, icrgr is initialized to h'00. bit initial value read/write 7 icrgf7 0 r 5 icrgf5 0 r 4 icrgf4 0 r 3 icrgf3 0 r 0 icrgf0 0 r 2 icrgf2 0 r 1 icrgf1 0 r 6 icrgf6 0 r bit initial value read/write 7 icrgr7 0 r 5 icrgr5 0 r 4 icrgr4 0 r 3 icrgr3 0 r 0 icrgr0 0 r 2 icrgr2 0 r 1 icrgr1 0 r 6 icrgr6 0 r 187
4. timer mode register g (tmg) note: * only 0 can be written, to clear flag. tmg is an 8-bit read/write register. it controls the choice of four input clocks, counter clear selection, and edge selection for input capture interrupt requests. it also indicates overflow status and enables or disables overflow interrupt requests. upon reset, tmg is initialized to h'00. bit 7: timer overflow flag h (ovfh) bit 7 is a status flag indicating that tcg overflowed (from h'ff to h'00) when the input capture signal was high. this flag is set by hardware and cleared by software. it cannot be set by software. bit 7 ovfh description 0 clearing conditions: (initial value) after reading ovfh = 1, cleared by writing 0 to ovfh 1 setting conditions: set when the value of tcg overflows from h'ff to h'00 bit 6: timer overflow flag l (ovfl) bit 6 is a status flag indicating that tcg overflowed (from h'ff to h'00) when the input capture signal was low, or in interval timer operation. this flag is set by hardware and cleared by software. it cannot be set by software. bit 6 ovfl description 0 clearing conditions: (initial value) after reading ovfl = 1, cleared by writing 0 to ovfl 1 setting conditions: set when the value of tcg overflows from h'ff to h'00 bit initial value read/write 7 ovfh 0 r/w 5 ovie 0 r/w 4 iiegs 0 r/w 3 cclr1 0 r/w 0 cks0 0 r/w 2 cclr0 0 r/w 1 cks1 0 r/w 6 ovfl 0 r/w ** 188
bit 5: timer overflow interrupt enable (ovie) bit 5 enables or disables tcg overflow interrupts. bit 5 ovie description 0 tcg overflow interrupt disabled (initial value) 1 tcg overflow interrupt enabled bit 4: input capture interrupt edge select (iiegs) bit 4 selects the input signal edge at which input capture interrupts are requested. bit 4 iiegs description 0 interrupts are requested at the rising edge of the input capture signal (initial value) 1 interrupts are requested at the falling edge of the input capture signal bits 3, 2: counter clear 1, 0 (cclr1, cclr0) bits 3 and 2 designate whether tcg is cleared at the rising, falling, or both edges of the input capture signal, or is not cleared. bit 3 bit 2 cclr1 cclr0 description 0 0 tcg is not cleared (initial value) 0 1 tcg is cleared at the falling edge of the input capture signal 1 0 tcg is cleared at the rising edge of the input capture signal 1 1 tcg is cleared at both edges of the input capture signal bits 1, 0: clock select (cks1, cks0) bits 1 and 0 select the clock input to tcg from four internal clock signals. bit 1 bit 0 cks1 cks0 description 0 0 internal clock: ?64 (initial value) 0 1 internal clock: ?32 1 0 internal clock: ?2 1 1 internal clock: w /2 189
9.4.3 noise canceller circuit the noise canceller circuit built into the h8/3877 series is a digital low-pass filter that rejects high-frequency pulse noise in the input at the input capture pin. the noise canceller circuit is enabled by the noise canceller select (ncs) bit in port mode register 2 (pmr2)*. figure 9-7 shows a block diagram of the noise canceller circuit. figure 9-7 block diagram of noise canceller circuit the noise canceller consists of five latch circuits connected in series, and a match detection circuit. when the noise canceller function is disabled (ncs = 0), the system clock is selected as the sampling clock. when the noise canceller is enabled (ncs = 1), the internal clock selected by bits cks1 and cks0 in tmg becomes the sampling clock. the input signal is sampled at the rising edge of this clock pulse. data is considered correct when the outputs of all five latch circuits match. if they do not match, the previous value is retained. upon reset, the noise canceller output is initialized after the falling edge of the input capture signal has been sampled five times. accordingly, after the noise canceller function is enabled, pulses that have a pulse width five times greater than the sampling clock will be recognized as input capture signals. if the noise canceller circuit is not used, the input capture signal pulse width must be at least 2?or 2 sub in order to ensure proper input capture operation. input capture signal sampling clock match detection circuit noise canceller output t: selected by bits cks1, cks0. sampling clock c latch d q c latch d q c latch d q c latch d q c latch d q d t d 190
note: rewriting the ncs bit may cause an internal input capture signal to be generated. figure 9-8 shows a typical timing diagram for the noise canceller circuit. in this example, a high- level input at the input capture pin is rejected as noise because its pulse width is less than five sampling clock ?cycles. figure 9-8 noise canceller circuit timing (example) 9.4.4 timer operation 1. timer g functions timer g is an 8-bit up-counter that functions as an input capture timer or an interval timer. these two functions are described below. input capture timer operation timer g functions as an input capture timer when bit tmig of port mode register 1 (pmr1) is set to 1.* at reset, timer mode register g (tmg), timer counter g (tcg), input capture register gf (icrgf), and input capture register gr (icrgr) are all initialized to h'00. immediately after reset, tcg begins counting an internal clock with a frequency of ?divided by 64 (?64). the clock to be input can be selected by using bits cks1 and cks0 in tmg from four internal clock sources. at the rising edge/falling edge of the input capture signal input to pin tmig, the value of tcg is copied into icrgr/icrgf. if the input edge is the same as the edge selected by the iiegs bit of tmg, then bit irrtg is set to 1 in irr2. if bit ientg is also set to 1 in ienr2, a cpu interrupt is requested. for details on interrupts, see 3.3, interrupts. input capture input signal sampling clock noise canceller output rejected as noise 191
tcg can be cleared to 0 at the rising edge, falling edge, or both edges of the input capture signal as determined with bits cclr1 and cclr0 of tmg. if tcg overflows while the input capture signal is high, bit ovfh of tmg is set. if tcg overflows while the input capture signal is low, bit ovfl of tmg is set. when either of these bits is set, if bit ovie of tmg is currently set to 1, then bit irrtg is set to 1 in irr2. if bit ientg is also set to 1 in ienr2, then timer g requests a cpu interrupt. for further details see 3.3, interrupts. timer g has a noise canceller circuit that rejects high-frequency pulse noise in the input to pin tmig. see 9.4.3, noise canceller circuit, for details. note: * rewriting the tmig bit may cause an internal input capture signal to be generated. interval timer operation timer g functions as an interval timer when bit tmig is cleared to 0 in pmr1. following a reset, tcg starts counting cycles of the ?64 internal clock. this is one of four internal clock sources that can be selected by bits cks1 and cks0 of tmg. tcg counts up according to the selected clock source. when it overflows from h'ff to h'00, bit ovfl of tmg is set to 1. if bit ovie of tmg is currently set to 1, then bit irrtg is set to 1 in irr2. if bit ientg is also set to 1 in ienr2, then timer g requests a cpu interrupt. for further details see 3.3, interrupts. 2. count timing tcg is incremented by input pulses from an internal clock. tmg bits cks1 and cks0 select one of four internal clocks (?64, ?32, ?2, w /2) derived by dividing the system clock (? and the watch clock ( w ). 192
3. timing of internal input capture signals timing with noise canceller function disabled separate internal input capture signals are generated from the rising and falling edges of the external input signal. figure 9-9 shows the timing of these signals. figure 9-9 input capture signal timing (noise canceller function disabled) timing with noise canceller function enabled when input capture noise cancelling is enabled, the external input capture signal is routed via the noise canceller circuit, so the internal signals are delayed from the input edge by five sampling clock cycles. figure 9-10 shows the timing. figure 9-10 input capture signal timing (noise canceller function enabled) external input capture signal sampling clock noise canceller circuit output internal input capture signal r external input capture signal internal input capture signal f internal input capture signal r 193
4. timing of input capture figure 9-11 shows the input capture timing in relation to the internal input capture signal. figure 9-11 input capture timing 5. tcg clear timing tcg can be cleared at the rising edge, falling edge, or both edges of the external input capture signal. figure 9-12 shows the timing for clearing at both edges. figure 9-12 tcg clear timing internal input capture signal tcg input capture register n ? n n +1 h'xx n external input capture signal internal input capture signal f internal input capture signal r tcg n h'00 n h'00 194
6. timer g operation states table 9-10 summarizes the timer g operation states. table 9-10 timer g operation states sub- sub- operation mode reset active sleep watch active sleep standby tcg input reset functions * functions * halted functions/ functions/ halted capture halted * halted * interval reset functions * functions * retained functions/ functions/ halted halted * halted * icrgf reset functions * functions * retained functions/ functions/ retained halted * halted * icrgr reset functions * functions * retained functions/ functions/ retained halted * halted * tmg reset functions retained retained functions retained retained note: * in active mode and sleep mode, if w /2 is selected as the tcg internal clock, since the system clock and internal clock are not synchronized with each other, a synchronization circuit is used. this may result in a count cycle error of up to 1/?(s). in subactive mode and subsleep mode, if w /2 is selected as the tcg internal clock, regardless of the subclock ? sub ( w /2, w /4, w /8) tcg and the noise canceller circuit run on an internal clock of w /2. if any other internal clock is chosen, tcg and the noise canceller circuit will not run, and the input capture function will not operate. 9.4.5 application notes 1. input clock switching and tcg operation depending on when the input clock is switched, there will be cases in which tcg is incremented in the process. table 9-4-4 shows the relation between internal clock switchover timing (selected in bits cks1 and cks0) and tcg operation. if an internal clock (derived from the system clock ?or subclock sub ) is used, an increment pulse is generated when a falling edge of the internal clock is detected. for this reason, in a case like no. 3 in table 9-11, where the clock is switched at a time such that the clock signal goes from high level before switching to low level after switching, the switchover is seen as a falling edge to generate the count clock, causing tcg to be incremented. 195
table 9-11 internal clock switching and tcg operation clock level before and after modifying no. bits cks1 and cks0 tcg operation 1 goes from low level to low level 2 goes from low level to high level 3 goes from high level to low level 4 goes from high level to high level note: * the switchover is seen as a falling edge of the clock pulse, and tcg is incremented. n +1 clock before switching clock after switching count clock tcg cks bits modified n n +1 n +2 clock before switching clock after switching count clock tcg cks bits modified n n +1 n n +2 * clock before switching clock after switching count clock tcg cks bits modified n +1 n +2 n clock before switching clock after switching count clock cks bits modified tcg 196
2. note on rewriting port mode registers when a port mode register setting is modified to enable or disable the input capture function or input capture noise canceling function, note the following points. switching the function of the input capture pin when the function of the input capture pin is switched by modifying port mode register 1 bit 3 (the tmig bit), an input capture edge may be recognized even though no valid signal edge has been input. this occurs under the conditions listed in table 9-12. table 9-12 false input capture edges generating by switching of input capture pin function input capture edge conditions tmig pin level is high, and tmig bit is changed from 0 to 1 tmig pin level is high and ncs bit is changed from 0 to 1, then tmig bit is changed from 0 to 1 before noise canceller circuit completes five samples tmig pin level is high, and tmig bit is changed from 1 to 0 tmig pin level is low and ncs bit is changed from 0 to 1, then tmig bit is changed from 0 to 1 before noise canceller circuit completes five samples tmig pin level is high and ncs bit is changed from 0 to 1, then tmig bit is changed from 1 to 0 before noise canceller circuit completes five samples note: when pin p1 3 is not used for input capture, the input capture signal input to timer g is low. switching the input capture noise canceling function when modifying port mode register 2 bit 4 (the ncs bit) to enable or disable the input capture noise canceling function, first clear the tmig bit to 0. otherwise an input capture edge may be recognized even though no valid signal edge has been input. this occurs under the conditions listed in table 9-13. table 9-13 false input capture edges generating by switching of noise canceling function input capture edge conditions rising edge tmig bit is set to 1 and tmig pin level changes from low to high, then ncs recognized bit is changed from 1 to 0 before noise canceller circuit completes five samples falling edge tmig bit is set to 1 and tmig pin level changes from high to low, then ncs recognized bit is changed from 1 to 0 before noise canceller circuit completes five samples rising edge recognized falling edge recognized 197
if switching of the pin function generates a false input capture edge matching the edge selected by the input capture interrupt edge select bit (iiegs), the interrupt request flag will be set to 1, making it necessary to clear this flag to 0 before using the interrupt function. figure 9-4-8 shows the procedure for modifying port mode register settings and clearing the interrupt request flag. the first step is to mask interrupts before modifying the port mode register. after modifying the port mode register setting, wait long enough for an input capture edge to be recognized (at least two system clocks when noise canceling is disabled; at least five sampling clocks when noise canceling is enabled), then clear the interrupt request flag to 0 (assuming it has been set to 1). an alternative procedure is to avoid having the interrupt request flag set when the pin function is switched, either by controlling the level of the input capture pin so that it does not satisfy the conditions in tables 9-12 and 9-13, or by setting the iiegs bit of tmg to select the edge opposite to the falsely generated edge. figure 9-13 procedure for modifying port mode register and clearing interrupt request flag set i bit to 1 in ccr clear i bit to 0 in ccr modify port mode register wait for tmig to be recognized clear interrupt request flag to 0 disable interrupts (or disable by clearing interrupt enable bit in interrupt enable register 2) modify port mode register setting, wait for input capture edge to be recognized (at least two system clocks when noise canceling is disabled; at least five sampling clocks when noise canceling is enabled), then clear interrupt request flag to 0 enable interrupts 198
9.4.6 sample timer g application the absolute values of the high and low widths of the input capture signal can be measured by using timer g. the cclr1 and cclr0 bits of tmg should be set to 1. figure 9-14 shows an example of this operation. figure 9-14 sample timer g application input capture signal h'ff input capture register gf input capture register gr h'00 counter cleared tcg 199
section 10 serial communication interface 10.1 overview the h8/3877n series is provided with a two-channel serial communication interface (sci), sci1 and sci2. table 10-1 summarizes the functions and features of the two sci channels. table 10-1 serial communication interface functions channel functions features sci1 synchronous serial transfer choice of 8-bit or 16-bit data length continuous clock output sci3 synchronous serial transfer 8-bit data transfer send, receive, or simultaneous send/receive asynchronous serial transfer multiprocessor communication function choice of 7-bit or 8-bit data length choice of 1-bit or 2-bit stop bit length odd or even parity choice of 8 internal clocks (?1024 to ?2) or external clock open drain output possible interrupt requested at completion of transfer built-in baud rate generator receive error detection break detection interrupt requested at completion of transfer or error 201
10.2 sci1 10.2.1 overview serial communication interface 1 (sci1) performs synchronous serial transfer of 8-bit or 16-bit data. 1. features features of sci1 are given below. choice of 8-bit or 16-bit data length choice of eight internal clock sources (?1024, ?256, ?64, ?32, ?16, ?8, ?4, ?2) or an external clock interrupt requested at completion of transfer 202
2. block diagram figure 10-1 shows a block diagram of sci1. figure 10-1 sci1 block diagram sck 1 si 1 so 1 scr1 scsr1 sdru sdrl pss transfer bit counter transmit/receive control circuit internal data bus notation: scr1: scsr1: sdru: sdrl: irrs1: pss: serial control register 1 serial control/status register 1 serial data register u serial data register l sci1 interrupt request flag prescaler s irrs1 203
3. pin configuration table 10-2 shows the sci1 pin configuration. table 10-2 pin configuration name abbrev. i/o function sci1 clock pin sck 1 i/o sci1 clock input or output sci1 data input pin si 1 input sci1 receive data input sci1 data output pin so 1 output sci1 transmit data output 4. register configuration table 10-3 shows the sci1 register configuration. table 10-3 sci1 registers name abbrev. r/w initial value address serial control register 1 scr1 r/w h'00 h'ffa0 serial control status register 1 scsr1 r/w h'80 h'ffa1 serial data register u sdru r/w undefined h'ffa2 serial data register l sdrl r/w undefined h'ffa3 10.2.2 register descriptions 1. serial control register 1 (scr1) scr1 is an 8-bit read/write register for selecting the operation mode, the transfer clock source, and the prescaler division ratio. upon reset, scr1 is initialized to h'00. writing to this register during a transfer stops the transfer. bit initial value read/write 7 snc1 0 r/w 6 snc0 0 r/w 5 0 r/w 4 0 r/w 3 cks3 0 r/w 0 cks0 0 r/w 2 cks2 0 r/w 1 cks1 0 r/w 204
bits 7 and 6: operation mode select 1, 0 (snc1, snc0) bits 7 and 6 select the operation mode. bit 7 bit 6 snc1 snc0 description 0 0 8-bit synchronous transfer mode (initial value) 0 1 16-bit synchronous transfer mode 1 0 continuous clock output mode * 1 1 1 reserved * 2 notes: 1. pins si 1 and so 1 should be used as general input or output ports. 2. don? set bits snc1 and snc0 to 11. bits 5 and 4: reserved bits bits 5 and 4 are reserved, but they can be written and read. bit 3: clock source select 3 (cks3) bit 3 selects the clock source and sets pin sck 1 as an input or output pin. bit 3 cks3 description 0 clock source is prescaler s, and pin sck 1 is output pin (initial value) 1 clock source is external clock, and pin sck 1 is input pin 205
bits 2 to 0: clock select 2 to 0 (cks2 to cks 0) when cks3 = 0, bits 2 to 0 select the prescaler division ratio and the serial clock cycle. serial clock cycle prescaler division ?= 5 mhz ?= 2.5 mhz 0 0 0 ?1024 (initial value) 204.8 ? 409.6 ? 0 0 1 ?256 51.2 ? 102.4 ? 0 1 0 ?64 12.8 ? 25.6 ? 0 1 1 ?32 6.4 ? 12.8 ? 1 0 0 ?16 3.2 ? 6.4 ? 1 0 1 ?8 1.6 ? 3.2 ? 1 1 0 ?4 0.8 ? 1.6 ? 1 1 1 ?2 0.8 ? 2. serial control/status register 1 (scsr1) note: * only a write of 0 for flag clearing is possible. scsr1 is an 8-bit read/write register indicating operation status and error status. upon reset, scsr1 is initialized to h'80. bit 7: reserved bit bit 7 is reserved; it is always read as 1, and cannot be modified. bit initial value read/write 7 1 6 sol 0 r/w 5 orer 0 r/(w) 4 0 3 0 0 stf 0 r/w 2 0 1 0 r/w * bit 2 bit 1 bit 0 cks2 cks1 cks0 206
bit 6: extended data bit (sol) bit 6 sets the so 1 output level. when read, sol returns the output level at the so 1 pin. after completion of a transmission, so 1 continues to output the value of the last bit of transmitted data. the so 1 output can be changed by writing to sol before or after a transmission. the sol bit setting remains valid only until the start of the next transmission. to control the level of the so 1 pin after transmission ends, it is necessary to write to the sol bit at the end of each transmission. do not write to this register while transmission is in progress, because that may cause a malfunction. bit 6 sol description 0 read so 1 pin output level is low (initial value) write so 1 pin output level changes to low 1 read so 1 pin output level is high write so 1 pin output level changes to high bit 5: overrun error flag (orer) when an external clock is used, bit 5 indicates the occurrence of an overrun error. if a clock pulse is input after transfer completion, this bit is set to 1 indicating an overrun. if noise occurs during a transfer, causing an extraneous pulse to be superimposed on the normal serial clock, incorrect data may be transferred. bit 5 orer description 0 clearing conditions: (initial value) after reading orer = 1, cleared by writing 0 to orer 1 setting conditions: set if a clock pulse is input after transfer is complete, when an external clock is used bits 4 to 2: reserved bits bits 4 to 2 are reserved. they are always read as 0, and cannot be modified. bit 1: reserved bit bit 1 is reserved; it should always be cleared to 0. 207
bit 0: start flag (stf) bit 0 controls the start of a transfer. setting this bit to 1 causes sci1 to start transferring data. during the transfer or while waiting for start bit, this bit remains set to 1. it is cleared to 0 upon completion of the transfer. it can therefore be used as a busy flag. bit 0 stf description 0 read: indicates that transfer is stopped (initial value) write: invalid 1 read: indicates transfer in progress write: starts a transfer operation 3. serial data register u (sdru) sdru is an 8-bit read/write register. it is used as the data register for the upper 8 bits in 16-bit transfer (sdrl is used for the lower 8 bits). data written to sdru is output to sdrl starting from the least significant bit (lsb). this data is then replaced by lsb-first data input at pin si 1 , which is shifted in the direction from the most significant bit (msb) toward the lsb. sdru must be written or read only after data transmission or reception is complete. if this register is written or read while a data transfer is in progress, the data contents are not guaranteed. the sdru value upon reset is not fixed. bit initial value read/write 7 sdru7 undefined r/w 6 sdru6 undefined r/w 5 sdru5 undefined r/w 4 sdru4 undefined r/w 3 sdru3 undefined r/w 0 sdru0 undefined r/w 2 sdru2 undefined r/w 1 sdru1 undefined r/w 208
4. serial data register l (sdrl) sdrl is an 8-bit read/write register. it is used as the data register in 8-bit transfer, and as the data register for the lower 8 bits in 16-bit transfer (sdru is used for the upper 8 bits). in 8-bit transfer, data written to sdrl is output from pin so 1 starting from the least significant bit (lsb). this data is than replaced by lsb-first data input at pin si 1 , which is shifted in the direction from the most significant bit (msb) toward the lsb. in 16-bit transfer, operation is the same as for 8-bit transfer, except that input data is fed in via sdru. sdrl must be written or read only after data transmission or reception is complete. if this register is read or written while a data transfer is in progress, the data contents are not guaranteed. the sdrl value upon reset is not fixed. 10.2.3 operation data can be sent and received in an 8-bit or 16-bit format, synchronized to an internal or external clock. overrun errors can be detected when an external clock is used. 1. clock the serial clock can be selected from a choice of eight internal clocks and an external clock. when an internal clock source is selected, pin sck 1 becomes the clock output pin. when continuous clock output mode is selected (scr1 bits snc1 and snc0 are set to 10), the clock signal (?1024 to ?2) selected in bits cks2 to cks0 is output continuously from pin sck 1 . when an external clock is used, pin sck 1 is the clock input pin. 2. data transfer format figure 10-2 shows the data transfer format. data is sent and received starting from the least significant bit, in lsb-first format. transmit data is output from one falling edge of the serial clock until the next falling edge. receive data is latched at the rising edge of the serial clock. bit initial value read/write 7 sdrl7 undefined r/w 6 sdrl6 undefined r/w 5 sdrl5 undefined r/w 4 sdrl4 undefined r/w 3 sdrl3 undefined r/w 0 sdrl0 undefined r/w 2 sdrl2 undefined r/w 1 sdrl1 undefined r/w 209
figure 10-2 transfer format 3. data transfer operations transmitting a transmit operation is carried out as follows. set bit so 1 in port mode register 2 (pmr2) to 1, making pin p2 3 /so 1 the so 1 output pin. also set bit sck1 in pmr2 to 1, making pin p2 1 /sck 1 the sck 1 i/o pin. if necessary, set bit pof1 in pmr2 for nmos open drain output at pin so 1 . clear bit snc1 in scr1 to 0, and set bit snc0 to 1 or 0, designating 8- or 16-bit synchronous transfer mode. select the serial clock in bits cks3 to cks0. writing data to scr1 initializes the internal state of sci1. write transmit data in sdrl and sdru, as follows. 8-bit transfer mode: sdrl 16-bit transfer mode: upper byte in sdru, lower byte in sdrl set the scsr1 start flag (stf) to 1. sci1 starts operating and outputs transmit data at pin so 1 . after data transmission is complete, bit irrs1 in interrupt request register 1 (irr1) is set to 1. when an internal clock is used, a serial clock is output from pin sck 1 in synchronization with the transmit data. after data transmission is complete, the serial clock is not output until the next time the start flag is set to 1. during this time, pin so 1 continues to output the value of the last bit transmitted. sck so /si 1 11 bit 0 bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 210
when an external clock is used, data is transmitted in synchronization with the serial clock input at pin sck 1 . after data transmission is complete, an overrun occurs if the serial clock continues to be input; no data is transmitted and the scsr1 overrun error flag (bit orer) is set to 1. while transmission is stopped, the output value of pin so 1 can be changed by rewriting bit sol in scsr1. receiving a receive operation is carried out as follows. set bit si1 in port mode register 2 (pmr2) to 1, making pin p2 2 /si 1 the si 1 input pin. also set bit sck1 in pmr2 to 1, making pin p2 1 /sck 1 the sck 1 i/o pin. clear bit snc1 in scr1 to 0, and set bit snc0 to 1 or 0, designating 8- or 16-bit synchronous transfer mode. select the serial clock in bits cks3 to cks0. writing data to scr1 initializes the internal state of sci1. set the scsr1 start flag (stf) to 1. sci1 starts operating and receives data at pin si 1 . after data reception is complete, bit irrs1 in interrupt request register 1 (irr1) is set to 1. read the received data from sdrl and sdru, as follows. 8-bit transfer mode: sdrl 16-bit transfer mode: upper byte in sdru, lower byte in sdrl after data reception is complete, an overrun occurs if the serial clock continues to be input; no data is received and the scsr1 overrun error flag (bit orer) is set to 1. 211
simultaneous transmit/receive a simultaneous transmit/receive operation is carried out as follows. set bits so 1 , si 1 , and sck1 in pmr2 to 1, making pin p2 3 /so 1 the so 1 output pin, pin p2 2 /si 1 the si 1 input pin, and pin p2 1 /sck 1 the sck 1 i/o pin. if necessary, set bit pof1 in pmr2 for nmos open drain output at pin so 1 . clear bit snc1 in scr1 to 0, and set bit snc0 to 1 or 0, designating 8- or 16-bit synchronous transfer mode. select the serial clock in bits cks3 to cks0. writing data to scr1 initializes the internal state of sci1. write transmit data in sdrl and sdru, as follows. 8-bit transfer mode: sdrl 16-bit transfer mode: upper byte in sdru, lower byte in sdrl set the scsr1 start flag (stf) to 1. sci1 starts operating. transmit data is output at pin so 1 . receive data is input at pin si 1 . after data transmission and reception are complete, bit irrs1 in irr1 is set to 1. read the received data from sdrl and sdru, as follows. 8-bit transfer mode: sdrl 16-bit transfer mode: upper byte in sdru, lower byte in sdrl when an internal clock is used, a serial clock is output from pin sck 1 in synchronization with the transmit data. after data transmission is complete, the serial clock is not output until the next time the start flag is set to 1. during this time, pin so 1 continues to output the value of the last bit transmitted. when an external clock is used, data is transmitted and received in synchronization with the serial clock input at pin sck 1 . after data transmission and reception are complete, an overrun occurs if the serial clock continues to be input; no data is transmitted or received and the scsr1 overrun error flag (bit orer) is set to 1. while transmission is stopped, the output value of pin so 1 can be changed by rewriting bit sol in scsr1. 212
10.2.4 interrupt sources sci1 can generate an interrupt at the end of a data transfer. when an sci1 transfer is complete, bit irrs1 in interrupt request register 1 (irr1) is set to 1. sci1 interrupt requests can be enabled or disabled by bit iens1 of interrupt enable register 1 (ienr1). for further details, see 3.3, interrupts. 213
10.3 sci3 10.3.1 overview serial communication interface 3 (sci3) has both synchronous and asynchronous serial data communication capabilities. it also has a multiprocessor communication function for serial data communication among two or more processors. 1. features sci3 features are listed below. selection of asynchronous or synchronous mode a. asynchronous mode sci3 can communicate with a uart (universal asynchronous receiver/transmitter), acia (asynchronous communication interface adapter), or other chip that employs standard asynchronous serial communication. it can also communicate with two or more other processors using the multiprocessor communication function. there are twelve selectable serial data communication formats. data length: seven or eight bits stop bit length: one or two bits parity: even, odd, or none multiprocessor bit: one or none receive error detection: parity, overrun, and framing errors break detection: by reading the rxd level directly when a framing error occurs b. synchronous mode serial data communication is synchronized with a clock signal. sci3 can communicate with other chips having a clocked synchronous communication function. data length: eight bits receive error detection: overrun errors full duplex communication the transmitting and receiving sections are independent, so sci3 can transmit and receive simultaneously. both sections use double buffering, so continuous data transfer is possible in both the transmit and receive directions. 214
built-in baud rate generator with selectable bit rates. internal or external clock may be selected as the transfer clock source. there are six interrupt sources: transmit end, transmit data register empty, receive data register full, overrun error, framing error, and parity error. 2. block diagram figure 10-3 shows a block diagram of sci3. figure 10-3 sci3 block diagram sck txd rxd 3 tsr rsr rdr tdr ssr scr3 smr brr brc rsr: rdr: tsr: tdr: smr: scr3: ssr: brr: brc: external clock baud rate generator internal clock (?64, ?16, ?4, ? clock transmit/receive control internal data bus interrupt requests (tei, txi, rxi, eri) notation: receive shift register receive data register transmit shift register transmit data register serial mode register serial control register 3 serial status register bit rate register bit rate counter 215
3. pin configuration table 10-4 shows the sci3 pin configuration. table 10-4 pin configuration name abbrev. i/o function sci3 clock sck 3 i/o sci3 clock input/output sci3 receive data input rxd input sci3 receive data input sci3 transmit data output txd output sci3 transmit data output 4. register configuration table 10-5 shows the sci3 internal register configuration. table 10-5 sci3 registers name abbrev. r/w initial value address serial mode register smr r/w h'00 h'ffa8 bit rate register brr r/w h'ff h'ffa9 serial control register 3 scr3 r/w h'00 h'ffaa transmit data register tdr r/w h'ff h'ffab serial status register ssr r/w h'84 h'ffac receive data register rdr r h'00 h'ffad transmit shift register tsr receive shift register rsr bit rate counter brc 216
10.3.2 register descriptions 1. receive shift register (rsr) the receive shift register (rsr) is for receiving serial data. serial data is input in lsb-first order into rsr from pin rxd, converting it to parallel data. after each byte of data has been received, the byte is automatically transferred to the receive data register (rdr). rsr cannot be read or written directly by the cpu. 2. receive data register (rdr) the receive data register (rdr) is an 8-bit register for storing received serial data. each time a byte of data is received, the received data is transferred from the receive shift register (rsr) to rdr, completing a receive operation. thereafter rsr again becomes ready to receive new data. rsr and rdr form a double buffer mechanism that allows data to be received continuously. rdr is exclusively for receiving data and cannot be written by the cpu. rdr is initialized to h'00 upon reset or in standby mode, watch mode, subactive mode, or subsleep mode. bit initial value read/write 7 rdr7 0 r 6 rdr6 0 r 5 rdr5 0 r 4 rdr4 0 r 3 rdr3 0 r 0 rdr0 0 r 2 rdr2 0 r 1 rdr1 0 r bit read/write 7 6 5 4 3 0 2 1 217
3. transmit shift register (tsr) the transmit shift register (tsr) is for transmitting serial data. transmit data is first transferred from the transmit data register (tdr) to tsr, then is transmitted from pin txd, starting from the lsb (bit 0). after one byte of data has been sent, the next byte is automatically transferred from tdr to tsr, and the next transmission begins. if no data has been written to tdr (1 is set in tdre), there is no data transfer from tdr to tsr. tsr cannot be read or written directly by the cpu. 4. transmit data register (tdr) the transmit data register (tdr) is an 8-bit register for holding transmit data. when sci3 detects that the transmit shift register (tsr) is empty, it shifts transmit data written in tdr to tsr and starts serial data transmission. while tsr is transmitting serial data, the next byte to be transmitted can be written to tdr, realizing continuous transmission. tdr can be read or written by the cpu at all times. tdr is initialized to h'ff upon reset or in standby mode, watch mode, subactive mode, or subsleep mode. bit read/write 7 6 5 4 3 0 2 1 bit initial value read/write 7 tdr7 1 r/w 6 tdr6 1 r/w 5 tdr5 1 r/w 4 tdr4 1 r/w 3 tdr3 1 r/w 0 tdr0 1 r/w 2 tdr2 1 r/w 1 tdr1 1 r/w 218
5. serial mode register (smr) the serial mode register (smr) is an 8-bit register for setting the serial data communication format and for selecting the clock source of the baud rate generator. smr can be read and written by the cpu at any time. smr is initialized to h'00 upon reset or in standby mode, watch mode, subactive mode, or subsleep mode. bit 7: communication mode (com) bit 7 selects asynchronous mode or synchronous mode as the serial data communication mode. bit 7 com description 0 asynchronous mode (initial value) 1 synchronous mode bit 6: character length (chr) bit 6 selects either 7 bits or 8 bits as the data length in asynchronous mode. in synchronous mode the data length is always 8 bits regardless of the setting here. bit 6 chr description 0 8-bit data (initial value) 1 7-bit data * note: * when 7-bit data is selected as the character length in asynchronous mode, the msb (bit 7) in the transmit data register is not transmitted. bit initial value read/write 7 com 0 r/w 6 chr 0 r/w 5 pe 0 r/w 4 pm 0 r/w 3 stop 0 r/w 0 cks0 0 r/w 2 mp 0 r/w 1 cks1 0 r/w 219
bit 5: parity enable (pe) in asynchronous mode, bit 5 selects whether or not a parity bit is to be added to transmitted data and checked in received data. in synchronous mode there is no adding or checking of parity regardless of the setting here. bit 5 pe description 0 parity bit adding and checking disabled (initial value) 1 parity bit adding and checking enabled * note: * when pe is set to 1, then either odd or even parity is added to transmit data, depending on the setting of the parity mode bit (pm). when data is received, it is checked for odd or even parity as designated in bit pm. bit 4: parity mode (pm) in asynchronous mode, bit 4 selects whether odd or even parity is to be added to transmitted data and checked in received data. the setting here is valid only if parity adding/checking is enabled in bit pe. in synchronous mode, or if parity adding/checking is disabled in bit pe, bit pm is ignored. bit 4 pm description 0 even parity * 1 (initial value) 1 odd parity * 2 notes: 1. when even parity is designated, a parity bit is added to the transmitted data so that the sum of 1s in the resulting data is an even number. when data is received, the sum of 1s in the data plus parity bit is checked to see if the result is an even number. 2. when odd parity is designated, a parity bit is added to the transmitted data so that the sum of 1s in the resulting data is an odd number. when data is received, the sum of 1s in the data plus parity bit is checked to see if the result is an odd number. 220
bit 3: stop bit length (stop) bit 3 selects 1 bit or 2 bits as the stop bit length in asynchronous mode. this setting is valid only in asynchronous mode. in synchronous mode a stop bit is not added, so this bit is ignored. bit 3 stop description 0 1 stop bit * 1 (initial value) 1 2 stop bits * 2 notes: 1. when data is transmitted, one ??bit is added at the end of each transmitted character as the stop bit. 2. when data is transmitted, two ??bits are added at the end of each transmitted character as the stop bits. when data is received, only the first stop bit is checked regardless of the stop bit length. if the second stop bit value is 1 it is treated as a stop bit; if it is 0, it is treated as the start bit of the next character. bit 2: multiprocessor mode (mp) bit 2 enables or disables the multiprocessor communication function. when the multiprocessor communication function is enabled, the parity enable (pe) and parity mode (pm) settings are ignored. the mp bit is valid only in asynchronous mode; it should be cleared to 0 in synchronous mode. see 10.3.6, for details on the multiprocessor communication function. bit 2 mp description 0 multiprocessor communication function disabled (initial value) 1 multiprocessor communication function enabled 221
bits 1 and 0: clock select 1, 0 (cks1, cks0) bits 1 and 0 select the clock source for the built-in baud rate generator. a choice of ?64, ?16, ?4, or ?is made in these bits. see 8, bit rate register, below for information on the clock source and bit rate register settings, and their relation to the baud rate. bit 1 bit 0 cks1 cks0 description 0 0 ?clock (initial value) 0 1 ?4 clock 1 0 ?16 clock 1 1 ?64 clock 6. serial control register 3 (scr3) serial control register 3 (scr3) is an 8-bit register that controls sci3 transmit and receive operations, enables or disables serial clock output in asynchronous mode, enables or disables interrupts, and selects the serial clock source. scr3 can be read and written by the cpu at any time. scr3 is initialized to h'00 upon reset or in standby mode, watch mode, subactive mode, or subsleep mode. bit initial value read/write 7 tie 0 r/w 6 rie 0 r/w 5 te 0 r/w 4 re 0 r/w 3 mpie 0 r/w 0 cke0 0 r/w 2 teie 0 r/w 1 cke1 0 r/w 222
bit 7: transmit interrupt enable (tie) bit 7 enables or disables the transmit data empty interrupt request (txi) when data is transferred from tdr to tsr and the transmit data register empty bit (tdre) in the serial status register (ssr) is set to 1. the txi interrupt can be cleared by clearing bit tdre to 0, or by clearing bit tie to 0. bit 7 tie description 0 transmit data empty interrupt request (txi) disabled (initial value) 1 transmit data empty interrupt request (txi) enabled bit 6: receive interrupt enable (rie) bit 6 enables or disables the receive error interrupt request (eri), and the receive data full interrupt request (rxi) when data is transferred from rsr to rdr and the receive data register full bit (rdrf) in the serial status register (ssr) is set to 1. receive errors include overrun errors, framing errors, and parity errors. rxi and eri interrupts can be cleared by clearing ssr flag rdrf, or flags fer, per, and oer to 0, or by clearing bit rie to 0. bit 6 rie description 0 receive data full interrupt request (rxi) and receive error interrupt (initial value) request (eri) disabled 1 receive data full interrupt request (rxi) and receive error interrupt request (eri) enabled bit 5: transmit enable (te) bit 5 enables or disables the start of a transmit operation. bit 5 te description 0 transmit operation disabled * 1 (txd is a general i/o port) (initial value) 1 transmit operation enabled * 2 (txd is the transmit data pin) notes: 1. the transmit data register empty bit (tdre) in the serial status register (ssr) is fixed at 1. 2. in this state, writing transmit data in tdr clears bit tdre in ssr to 0 and starts serial data transmission. before setting te to 1 it is necessary to set the transmit format in smr. 223
bit 4: receive enable (re) bit 4 enables or disables the start of a receive operation. bit 4 re description 0 receive operation disabled * 1 (rxd is a general i/o port) (initial value) 1 receive operation enabled * 2 (rxd is the receive data pin) notes: 1. when re is cleared to 0, this has no effect on the ssr flags rdrf, fer, per, and oer, which retain their states. 2. serial data receiving begins when, in this state, a start bit is detected in asynchronous mode, or serial clock input is detected in synchronous mode. before setting re to 1 it is necessary to set the receive format in smr. bit 3: multiprocessor interrupt enable (mpie) bit 3 enables or disables multiprocessor interrupt requests. this setting is valid only in asynchronous mode, and only when the multiprocessor mode bit (mp) in the serial mode register (smr) is set to 1. it applies only to data receiving. this bit is ignored when com is set to 1 or when bit mp is cleared to 0. bit 3 mpie description 0 multiprocessor interrupt request disabled (ordinary receive operation) (initial value) clearing condition: multiprocessor bit receives a data value of 1 1 multiprocessor interrupt request enabled * note: * sci3 does not transfer receive data from rsr to rdr, does not detect receive errors, and does not set status flags rdrf, fer, and oer in ssr. until a multiprocessor bit value of 1 is received, the receive data full interrupt (rxi) and receive error interrupt (eri) are disabled and serial status register (ssr) flags rdrf, fer, and oer are not set. when the multiprocessor bit receives a ?? the mpbr bit of ssr is set to 1, mpie is automatically cleared to 0, rxi and eri interrupts are enabled (provided bits tie and rie in scr3 are set to 1), and setting of the rdrf, fer, and oer flags is enabled. 224
bit 2: transmit end interrupt enable (teie) bit 2 enables or disables the transmit end interrupt (tei) requested if there is no valid transmit data in tdr when the msb is transmitted. bit 2 teie description 0 transmit end interrupt (tei) disabled (initial value) 1 transmit end interrupt (tei) enabled * note: * a tei interrupt can be cleared by clearing the ssr bit tdre to 0 and clearing the transmit end bit (tend) to 0, or by clearing bit teie to 0. bits 1 and 0: clock enable 1, 0 (cke1, cke0) bits 1 and 0 select the clock source and enable or disable clock output at pin sck 3 . the combination of bits cke1 and cke0 determines whether pin sck 3 is a general i/o port, a clock output pin, or a clock input pin. note that the cke0 setting is valid only when operation is in asynchronous mode using an internal clock (cke1 = 0). this bit is invalid in synchronous mode or when using an external clock (cke1 = 1). in synchronous mode and in external clock mode, clear cke0 to 0. after setting bits cke1 and cke0, the operation mode must first be set in the serial mode register (smr). see table 10-10 in 10.3.2, operation, for details on clock source selection. bit 1 bit 0 cke1 cke0 communication mode clock source sck 3 pin function 0 0 asynchronous internal clock i/o port * 1 synchronous internal clock serial clock output * 1 0 1 asynchronous internal clock clock output * 2 synchronous reserved reserved 1 0 asynchronous external clock clock input * 3 synchronous external clock serial clock input 1 1 asynchronous reserved reserved synchronous reserved reserved notes: 1. initial value 2. a clock is output with the same frequency as the bit rate. 3. input a clock with a frequency 16 times the bit rate. 225
7. serial status register (ssr) the serial status register (ssr) is an 8-bit register containing status flags for indicating sci3 states, and containing the multiprocessor bits. ssr can be read and written by the cpu at any time, but the cpu cannot write a 1 to the status flags tdre, rdrf, oer, per, and fer. to clear these flags to 0 it is first necessary to read a 1. bit 2 (tend) and bit 1 (mpbr) are read-only bits and cannot be modified. ssr is initialized to h'84 upon reset or in standby mode, watch mode, subactive mode, or subsleep mode. bit 7: transmit data register empty (tdre) bit 7 is a status flag indicating that data has been transferred from tdr to tsr. bit 7 tdre description 0 indicates that transmit data written to tdr has not been transferred to tsr clearing conditions: after reading tdre = 1, cleared by writing 0 to tdre. when data is written to tdr by an instruction. 1 indicates that no transmit data has been written to tdr, (initial value) or the transmit data written to tdr has been transferred to tsr setting conditions: when bit te in scr3 is cleared to 0. when data is transferred from tdr to tsr. bit initial value read/write 7 tdre 1 r/(w) 6 rdrf 0 r/(w) 5 oer 0 r/(w) 4 fer 0 r/(w) 3 per 0 r/(w) 0 mpbt 0 r/w 2 tend 1 r 1 mpbr 0 r ***** note: only 0 can be written for flag clearing. * 226
bit 6: receive data register full (rdrf) bit 6 is a status flag indicating whether there is receive data in rdr. bit 6 rdrf description 0 indicates there is no receive data in rdr (initial value) clearing conditions: after reading rdrf = 1, cleared by writing 0 to rdrf. when data is read from rdr by an instruction. 1 indicates that there is receive data in rdr setting condition: when receiving ends normally, with receive data transferred from rsr to rdr note: if a receive error is detected at the end of receiving, or if bit re in serial control register 3 (scr3) is cleared to 0, rdr and rdrf are unaffected and keep their previous states. an overrun error (oer) occurs if receiving of data is completed while bit rdrf remains set to 1. if this happens, receive data will be lost. bit 5: overrun error (oer) bit 5 is a status flag indicating that an overrun error has occurred during data receiving. bit 5 oer description 0 indicates that data receiving is in progress or has been completed * 1 (initial value) clearing condition: after reading oer = 1, cleared by writing 0 to oer 1 indicates that an overrun error occurred in data receiving * 2 setting condition: when data receiving is completed while rdrf is set to 1 notes: 1. when bit re in serial control register 3 (scr3) is cleared to 0, oer is unaffected and keeps its previous state. 2. rdr keeps the data received prior to the overrun; data received after that is lost. while oer is set to 1, data receiving cannot be continued. in synchronous mode, data transmitting cannot be continued either. 227
bit 4: framing error (fer) bit 4 is a status flag indicating that a framing error has occurred during asynchronous receiving. bit 4 fer description 0 indicates that data receiving is in progress or has been completed * 1 (initial value) clearing condition: after reading fer = 1, cleared by writing 0 to fer 1 indicates that a framing error occurred in data receiving setting condition: the stop bit at the end of receive data is checked and found to be 0 * 2 notes: 1. when bit re in serial control register 3 (scr3) is cleared to 0, fer is unaffected and keeps its previous state. 2. when two stop bits are used only the first stop bit is checked, not the second. when a framing error occurs, receive data is transferred to rdr but rdrf is not set. while fer is set to 1, data receiving cannot be continued. in synchronous mode, data transmission and reception cannot be performed if fer is set to 1. bit 3: parity error (per) bit 3 is a status flag indicating that a parity error has occurred during asynchronous receiving. bit 3 per description 0 indicates that data receiving is in progress or has been completed * 1 (initial value) clearing condition: after reading per = 1, cleared by writing 0 to per 1 indicates that a parity error occurred in data receiving * 2 setting condition: when the sum of 1s in received data plus the parity bit does not match the parity mode bit (pm) setting in the serial mode register (smr) notes: 1. when bit re in serial control register 3 (scr3) is cleared to 0, per is unaffected and keeps its previous state. 2. when a parity error occurs, receive data is transferred to rdr but rdrf is not set. while per is set to 1, data receiving cannot be continued. while per is set to 1 in synchronous mode, data transmission and reception cannot be performed. 228
bit 2: transmit end (tend) bit 2 is a status flag indicating that tdre was set to 1 when the last bit of a transmitted character was sent. tend is a read-only bit and cannot be modified. bit 2 tend description 0 indicates that transmission is in progress clearing conditions: after reading tdre = 1, cleared by writing 0 to tdre. when data is written to tdr by an instruction. 1 indicates that a transmission has ended (initial value) setting conditions: when bit te in scr3 is cleared to 0. if tdre is set to 1 when the last bit of a transmitted character is sent. bit 1: multiprocessor bit receive (mpbr) bit 1 holds the multiprocessor bit in data received in asynchronous mode using a multiprocessor format. mpbr is a read-only bit and cannot be modified. bit 1 mpbr description 0 indicates reception of data in which the multiprocessor bit is 0 * (initial value) 1 indicates reception of data in which the multiprocessor bit is 1 note: * if bit re in scr3 is cleared to 0 while a multiprocessor format is in use, mpbr retains its previous state. 229
bit 0: multiprocessor bit transmit (mpbt) bit 0 holds the multiprocessor bit to be added to transmitted data when a multiprocessor format is used in asynchronous mode. bit mpbt is ignored when synchronous mode is chosen, when the multiprocessor communication function is disabled, or when data transmission is disabled. bit 0 mpbt description 0 the multiprocessor bit in transmit data is 0 (initial value) 1 the multiprocessor bit in transmit data is 1 8. bit rate register (brr) the bit rate register (brr) is an 8-bit register which, together with the baud rate generator clock selected by bits cks1 and cks0 in the serial mode register (smr), sets the transmit/receive bit rate. brr can be read or written by the cpu at any time. brr is initialized to h'ff upon reset or in standby mode, watch mode, subactive mode, or subsleep mode. table 10-6 gives examples of how brr is set in asynchronous mode. the values in table 10-6 are for active (high-speed) mode. bit initial value read/write 7 brr7 1 r/w 6 brr6 1 r/w 5 brr5 1 r/w 4 brr4 1 r/w 3 brr3 1 r/w 0 brr0 1 r/w 2 brr2 1 r/w 1 brr1 1 r/w 230
table 10-6 brr settings and bit rates in asynchronous mode (1) osc (mhz) 2 2.4576 4 4.194304 bit rate error error error error (bits/s) n n (%) n n (%) n n (%) n n (%) 110 1 70 +0.03 1 86 +0.31 1 141 +0.03 1 148 ?.04 150 0 207 +0.16 0 255 0 1 103 +0.16 1 108 +0.21 300 0 103 +0.16 0 127 0 0 207 +0.16 0 217 +0.21 600 0 51 +0.16 0 63 0 0 103 +0.16 0 108 +0.21 1200 0 25 +0.16 0 31 0 0 51 +0.16 0 54 ?.70 2400 0 12 +0.16 0 15 0 0 25 +0.16 0 26 +1.14 4800 0 7 0 0 12 +0.16 0 13 ?.48 9600 0 3 0 0 6 ?.48 19200 0 1 0 31250 0 0 0 0 1 0 38400 0 0 0 table 10-6 brr settings and bit rates in asynchronous mode (2) osc (mhz) 4.9152 6 7.3728 8 bit rate error error error error (bits/s) n n (%) n n (%) n n (%) n n (%) 110 1 174 ?.26 1 212 +0.03 2 64 +0.70 2 70 +0.03 150 1 127 0 1 155 +0.16 1 191 0 1 207 +0.16 300 0 255 0 1 77 +0.16 1 95 0 1 103 +0.16 600 0 127 0 0 155 +0.16 0 191 0 0 207 +0.16 1200 0 63 0 0 77 +0.16 0 95 0 0 103 +0.16 2400 0 31 0 0 38 +0.16 0 47 0 0 51 +0.16 4800 0 15 0 0 19 ?.34 0 23 0 0 25 +0.16 9600 0 7 0 0 9 ?.34 0 11 0 0 12 +0.16 19200 0 3 0 0 4 ?.34 0 5 0 31250 0 2 0 0 3 0 38400 0 1 0 0 2 0 231
table 10-6 brr settings and bit rates in asynchronous mode (3) osc (mhz) 9.8304 10 bit rate error error (bits/s) n n (%) n n (%) 110 2 86 +0.31 2 88 ?.25 150 1 255 0 2 64 +0.16 300 1 127 0 1 129 +0.16 600 0 255 0 1 64 +0.16 1200 0 127 0 0 129 +0.16 2400 0 63 0 0 64 +0.16 4800 0 31 0 0 32 ?.36 9600 0 15 0 0 15 +1.73 19200 0 7 0 0 7 +1.73 31250 0 4 ?.70 0 4 0 38400 0 3 0 0 3 +1.73 notes: 1. settings should be made so that error is within 1%. 2. brr setting values are derived by the following equation. n = 10 6 ?1 b: bit rate (bits/s) n: brr baud rate generator setting (0 n 255) osc: value of osc (mhz) n: baud rate generator input clock number (n = 0, 1, 2, 3) the meaning of n is shown in table 10-7. table 10-7 relation between n and clock smr setting n clock cks1 cks0 0 0 0 1 ?4 0 1 2 ?16 1 0 3 ?64 1 1 osc 64 2 2n b 232
3. the error values in table 10-6 were derived by performing the following calculation and rounding off to two decimal places. error (%) = 100 b: bit rate found from n, n, and osc r: bit rate listed in left column of table 10-6 table 10-8 shows the maximum bit rate for selected frequencies in asynchronous mode. values in table 10-8 are for active (high-speed) mode. table 10-8 maximum bit rate at selected frequencies (asynchronous mode) setting osc (mhz) maximum bit rate (bits/s) n n 2 31250 0 0 2.4576 38400 0 0 4 62500 0 0 4.194304 65536 0 0 4.9152 76800 0 0 6 93750 0 0 7.3728 115200 0 0 8 125000 0 0 9.8304 153600 0 0 10 156250 0 0 233 b ?r r
table 10-9 shows typical brr settings in synchronous mode. values in table 10-9 are for active (high-speed) mode. table 10-9 typical brr settings and bit rates (synchronous mode) osc (mhz) 24810 n n nn nn nn 110 250 1 249 2 124 2 249 500 1 124 1 249 2 124 1k 0 249 1 124 1 249 2.5k 0 99 0 199 1 99 1 124 5k 0 49 0 99 0 199 0 249 10k 0 24 0 49 0 99 0 124 25k 0 9 0 19 0 39 0 49 50k 0 4 0 9 0 19 0 24 100k 0 4 0 9 250k 0 0 * 01 03 04 500k 0 0 * 01 1m 0 0 * 2.5m notes: blank: cannot be set ? can be set, but error will result * : continuous transmit/receive operation is not possible at this setting brr setting values are derived by the following equation. n = 10 6 ?1 b: bit rate (bits/s) n: brr baud rate generator setting (0 n 255) osc: value of osc (mhz) n: baud rate generator input clock number (n = 0, 1, 2, 3) bit rate (bits/s) osc 8 2 2n b 234
the meaning of n is shown in table 10-10. table 10-10 relation between n and clock smr setting n clock cks1 cks0 0 0 0 1 ?4 0 1 2 ?16 1 0 3 ?64 1 1 10.3.3 operation sci3 supports serial data communication in both asynchronous mode, where each character transferred is synchronized separately, and synchronous mode, where transfer is synchronized by clock pulses. the choice of asynchronous mode or synchronous mode, and the communication format, is made in the serial mode register (smr), as shown in table 10-11. the sci3 clock source is determined by bit com in smr and bits cke1 and cke0 in serial control register 3 (scr3), as shown in table 10-12. 1. asynchronous mode data length: choice of 7 bits or 8 bits choice for the addition of a parity bit, the multiprocessor bit as well as one or two stop bits (these options determine the transmit/receive format and the character length). framing error (fer), parity error (per), overrun error (oer), and break signal can be detected when data is received. clock source: choice of internal clocks or an external clock when an internal clock is selected: operates on baud rate generator clock. a clock can be output with the same frequency as the bit rate. when an external clock is selected: a clock input with a frequency 16 times the bit rate is required (internal baud rate generator is not used). 235
2. synchronous mode transfer format: 8 bits overrun errors can be detected when data is received. clock source: choice of internal clocks or an external clock when an internal clock is selected: operates on baud rate generator clock, and outputs a serial clock. when an external clock is selected: the internal baud rate generator is not used. operation is synchronous with the input clock. table 10-11 smr settings and sci3 communication format smr setting communication format bit 7 bit 6 bit 2 bit 5 bit 3 multipro- parity stop bit com chr mp pe stop mode data length cessor bit bit length 00000 8-bit data none none 1 bit 1 2 bits 1 0 yes 1 bit 1 2 bits 1 0 0 7-bit data none 1 bit 1 2 bits 1 0 yes 1 bit 1 2 bits 01 * 0 8-bit data yes none 1 bit * 1 2 bits 1 * 0 7-bit data 1 bit * 1 2 bits 1 * 0 ** synchronous 8-bit data none none mode note: * don? care asynchronous mode (multiprocessor format) asynchronous mode 236
table 10-12 smr and scr3 settings and clock source selection smr scr3 transmit/receive clock bit 7 bit 1 bit 0 clock com cke1 cke0 mode source pin sck 3 function 0 0 0 internal i/o port (sck 3 pin not used) 1 outputs clock with same frequency as bit rate 1 0 external 1 0 0 internal outputs a serial clock 1 0 external inputs a serial clock 0 1 1 reserved (illegal settings) 101 111 3. continuous transmit/receive operation using interrupts continuous transmit and receive operations are possible with sci3, using the rxi or txi interrupts. table 10-13 explains this use of these interrupts. table 10-13 transmit/receive interrupts interrupt flag interrupt conditions remarks rxi rdrf rie when serial data is received the rxi interrupt handling routine normally and receive data reads the receive data from rdr is transferred from rsr to rdr, and clears rdrf to 0. rdrf is set to 1. if rie is 1 at continuous data reception is possible this time, rxi is enabled and an by performing these operations interrupt occurs. before the reception of the next (see figure 10-4 (a).) serial data in rsr is completed. txi tdre tie when tsr empty (previous trans- the txi interrupt handling routine mission complete) is detected and writes the next transmit data to the transmit data set in tdr is tdr and clears tdre to 0. transferred to tsr, tdre is continuous data transmission is set to 1. if tie is 1 at this time, possible by performing these txi is enabled and an interrupt operations before the transmission occurs. (see figure 10-4 (b).) of data transferred to tsr is completed. tei tend teie when the last bit of the tsr tei indicates that, when the last transmit character has been sent, bit of the tsr transmit character if tdre is 1, then 1 is set in tend. was sent, the next transmit data if teie is 1 at this time, tei is had not been written to tdr. enabled and an interrupt occurs. (see figure 10-4 (c).) clock should be input with frequency 16 times the desired bit rate asynchronous mode synchronous mode 237
figure 10-4 (a) rdrf setting and rxi interrupt figure 10-4 (b) tdre setting and txi interrupt figure 10-4 (c) tend setting and tei interrupt rdr rsr (receiving) rxd pin rdrf = 0 rdr rsr (received and transferred) rxd pin rdrf 1 (rxi requested if rie = 1) tdr (next transmit data) tsr (transmitting) txd pin tdre = 0 tdr tsr (transmission complete, next data transferred) txd pin tdre 1 (txi requested if tie = 1) tdr tsr (transmitting) txd pin tend = 0 tdr tsr (transmission complete) txd pin tend 1 (tei requested if teie = 1) 238
10.3.4 operation in asynchronous mode in asynchronous communication mode, a start bit indicating the start of communication and a stop bit (1 or 2 bits) indicating the end of communication are added to each character that is sent/ received. in this way synchronization is achieved for each character as a self-contained unit. sci3 consists of independent transmit and receive modules, giving it the capability of full duplex communication. both the transmit and receive modules have a double-buffer configuration, allowing data to be read or written during communication operations so that data can be transmitted and received continuously. 1. transmit/receive formats figure 10-5 shows the general format for asynchronous serial communication. the communication line in asynchronous communication mode normally stays at the high level, in the ?ark?state. sci3 monitors the communication line, and begins serial data communication when it detects a ?pace?(low-level signal), which is regarded as a start bit. one character consists of a start bit (low level), transmit/receive data (in lsb-first order), a parity bit (high or low level), and finally a stop bit (high level), in this order. in asynchronous data receiving, synchronization is carried out at the falling edge of the start bit. sci3 samples data on the 8th pulse of a clock that has 16 times the frequency of one-bit interval, so each bit of data is latched at its center. figure 10-5 data format in asynchronous serial communication mode serial data one unit of data (character or frame) start bit transmit or receive data parity bit (msb) stop bit 1 bit 1 bit or none 1 or 2 bits 7 or 8 bits mark state (lsb) 1 239
table 10-14 shows the 12 formats that can be selected in asynchronous mode. the format is selected in the serial mode register (smr). table 10-14 serial communication formats in asynchronous mode 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 0 0 0 0 0 0 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 * * * * chr pe mp stop smr setting 123456789101112 s s s s s s s s s s s s stop stop p p mpb mpb stop stop p p stop stop stop mpb mpb stop stop stop stop stop stop stop stop stop stop stop serial communication format and frame length 8-bit data 8-bit data 8-bit data 8-bit data 7-bit data 7-bit data 7-bit data 7-bit data 8-bit data 8-bit data 7-bit data 7-bit data notation: * don? care s: stop: p: mpb: start bit stop bit parity bit multiprocessor bit note: 240
2. clock the clock source is determined by bit com in smr and bits cke1 and cke0 in serial control register 3 (scr3). see table 10-12 for the settings. either an internal clock source can be used to run the built-in baud rate generator, or an external clock source can be input at pin sck 3 . when an external clock source is input to pin sck 3 , it should have a frequency 16 times the desired bit rate. when an internal clock source is used, sck 3 can be used as the clock output pin. the clock output has the same frequency as the serial bit rate, and is synchronized as in figure 10-6 so that the rising edge of the clock occurs in the center of each bit of transmit/receive data. figure 10-6 phase relation of output clock and communication data in asynchronous mode (8-bit data, parity bit added, and 2 stop bits) 3. data transmit/receive operations sci3 initialization before data is sent or received, bits te and re in serial control register 3 (scr3) must be cleared to 0, after which initialization can be performed using the procedure. note: when modifying the operation mode, transfer format or other settings, always be sure to clear bits te and re first. when te is cleared to 0, bit tdre will be set to 1. clearing re does not clear the status flags rdrf, per, fer, or oer, or alter the contents of the receive data register (rdr). when an external clock is used in asynchronous mode, do not stop the clock during operation, including during initialization. when an external clock is used in synchronous mode, do not supply the clock during initialization. serial data 1 character (1 frame) 0 d0d1d2d3d4d5d6d70/1 1 1 clock 241
figure 10-7 shows a typical flow chart for sci3 initialization. figure 10-7 typical flow chart when sci3 is initialized start clear te and re to 0 in scr3 select communication format in smr set brr value has a 1-bit interval elapsed? set bits rie, tie, teie, and mpie in scr3, and set te or re to 1 2 3 4 2. 3. 4. 1. set the transmit/receive format in the serial mode register (smr). write the value corresponding to the desired bit rate to the bit rate register (brr). note that this setting is not required when using an external clock. wait for at least a 1-bit interval, then set bits rie, tie, teie, and mpie, and set bit te or re in scr3 to 1. setting te or re no yes wait end enables sci3 to use the txd or rxd pin. the initial states in asynchronous mode are the mark transmit state and the idle receive state (waiting for a start bit). 1 set bits cke1 and cke0 select the clock using serial control register 3(scr3). be sure to set 0 for other unused bits. when the clock output is selected in the asynchronous mode, a clock signal is output immediately after setting bits cke1 and cke0 appropriately. when the clock output is selected in the synchronous mode, a clock signal is output immediately after setting bits cke1 and cke0 appropriately and setting bit re to 1. 242
transmitting figure 10-8 shows a typical flow chart for data transmission. after sci3 initialization, follow the procedure below. figure 10-8 typical data transmission flow chart (asynchronous mode) start read bit tdre in ssr tdre = 1? write transmit data in tdr continue data transmission? tend = 1? read bit tend in ssr break output? set pdr = 0 and pcr = 1 clear bit te in scr3 to 0 end 1 2 3 1. 2. 3. read the serial status register (srr), and after confirming that bit tdre = 1, write transmit data in the transmit data register (tdr). when data is written to tdr, tdre is automatically cleared to 0. to continue transmitting data, first read tdre to confirm that it is set to 1, indicating that data writing is enabled, then write the next data to tdr. when data is written to tdr, tdre is automatically cleared to 0. to output a break signal when transmission ends, first set the port values pcr = 1 and pdr = 0, then clear bit te in scr3 to 0. no yes no no yes no yes yes 243
sci3 operates as follows during data transmission in asynchronous mode. sci3 monitors bit tdre in ssr. when this bit is cleared to 0, sci3 recognizes that there is data written in the transmit data register (tdr), which it transfers to the transmit shift register (tsr). then tdre is set to 1 and transmission starts. if bit tie in scr3 is set to 1, a txi interrupt is requested. serial data is transmitted from pin txd using the communication format outlined in table 10-14. after that, it checks tdre at the same timing which it transmits the stop bit. if tdre is 0, data is transferred from tdr to tsr, and after the stop bit is sent, transmission of the next frame starts. if tdre is 1, the tend bit in ssr is set to 1, and after the stop bit is sent, the ?ark state?is entered, in which 1 is continuously output. a tei interrupt is requested in this state if bit teie in scr3 is set to 1. figure 10-9 shows a typical operation in asynchronous transmission mode. figure 10-9 typical transmit operation in asynchronous mode (8-bit data, parity bit added, and 1 stop bit) 0 d0 d1 d7 0/1 1 d0 d1 d7 0/1 1 0 start bit parity bit stop bit parity bit stop bit 1 start bit mark state tdre tend txi request tei request 1 frame txi request serial data transmit data transmit data 1 frame sci3 operation user processing tdre cleared to 0 1 write data in tdr 244
receiving figure 10-10 shows a typical flow chart for receiving serial data. after sci3 initialization, follow the procedure below. figure 10-10 typical serial data receiving flow chart in asynchronous mode start read bits oer, per, and fer in ssr read bit rdrf in ssr continue receiving? clear bit re in scr3 to 0 end 1 yes yes no no 1. read bits oer, per, and fer in the serial status register (ssr) to determine if a receive error has occurred. if a receive error has occurred, receive error processing is executed. oer = 1? fer = 1? per = 1? clear bits oer, per, and fer in ssr to 0 overrun error processing break? framing error processing parity error processing yes yes yes no no no yes no 4 receive error processing end receive error processing 4 a start receive error processing a oer + per + fer = 1 rdrf = 1? no yes 2. read the serial status register (ssr), and after confirming that bit rdrf = 1, read received data from the receive data register (rdr). when rdr data is read, rdrf is automatically cleared to 0. 3. to continue receiving data, read bit rdrf and finish reading rdr before the stop bit of the present frame is received. when data is read from rdr, rdrf is automatically cleared to 0. 4. when a receive error occurs, read bits oer, per, and fer in ssr to determine which error (s) occurred. after the necessary error processing, be sure to clear the above bits all to 0. data receiving cannot be resumed while any of bits oer, per, or fer is set to 1. when a framing error occurs, a break can be detected by reading the rxd pin value. 2 read received data in rdr 3 245
sci3 operates as follows when receiving serial data in asynchronous mode. sci3 monitors the communication line, and when a start bit (0) is detected it performs internal synchronization and starts receiving. the communication format for data receiving is as outlined in table 10-14. received data is set in rsr in order of lsb to msb, then the parity bit and stop bit(s) are received. after receiving the data, sci3 performs the following checks: parity check: the number of 1s in receive data is checked to see if it matches the odd or even parity selected in bit pm of smr. stop bit check: the stop bit is checked for a value of 1. if there are two stop bits, only the first bit is checked. status check: the rdrf bit is checked for a value of 0 to make sure received data can be transferred from rsr to rdr. if no receive error is detected by the above checks, bit rdrf is set to 1 and the received data is stored in rdr. at that time, if bit rie in scr3 is set to 1, an rxi interrupt is requested. if the error check detects a receive error, the appropriate error flag (oer, per, or fer) is set to 1. rdrf retains the same value as before the data was received. if at this time bit rie in scr3 is set to 1, an eri interrupt is requested. table 10-15 gives the receive error detection conditions and the processing of received data in each case. note: data receiving cannot be continued while a receive error flag is set. before continuing the receive operation it is necessary to clear the oer, fer, per, and rdrf flags to 0. table 10-15 receive error conditions and received data processing receive error abbrev. detection conditions received data processing overrun error oer receiving of the next data ends while received data is not bit rdrf in ssr is still set to 1 transferred from rsr to rdr framing error fer stop bit is 0 received data is transferred from rsr to rdr parity error per received data does not match the received data is transferred parity (odd/even) set in smr from rsr to rdr 246
figure 10-11 shows a typical sci3 data receive operation in asynchronous mode. figure 10-11 typical receive operation in asynchronous mode (8-bit data, parity bit added, and 1 stop bit) 10.3.5 operation in synchronous mode in synchronous mode, data is sent or received in synchronization with clock pulses. this mode is suited to high-speed serial communication. sci3 consists of independent transmit and receive modules, so full duplex communication is possible, sharing the same clock between both modules. both the transmit and receive modules have a double-buffer configuration. this allows data to be written during a transmit operation so that data can be transmitted continuously, and enables data to be read during a receive operation so that data can be received continuously. 1. transmit/receive format figure 10-12 shows the general communication data format for synchronous communication. 0 d0 d1 d7 0/1 1 d0 d1 d7 0/1 0 0 start bit parity bit stop bit parity bit stop bit 1 start bit mark (idle state) rdrf fer 1 frame serial data rxi request detects stop bit = 0 eri request due to framing error 1 frame 1 sci3 operation receive data receive data read rdr data user processing rdrf cleared to 0 framing error handling 247
figure 10-12 data format in synchronous communication mode in synchronous communication, data is output to the communication line during the period from one falling edge of the synchronous clock to the next falling edge. one character of data starts from the lsb and ends with the msb. the communication line retains the msb state after the msb is output. in synchronous receive mode, sci3 latches receive data in synchronization with the rising edge of the serial clock. the transmit/receive format is fixed at 8-bit data. no parity bit or multiprocessor bit is added in this mode. 2. clock either an internal clock from the built-in baud rate generator is used, or an external clock is input at pin sck 3 . the choice of clock sources is designated by bit com in smr and bits cke1 and cke0 in serial control register 3 (scr3). see table 10-12 for details on selecting the clock source. when operation is based on an internal clock, a serial clock is output at pin sck 3 . eight clock pulses are output per character of transmit/receive data. when no transmit or receive operation is being performed, the pin is held at the high level. note: at high level except during continuous transmit/receive. serial data serial clock one unit of communication data (character or frame) bit 0 bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 don't care don't care * * * lsb msb 8 bits 248
3. data transmit/receive operations sci3 initialization before transmitting or receiving data, follow the sci3 initialization procedure explained under 10.3.4, sci3 initialization, and illustrated in figure 10-7. transmitting figure 10-13 shows a typical flow chart for data transmission. after sci3 initialization, follow the procedure below. figure 10-13 typical data transmission flow chart in synchronous mode start read bit tdre in ssr tdre = 1? write transmit data in tdr continue data transmission? read bit tend in ssr tend = 1? write 0 to bit te in scr3 end no yes no yes no yes 1 2 1. 2. read the serial status register (ssr), and after confirming that bit tdre = 1, write transmit data in the transmit data register (tdr). when data is written to tdr, tdre is automatically cleared to 0. if clock output has been selected, after data is written to tdr, the clock is output and data transmission begins. to continue transmitting data, first read tdre to confirm that it is set to 1, indicating that data writing is enabled; then write the next data to tdr. when data is written to tdr, tdre is automatically cleared to 0. 249
sci3 operates as follows during data transmission in synchronous mode. sci3 monitors bit tdre in ssr. when this bit is cleared to 0, sci3 recognizes that there is data written in the transmit data register (tdr), which it transfers to the transmit shift register (tsr). then tdre is set to 1 and transmission starts. if bit tie in scr3 is set to 1, a txi interrupt is requested. if clock output is selected, sci3 outputs eight serial clock pulses. if an external clock is used, data is output in synchronization with the clock input. serial data is transmitted from pin txd in order from lsb (bit 0) to msb (bit 7). after that, it checks tdre at the same timing which it transmits the msb (bit 7). if tdre is 0, data is transferred from tdr to tsr, and after the msb (bit 7) is sent, transmission of the next frame starts. if tdre is 1, the tend bit in ssr is set to 1, and after the msb (bit 7) is sent, the msb state is maintained. a tei interrupt is requested in this state if bit teie in scr3 is set to 1. after data transmission ends, pin sck 3 is held at the high level. note: data transmission cannot take place while any of the receive error flags (oer, fer, per) is set to 1. be sure to confirm that these error flags are cleared to 0 before starting transmission. figure 10-14 shows a typical sci3 transmit operation in synchronous mode. figure 10-14 typical sci3 transmit operation in synchronous mode serial clock serial data tdre tend bit 0 bit 7 bit 0 bit 1 bit 6 bit 7 bit 1 txi request tdre cleared to 0 txi request tei request 1 frame 1 frame sci3 operation user processing write data in tdr 250
receiving figure 10-15 shows a typical flow chart for receiving data. after sci3 initialization, follow the procedure below. figure 10-15 typical data receiving flow chart in synchronous mode start read bit oer in ssr read bit rdrf in ssr read received data in rdr oer = 1? continue receiving? clear bit re in scr3 to 0 end clear bit oer in ssr to 0 1 3 4 4 2. 3. 4. read the serial status register (ssr), and after confirming that bit rdrf = 1, read received data from the receive data register (rdr). when data is read from rdr, rdrf is automatically cleared to 0. 1. read bit oer in the serial status register (ssr) to determine if an error has occurred. if an overrun error has occurred, overrun error processing is executed. to continue receiving data, read bit rdrf and read the received data in rdr before the msb (bit 7) of the present frame is received. when data is read from rdr, rdrf is automatically cleared to 0. when an overrun error occurs, read bit oer in ssr. after the necessary error processing, be sure to clear oer to 0. data receiving cannot be resumed while bit oer is set to 1. yes yes no no rdrf = 1? no yes overrun error processing start overrun processing end overrun error processing overrun error processing 2 251
sci3 operates as follows when receiving serial data in synchronous mode. in synchronization with the input or output of the serial clock, sci3 initializes internally and starts receiving. received data is set in rsr from lsb to msb. after data has been received, sci3 checks to confirm that the value of bit rdrf is 0 indicating that received data can be transferred from rsr to rdr. if this check passes, rdrf is set to 1 and the received data is stored in rdr. at this time, if bit rie in scr3 is set to 1, an rxi interrupt is requested. if an overrun error is detected, oer is set to 1 and rdrf remains set to 1. then if bit rie in scr3 is set to 1, an eri interrupt is requested. for the overrun error detection conditions and receive data processing, see table 10-3-12. note: data receiving cannot be continued while a receive error flag is set. before continuing the receive operation it is necessary to clear the oer, fer, per, and rdrf flags to 0. figure 10-16 shows a typical receive operation in synchronous mode. figure 10-16 typical receive operation in synchronous mode serial clock serial data rdrf oer sci3 operation user processing bit 7 bit 0 bit 7 bit 0 bit 1 bit 6 bit 7 1 frame 1 frame rxi request rdrf cleared to 0 rxi request read data from rdr eri request due to overrun error rdr data not read (rdrf = 1) overrun error handling 252
simultaneous transmit/receive figure 10-17 shows a typical flow chart for transmitting and receiving simultaneously. after sci3 synchronization, follow the procedure below. figure 10-17 simultaneous transmit/receive flow chart in synchronous mode start read bit tdre in ssr read rdrf in ssr rdrf = 1? read received data in rdr read bit oer in ssr oer = 1? continue transmitting and receiving? clear bits te and re in scr3 to 0 end 1 1. 2. 3. 4. 4 read the serial status register (ssr), and after confirming that bit tdre = 1, write transmit data in the transmit data register (tdr). when data is written to tdr, tdre is automatically cleared to 0. read the serial status register (ssr), and after confirming that bit rdrf = 1, read the received data from the receive data register (rdr). when data is read from rdr, rdrf is automatically cleared to 0. to continue transmitting and receiving serial data, read bit rdrf and finish reading rdr before the msb (bit 7) of the present frame is received. also read bit when an overrun error occurs, read bit oer in ssr. after the necessary error processing, be sure to clear oer to 0. data transmission and reception cannot take place while bit oer is set to 1. see figure 10-3-13 for overrun error processing. tdre = 1? no no yes yes yes no 3 no yes write transmit data in tdr overrun error processing tdre, check that it is set to 1, and write the next data in tdr before the msb of the current frame has been transmitted. when data is written to tdr, tdre is automatically cleared to 0; and when data is read from rdr, rdrf is automatically cleared to 0. 2 253
notes: 1. to switch from transmitting to simultaneous transmitting and receiving, first confirm that tdre and tend are both set to 1 and that sci3 has finished transmitting. next clear te to 0. then set both te and re to 1. 2. to switch from receiving to simultaneous transmitting and receiving, after confirming that sci3 has finished receiving, clear re to 0. next, after confirming that rdrf and the error flags (oer fer, per) are all 0, set both te and re to 1. 10.3.6 multiprocessor communication function the multiprocessor communication function enables several processors to share a single serial communication line. the processors communicate in asynchronous mode using a format with an additional multiprocessor bit (multiprocessor format). in multiprocessor communication, each receiving processor is addressed by an id code. a serial communication cycle consists of two cycles: an id-sending cycle that identifies the receiving processor, and a data-sending cycle. the multiprocessor bit is 1 in an id-sending cycle, and 0 in a data-sending cycle. the transmitting processor starts by sending the id of the receiving processor with which it wants to communicate as data with the multiprocessor bit set to 1. next the transmitting processor sends transmit data with the multiprocessor bit cleared to 0. when a receiving processor receives data with the multiprocessor bit set to 1, it compares the data with its own id. if the data matches its id, the receiving processor continues to receive incoming data. if the data does not match its id, the receiving processor skips further incoming data until it again receives data with the multiprocessor bit set to 1. multiple processors can send and receive data in this way. figure 10-18 shows an example of communication among different processors using a multiprocessor format. 254
figure 10-18 example of interprocessor communication using multiprocessor format (data h'aa sent to receiving processor a) four communication formats are available. parity-bit settings are ignored when a multiprocessor format is selected. for details see table 10-14. for a description of the clock used in multiprocessor communication, see 10.3.4, operation in asynchronous mode. transmitting processor receiving processor a communication line receiving processor b receiving processor c receiving processor d serial data id-sending cycle (receiving processor address) data-sending cycle (data sent to receiving processor designated by id) (id = 01) (id = 02) (id = 03) (id = 04) h'01 h'aa (mpb = 1) (mpb = 0) mpb: multiprocessor bit 255
transmitting multiprocessor data figure 10-19 shows a typical flow chart for multiprocessor serial data transmission. after sci3 initialization, follow the procedure below. figure 10-19 typical multiprocessor data transmission flow chart start read bit tdre in ssr tdre = 1? set bit mpbt in ssr write transmit data to tdr continue transmitting? read bit tend in ssr tend = 1? break output? set pdr = 0 and pcr = 1 clear bit te in scr3 to 0 end 1 2 3 2. 3. 1. to continue transmitting data, read bit tdre to make sure it is set to 1, indicating that data writing is enabled. then write the next data to tdr. when data is written to tdr, tdre is automatically cleared to 0. to output a break signal at the end of data transmission, first set the port values pcr = 1 and pdr = 0, then clear bit te in scr3 to 0. read the serial status register (ssr), and after confirming that bit tdre = 1, set bit mpbt (multiprocessor bit transmit) in ssr to 0 or 1, then write transmit data in the transmit data register (tdr). no yes no no yes no yes yes when data is written to tdr, tdre is automatically cleared to 0. 256
sci3 operates as follows during data transmission using a multiprocessor format. sci3 monitors bit tdre in ssr. when this bit is cleared to 0, sci3 recognizes that there is data written in the transmit data register (tdr), which it transfers to the transmit shift register (tsr). then tdre is set to 1 and transmission starts. if bit tie in scr3 is set to 1, a txi interrupt is requested. serial data is transmitted from pin txd using the communication format outlined in table 10-13. next, tdre is checked as the stop bit is being transmitted. if tdre is 0, data is transferred from tdr to tsr, and after the stop bit is sent, transmission of the next frame starts. if tdre is 1, the tend bit in ssr is set to 1, and after the stop bit is sent the output remains at 1 (mark state). a tei interrupt is requested in this state if bit teie (transmit end interrupt enable) in scr3 is set to 1. figure 10-20 shows a typical sci3 operation in multiprocessor communication mode. figure 10-20 typical multiprocessor format transmit operation (8-bit data, multiprocessor bit added, and 1 stop bit) 0d0d1 d7 d0 d1 0 d7 1 0/1 1 0/1 start bit start bit stop bit stop bit mpb mpb 1 tdre tend tdre cleared to 0 txi request tei request 1 frame txi request serial data transmit data transmit data mark state 1 frame sci3 operation user processing write data in tdr 1 257
receiving multiprocessor data figure 10-21 shows a typical flow chart for receiving data using a multiprocessor format. after sci3 initialization, follow the procedure below. figure 10-21 typical flow chart for receiving serial data using multiprocessor format start set bit mpie in scr3 to 1 read bits oer and fer in ssr read bit rdrf in ssr rdrf = 1? read received data in rdr oer + fer = 1? read bits oer and fer in ssr continue receiving? end clear bit re in scr3 to 0 start receive error processing oer = 1? fer = 1? clear bits oer and fer in ssr to 0. overrun error processing break? framing error processing 1 2 1. 2. 4. 5. set bit mpie in serial control register 3 (scr3) to 1. read bits oer and fer in the serial status register (ssr) to determine if an error has occurred. if a receive error has occurred, receive error processing is executed. read ssr, check that bit rdrf = 1, then read received data from the receive data register (rdr). if a receive error occurs, read bits oer and fer in ssr to determine which error occurred. after the necessary error processing, be sure to clear the error flags to 0. data reception cannot resume while bit oer or fer is set to 1. when a framing error occurs, a break can be detected by reading the rxd pin value. no yes yes no yes no yes yes no no yes no error processing read received data in rdr a a end receive error processing own id? no read bit rdrf in ssr 4 oer + fer = 1? yes yes no rdrf = 1? no yes 5 3. if the received data does not match the id, set bit mpie to 1 again. bit rdrf is automatically cleared to 0 when data in the received data register (rdr) is read. read the serial status register (ssr) and confirm that rdrf = 1. if rdrf = 1, read the data in the received data register (rdr) and compare it with the processor? own id. 3 258
figure 10-22 gives an example of data reception using a multiprocessor format. figure 10-22 example of multiprocessor format receive operation (8-bit data, multiprocessor bit added, and 1 stop bit) 0 d0 d1 d7 1 d0 d1 d7 0 1 10 1 start bit stop bit stop bit start bit receive data (id1) receive data (data 1) mark (idle state) mpie rdrf rdr value rxi request mpie cleared to 0 rdrf cleared to 0 no rxi request rdr state retained (a) data does not match own id 0 d0 d1 d7 1 d0 d1 d7 0 1 10 1 start bit stop bit stop bit start bit receive data (id2) receive data (data 2) mark (idle state) mpb mpb mpb mpb mpie rdrf rdr value id1 (b) data matches own id 1 frame 1 frame 1 frame 1 frame id1 if not own id, set mpie to 1 again sci3 operation user processing rxi request mpie cleared to 0 rdrf cleared to 0 if own id, continue receiving sci3 operation user processing rdrf cleared to 0 read data from rdr and set mpie to 1 again data 2 serial data serial data 1 1 rxi request read data from rdr id2 read data from rdr 259
10.3.7 interrupts sci3 has six interrupt sources: transmit end, transmit data empty, receive data full, and the three receive error interrupts (overrun error, framing error, and parity error). all share a common interrupt vector. table 10-16 describes each interrupt. table 10-16 sci3 interrupts interrupt description vector address rxi interrupt request due to receive data register full (rdrf) h'0024 txi interrupt request due to transmit data register empty (tdre) tei interrupt request due to transmit end (tend) eri interrupt request due to receive error (oer, fer, or per) the interrupt requests are enabled and disabled by bits tie and rie of scr3. when bit tdre in ssr is set to 1, txi is requested. when bit tend in ssr is set to 1, tei is requested. these two interrupt requests occur during data transmission. the initial value of bit tdre is 1. accordingly, if the transmit data empty interrupt request (txi) is enabled by setting bit tie to 1 in scr3 before placing transmit data in tdr, txi will be requested even though no transmit data has been readied. likewise, the initial value of bit tend is 1. accordingly, if the transmit end interrupt request (tei) is enabled by setting bit teie to 1 in scr3 before placing transmit data in tdr, tei will be requested even though no data has been transmitted. these interrupt features can be used to advantage by programming the interrupt handler to move the transmit data into tdr. when this technique is not used, the interrupt enable bits (tie and teie) should not be set to 1 until after tdr has been loaded with transmit data, to avoid unwanted txi and tei interrupts. when bit rdrf in ssr is set to 1, rxi is requested. when any of ssr bits oer, fer, or per is set to 1, eri is requested. these two interrupt requests occur during the receiving of data. details on interrupts are given in 3.3, interrupts. 260
10.3.8 application notes when using sci3, attention should be paid to the following matters. 1. relation between bit tdre and writing data to tdr bit tdre in the serial status register (ssr) is a status flag indicating that tdr does not contain new transmit data. tdre is automatically cleared to 0 when data is written to tdr. when sci3 transfers data from tdr to tsr, bit tdre is set to 1. data can be written to tdr regardless of the status of bit tdre. however, if new data is written to tdr while tdre is cleared to 0, assuming the data held in tdr has not yet been shifted to tsr, it will be lost. for this reason, it is recommended for securing serial data transmission that writing transmit data to tdr should be performed only once (not two or more times), always after confirming that bit tdre is set to 1. 2. operation when multiple receive errors occur at the same time when two or more receive errors occur at the same time, the status flags in ssr are set as shown in table 10-17. if an overrun error occurs, data is not transferred from rsr to rdr, and receive data is lost. table 10-17 ssr status flag states and transfer of receive data ssr status flags rdrf * oer fer per receive error status 1100 overrun error 0010 l l framing error 0001 l l parity error 1110 overrun error + framing error 1101 overrun error + parity error 0011 l l framing error + parity error 1111 overrun error + framing error + parity error notation: l l : receive data transferred from rsr to rdr : receive data not transferred from rsr to rdr note: * rdrf keeps the same state as before the data was received. receive data transfer (rsr ? rdr) 261
3. break detection and processing break signals can be detected by reading the rxd pin directly when a framing error (fer) is detected. in the break state the input from the rxd pin consists of all 0s, so fer is set and the parity error flag (per) may also be set. in the break state sci3 continues to receive, so if the fer bit is cleared to 0 it will be set to 1 again. 4. sending a mark or break signal when te is cleared to 0 the txd pin becomes an i/o port, the level and direction (input or output) of which are determined by the pdr and pcr bits. this feature can be used to place the txd pin in the mark state or send a break signal. to place the serial communication line in the mark (1) state before te is set to 1, set the pdr and pcr bits both to 1. since te is cleared to 0, txd becomes a general i/o port outputting the value 1. to send a break signal during data transmission, set the pcr bit to 1 and clear the pdr bit to 0, then clear te to 0. when te is cleared to 0 the transmitter is initialized, regardless of its current state, so the txd pin becomes an i/o port outputting the value 0. 5. receive error flags and transmit operation (sysnchronous mode only) when a receive error flag (orer, per, or fer) is set to 1, sci3 will not start transmitting even if tdre is cleared to 0. be sure to clear the receive error flags to 0 when starting to transmit. note that clearing re to 0 does not clear the receive error flags. 6. receive data sampling timing and receive margin in asynchronous mode in asynchronous mode sci3 operates on a base clock with 16 times the bit rate frequency. in receiving, sci3 synchronizes internally with the falling edge of the start bit, which it samples on the base clock. receive data is latched at the rising edge of the eighth base clock pulse. see figure 10-23. 262
figure 10-23 receive data sampling timing in asynchronous mode the receive margin in asynchronous mode can therefore be derived from the following equation. m = {(0.5 ?1/2n) ?(d ?0.5) / n ?(l ?0.5) f} 100%.....................................equation (1) m: receive margin (%) n: ratio of clock frequency to bit rate (n = 16) d: clock duty cycle (d = 0.5 to 1) l: frame length (l = 9 to 12) f: absolute value of clock frequency error in equation (1), if f (absolute value of clock frequency error) = 0 and d (clock duty cycle) = 0.5, the receive margin is 46.875% as given by equation (2) below. when d = 0.5 and f = 0, m = {0.5 ?1/(2 16)} 100% = 46.875%...........................................................equation (2) this value is theoretical. in actual system designs a margin of from 20 to 30 percent should be allowed. 16 clock cycles 8 clock cycles start bit internal base clock receive data (rxd) synchronization sampling timing data sampling timing 07 15 7 150 d0 d1 0 263
7. relationship between bit rdrf and reading rdr while sci3 is receiving, it checks the rdrf flag. if the rdrf flag is cleared to 0 when the reception of one frame of data is completed, data reception ends normally. if rdrf is set to 1, an overrun error occurs. rdrf is automatically cleared to 0 when the contents of rdr are read. if rdr is read more than once, the second and later reads will be performed with rdrf cleared to 0. note that when rdr is read while rdrf is 0, data from the next frame may be read if this reading operation is carried out at the same time that the reception of the next frame is completed. this is illustrated in figure 10-24. figure 10-24 relationship between data and rdr read timing to avoid the situation described above, rdr reading should be carried out only once (not two or more times) after confirming that bit rdrf is set to 1. when reading rdr more than once, be sure to copy any data read for the first time to ram, for example, and use the copied data. also note that rdr reading should be carried out with a safe margin just before reception of the next frame is completed. more concretely, rdr reading should be completed before transferring bit 7 in the synchronous mode or before transferring the stop bit in the asynchronous mode. communica- tion line rdrf rdr frame 1 frame 2 frame 3 data 1 data 2 data 3 data 1 data 2 rdr read rdr read at a , data 1 is read. at b , data 2 is read. user processing a b 264
8. application notes for sck pin function switching when the sck3 pin function is changed from clock output to i/o port after having been used in clock synchronizing mode, an instantaneous (half period of system clock ? low level is output at the moment when the sck3 pin function changes. the following methods can be used to avoid this instantaneous low level output. if the sck3 pin is changed from clock output to non-output state: after halting signal transmission/reception, the te bit and re bit of serial control register 3 (scr3) should both be cleared to 0 with an instruction. at the same time, the cke1 bit and cke0 bit should be set to 1 and 0, respectively. in this method, leave the com bit of serial mode register (smr) set to 1, which means that this pin cannot be used as an i/o port. in addition, the line connected to the sck3 pin should be pulled up to vcc with a resistor, or output should be performed through other devices, so that intermediate potential is not applied to the sck3 pin. if the sck3 pin function is changed from clock output to i/o port: after halting signal transmission/reception, first, both the te bit and re bit of serial control register 3 (scr3) should be cleared to 0 with an instruction. at the same time, the cke1 bit and cke0 bit should be set to 1 and 0, respectively. then, the com bit of serial mode register (smr) should be cleared to 0. finally, both the cke1 and cke0 bit of scr3 should be cleared to 0. in this case also, make sure that an intermediate potential is not applied to the sck3 pin. 9. application notes for txd pin function switching when the txd pin function is changed from the data output to the i/o port after being used in the synchronous mode, a high level is output instantaneously (for one cycle of system clock ? at the same time when the txd pin function is switched. 265
section 11 dtmf generator 11.1 overview the h8/3877n series has an on-chip dual-tone multifrequency (dtmf) generator that can generate dtmf signals. a dtmf signal accesses a telephone switching system by a pair of sine waves. figure 11-1 shows the frequency matrix. the dtmf generator generates frequencies corresponding to the numbers and symbols on the keypad of a telephone set or facsimile machine. figure 11-1 dtmf frequencies 1 4 7 2 5 8 0 3 6 9 # a b c d * r1 (697 hz) r2 (770 hz) r3 (852 hz) r4 (941 hz) c1 (1,209 hz) c2 (1,336 hz) c3 (1,477 hz) c4 (1,633 hz) 267
11.1.1 features features of the dtmf generator are as follows. generates sine waves with dtmf frequencies from the system clock input at the osc pins (f osc ) the osc clock (1.2 mhz to 10 mhz, selectable in 400-khz steps) is divided to generate a 400-khz clock. input to a feedback loop with a modified programmable divider and sine- wave counter, this clock is used to generate sine waves with the dtmf frequencies. stable sine-wave output with low distortion sine waves are output from a high-precision resistor-ladder-type d/a converter. each cycle is divided into 32 segments to give a stable waveform with low distortion. composite or single waveform output register settings can select combined row-and-column-group output, or independent row- group or column-group output. 268
11.1.2 block diagram figure 11-2 shows a block diagram of the dtmf generator. figure 11-2 dtmf generator block diagram dtlr clock counter 400 khz 1.2 mhz to 10 mhz in 400-khz steps d/a sine-wave counter modified programmable divider dtcr feedback column section feedback toned vt ref f osc internal data bus row section dtlr: dtcr: dtmf load register dtmf control register d/a sine-wave counter modified programmable divider notation: 269
11.1.3 pin configuration table 11-1 shows the pins assigned to the dtmf generator. table 11-1 pin configuration name abbrev. i/o function dtmf output reference level vt ref reference level voltage for dtmf power supply pin output dtmf signal output pin toned output dtmf signal output 11.1.4 register configuration table 11-2 shows the register configuration of the dtmf generator. table 11-2 register configuration name abbrev. r/w initial value address dtmf control register dtcr r/w h'40 h'ffb2 dtmf load register dtlr r/w h'e0 h'ffb3 270
11.2 register descriptions 11.2.1 dtmf control register (dtcr) dtcr is an 8-bit read/write register that enables the dtmf generator, enables row and column output, and selects the output frequencies. upon reset, dtcr is initialized to h'40. bit 7: dtmf generator enable (dten) bit 7 enables or disables the dtmf generator. bit 7 dten description 0 dtmf generator is halted (initial value) 1 dtmf generator operates bit 6: reserved bit bit 6 is reserved: it is always read as 1, and cannot be modified. bit 5: column output enable (cloe) bit 5 enables or disables dtmf column signal output. bit 5 cloe description 0 dtmf column signal output is disabled (high-impedance) (initial value) 1 dtmf column signal output is enabled bit initial value read/write 7 dten 0 r/w 6 1 5 cloe 0 r/w 4 rwoe 0 r/w 3 clf1 0 r/w 0 rwf0 0 r/w 2 clf0 0 r/w 1 rwf1 0 r/w 271
bit 4: row output enable (rwoe) bit 4 enables or disables dtmf row signal output. bit 4 rwoe description 0 dtmf row signal output is disabled (high-impedance) (initial value) 1 dtmf row signal output is enabled bits 3 and 2: dtmf column signal output frequency 1 and 0 (clf1, clf0) bits 3 and 2 select the dtmf column signal frequency (c1 to c4). bit 3 bit 2 clf1 clf0 description 0 0 dtmf column signal output frequency: 1209 hz (c1) (initial value) 0 1 dtmf column signal output frequency: 1336 hz (c2) 1 0 dtmf column signal output frequency: 1447 hz (c3) 1 1 dtmf column signal output frequency: 1633 hz (c4) bits 1 and 0: dtmf row signal output frequency 1 and 0 (rwf1, rwf0) bits 1 and 0 select the dtmf row signal frequency (r1 to r4). bit 1 bit 0 rwf1 rwf0 description 0 0 dtmf row signal output frequency: 697 hz (r1) (initial value) 0 1 dtmf row signal output frequency: 770 hz (r2) 1 0 dtmf row signal output frequency: 852 hz (r3) 1 1 dtmf row signal output frequency: 941 hz (r4) 272
11.2.2 dtmf load register (dtlr) dtlr is an 8-bit read/write register that specifies the ratio by which the clock frequency at the osc pins is divided for input to the dtmf generator. upon reset, dtlr is initialized to h'e0. bits 7 to 5: reserved bits bits 7 to 5 are reserved: they are always read as 1, and cannot be modified. bits 4 to 0: osc clock division ratio 4 to 0 (dtl4 to dtl0) bits 4 to 0 specify a division ratio of the osc clock frequency which will generate a 400-khz clock for input to the dtmf generator. the ratio is set as a counter value from 3 to 25, corresponding to osc clock frequencies of 1.2 to 10 mhz (in 400-khz steps). description division ratio osc clock frequency 00000 illegal setting (initial value) 00001 illegal setting 00010 illegal setting 00011 3 1.2 mhz 00100 4 1.6 mhz ..... . . ..... . . ..... . . 11001 25 10 mhz 1101 * illegal setting 111 ** illegal setting note: * don? care these bits must be set to the correct value. normal dtmf signal output frequencies will not be obtained if these bits are set to a value not matching the clock input at the osc pins. operation is not guaranteed if these bits are set to a value other than 3 to 25. bit initial value read/write 7 1 6 1 5 1 4 dtl4 0 r/w 3 dtl3 0 r/w 0 dtl0 0 r/w 2 dtl2 0 r/w 1 dtl1 0 r/w bit 4 bit 3 bit 2 bit 1 bit 0 dtl4 dtl3 dtl2 dtl1 dtl0 273
11.3 operation 11.3.1 output waveform the dtmf generator outputs a row-group or column-group sine wave (dtmf signal) or a combined row-column waveform at the toned pin. these signals are generated by a high- precision resistor-ladder-type d/a converter circuit. the output frequency is selected by dtcr. figure 11-3 shows an equivalent circuit for the toned output. figure 11-4 shows the output waveform of an independent row-group or column-group signal. one cycle of the output is divided into 32 segments, giving a stable output with low distortion. figure 11-3 equivalent circuit for toned output figure 11-4 toned output waveform (independent row- or column-group output) control output control row column vt gnd ref toned 1234567891011121314151617181920212223242526272829303132 time slot vt gnd ref 274
table 11-3 indicates the frequency deviation between the dtmf signals output by the dtmf generator and the nominal (standard) signal values. table 11-3 frequency deviation of dtmf signals from nominal signals standard signal dtmf signal frequency symbol frequency (hz) output (hz) deviation (%) r1 697 694.44 ?.37 r2 770 769.23 ?.10 r3 852 851.06 ?.11 r4 941 938.97 ?.22 c1 1209 1212.12 0.26 c2 1336 1333.33 ?.20 c3 1477 1481.48 0.30 c4 1633 1639.34 0.39 11.3.2 programming the procedure for using the dtmf generator is given below. 1. set the osc clock division ratio in dtlr to match the frequency of the connected system clock oscillator (1.2 mhz to 10 mhz in 400-khz steps). 2. select a row (r1 to r4) and/or column (c1 to c4) frequency with bits clf1, clf0, rwf1, and rwf0 in dtcr. 3. select row and/or column output with the cloe and rwoe bits in dtcr, and set the dten bit to 1 to enable the dtmf generator. this procedure outputs the selected dtmf signal from the toned pin. 275
11.4 typical use figure 11-5 shows an example of the use of the dtmf generator. figure 11-5 connection to ha16808 ant 11.5 application notes when using the dtmf generator, note the following point: be sure that the dtlr setting (dtl4 to dtl0) matches the system clock frequency at the osc pins. normal dtmf signal output frequencies will not be obtained unless the dtlr setting matches the osc frequency. toned vt ref p1 4 h8/3877n dtmf v mute ref1 ha16808ant 91 92 22 19 20 11 2 k w +0.47 f 100 k w 360 k w 24 k w 2sc458 note: numbers at ends of signal lines are pin numbers of respective devices. 276
section 12 a/d converter 12.1 overview the h8/3877n series includes on-chip a resistance-ladder-based successive-approximation analog-to-digital converter, and can convert up to eight channels of analog input. 12.1.1 features the a/d converter has the following features. 8-bit resolution 8 input channels conversion time: approx. 12.4 ? per channel (at 5 mhz operation) built-in sample-and-hold function interrupt requested on completion of a/d conversion a/d conversion can be started by external trigger input analog conversion voltage range programmable at av ref pin 12.1.2 block diagram figure 12-1 shows a block diagram of the a/d converter. figure 12-1 block diagram of the a/d converter internal data bus amr adsr adrr control logic + com- parator an 0 an 1 an 2 an 3 an 4 an 5 an 6 an 7 adtrg av av av cc ref ss multiplexer reference voltage irrad av cc av ss notation: amr: adsr: adrr: a/d mode register a/d start register a/d result register 277
12.1.3 pin configuration table 12-1 shows the a/d converter pin configuration. table 12-1 pin configuration name abbrev. i/o function analog power supply pin av cc input power supply of analog part analog ground pin av ss input ground and reference voltage of analog part reference voltage pin av ref input analog reference voltage analog input pin 0 an 0 input analog input channel 0 analog input pin 1 an 1 input analog input channel 1 analog input pin 2 an 2 input analog input channel 2 analog input pin 3 an 3 input analog input channel 3 analog input pin 4 an 4 input analog input channel 4 analog input pin 5 an 5 input analog input channel 5 analog input pin 6 an 6 input analog input channel 6 analog input pin 7 an 7 input analog input channel 7 external trigger input pin adtrg input external trigger input for starting a/d conversion 12.1.4 register configuration table 12-2 shows the a/d converter register configuration. table 12-2 register configuration name abbrev. r/w initial value address a/d mode register amr r/w h'10 h'ffc4 a/d start register adsr r/w h'7f h'ffc6 a/d result register adrr r undefined h'ffc5 278
12.2 register descriptions 12.2.1 a/d result register (adrr) the a/d result register (adrr) is an 8-bit read-only register for holding the results of analog-to- digital conversion. adrr can be read by the cpu at any time, but the adrr values during a/d conversion are undefined. after a/d conversion is complete, the conversion result is stored in adrr as 8-bit data; this data is held in adrr until the next conversion operation starts. adrr is not cleared on reset. 12.2.2 a/d mode register (amr) amr is an 8-bit read/write register for specifying the a/d conversion speed, external trigger option, and the analog input pins. upon reset, amr is initialized to h'10. bit 7: clock select (cks) bits cks and cks1 select the a/d conversion speed. conversion time cks1 cks conversion period ?= 2 mhz ?= 5 mhz 0 0 reserved (initial value) 0 1 124/ 62 ? 24.8 ? 1 0 62/ 31 ? 12.4 ? 1 1 31/ 15.5 ? * note: * operation is not guaranteed if the conversion time is less than 12.4 ?. set the bits to get a value of at least 12.4 ?. bit initial value read/write 7 adr7 undefined r 6 adr6 undefined r 5 adr5 undefined r 4 adr4 undefined r 3 adr3 undefined r 0 adr0 undefined r 2 adr2 undefined r 1 adr1 undefined r bit initial value read/write 7 cks 0 r/w 6 trge 0 r/w 5 cks1 0 r/w 4 1 3 ch3 0 r/w 0 ch0 0 r/w 2 ch2 0 r/w 1 ch1 0 r/w bit 5 bit 7 cks1 cks 279
bit 6: external trigger select (trge) bit 6 enables or disables the start of a/d conversion by external trigger input. bit 6 trge description 0 disables start of a/d conversion by external trigger (initial value) 1 enables start of a/d conversion by rising or falling edge of external trigger at pin adtrg * note: * the external trigger (adtrg) edge is selected by bit ieg4 of the interrupt edge select register (iegr). see 3.3.2 for details. bit 5: clock select 1 (cks1) bits cks and cks1 select the a/d conversion speed. see bit 7 (cks) for details. bit 4: reserved bit bit 4 is reserved; it is always read as 1, and cannot be modified. bits 3 to 0: channel select 3 to 0 (ch3 to ch0) bits 3 to 0 select the analog input channel. the channel selection should be made while bit adsf is cleared to 0. bit 3 bit 2 bit 1 bit 0 ch3 ch2 ch1 ch0 analog input channel 00 ** no channel selected (initial value) 0100an 0 0101an 1 0110an 2 0111an 3 1000an 4 1001an 5 1010an 6 1011an 7 11 ** reserved note: * don? care 280
12.2.3 a/d start register (adsr) the a/d start register (adsr) is an 8-bit read/write register for starting and stopping a/d conversion. a/d conversion is started by writing 1 to the a/d start flag (adsf) or by input of the designated edge of the external trigger signal, which also sets adsf to 1. when conversion is complete, the converted data is set in the a/d result register (adrr), and at the same time adsf is cleared to 0. bit 7: a/d start flag (adsf) bit 7 controls and indicates the start and end of a/d conversion. bit 7 adsf description 0 read access indicates the completion of a/d conversion. (initial value) write access stops a/d conversion. 1 read access indicates a/d conversion in progress. write access starts a/d conversion. bits 6 to 0: reserved bits bits 6 to 0 are reserved; they are always read as 1, and cannot be modified. bit initial value read/write 7 adsf 0 r/w 6 1 5 1 4 1 3 1 0 1 2 1 1 1 281
12.3 operation 12.3.1 a/d conversion operation the a/d converter operates by successive approximations, and yields its conversion result as 8-bit data. a/d conversion begins when software sets the a/d start flag (bit adsf) to 1. bit adsf keeps a value of 1 during a/d conversion, and is cleared to 0 automatically when conversion is complete. the completion of conversion also sets bit irrad in interrupt request register 2 (irr2) to 1. an a/d conversion end interrupt is requested if bit ienad in interrupt enable register 2 (ienr2) is set to 1. if the conversion time or input channel needs to be changed in the a/d mode register (amr) during a/d conversion, bit adsf should first be cleared to 0, stopping the conversion operation, in order to avoid malfunction. 12.3.2 start of a/d conversion by external trigger input the a/d converter can be made to start a/d conversion by input of an external trigger signal. external trigger input is enabled at pin adtrg when bit irq4 in port mode register 2 for the i/o port (pmr2) is set to 1, and bit trge in amr is set to 1. then when the input signal edge designated in bit ieg4 of the irq edge select register (iegr) is detected at pin adtrg, bit adsf in adsr will be set to 1, starting a/d conversion. figure 12-2 shows the timing. figure 12-2 external trigger input timing pin adtrg (when bit ieg4 = 0) adsf a/d conversion 282
12.4 interrupts when a/d conversion ends (adsf changes from 1 to 0), bit irrad in interrupt request register 2 (irr2) is set to 1. a/d conversion end interrupts can be enabled or disabled by means of bit ienad in interrupt enable register 2 (ienr2). for further details see 3.3, interrupts. 12.5 typical use an example of how the a/d converter can be used is given below, using channel 1 (pin an 1 ) as the analog input channel. figure 12-3 shows the operation timing. bits ch3 to ch0 of the a/d mode register (amr) are set to 0101, making pin an 1 the analog input channel. a/d interrupts are enabled by setting bit ienad to 1, and a/d conversion is started by setting bit adsf to 1. when a/d conversion is complete, bit irrad is set to 1, and the a/d conversion result is stored in the a/d result register (adrr). at the same time adsf is cleared to 0, and the a/d converter goes to the idle state. a bit ienad = 1, so an a/d conversion end interrupt is requested. ? the a/d interrupt handling routine starts. ? the a/d conversion result is read and processed. ? the a/d interrupt handling routine ends. if adsf is set to 1 again afterward, a/d conversion starts and steps through ? take place. figures 12-4 and 12-5 show flow charts of procedures for using the a/d converter. 283
figure 12-3 typical a/d converter operation timing idle a/d conversion (1) idle a/d conversion (2) idle interrupt (irrad) ienad adsf channel 1 (an ) operation state adrr 1 set * set * set * read conversion result read conversion result a/d conversion result (1) a/d conversion result (2) a/d conversion starts note: ( ) indicates instruction execution by software. * 284
figure 12-4 flow chart of procedure for using a/d converter (1) (polling by software) start set a/d conversion speed and input channel perform a/d conversion? end yes no disable a/d conversion end interrupt start a/d conversion adsf = 0? no yes read adsr read adrr data 285
figure 12-5 flow chart of procedure for using a/d converter (2) (interrupts used) 12.6 application notes data in the a/d result register (adrr) should be read only when the a/d start flag (adsf) in the a/d start register (adsr) is cleared to 0. changing the digital input signal at an adjacent pin during a/d conversion may adversely affect conversion accuracy. start set a/d conversion speed and input channels enable a/d conversion end interrupt start a/d conversion a/d conversion end interrupt? yes no end yes no clear bit irrad to 0 in irr2 read adrr data perform a/d conversion? 286
section 13 multitone generator 13.1 overview the h8/3877n series has an on-chip multitone generator that can output an arbitrary waveform at an arbitrary frequency. 13.1.1 features features of the multitone generator are as follows. arbitrary frequencies can be selected in the range from 40 hz to 4000 hz (when the clock frequency f osc at the osc pins is 10 mhz). output frequency range step error 40 hz to 1000 hz 0.1 hz and above ?.05 hz or less 1000 hz to 3000 hz 1 hz and above ?.5 hz or less 3000 hz to 4000 hz 2 hz and above ? hz or less the output frequency is generated by using a frame counter and fine-tuning counter to divide the osc clock frequency (f osc ). a stable waveform can be output with low distortion. the waveform is output by an r ?2r d/a converter with 5-bit resolution. one cycle can be divided into up to 128 segments for a stable waveform with low distortion. arbitrary waveform patterns can be created by setting bit patterns in mtg ram (maximum 128 bits). an interrupt request is generated at half-cycle points in the multitone waveform. 287
13.1.2 block diagram figure 13-1 shows a block diagram of the multitone generator. figure 13-1 multitone generator block diagram internal data bus frame counter fine-tuning counter bit counter mtg ram (16 bytes) shift register increment/ decrement circuit d/a converter irrmt eblr frmr ftnr itlr mtcr f osc vt tonem ref notation: frmr: ftnr: itlr: mtcr: eblr: irrmt: frame register fine-tuning register initial level register multitone control register effective bit length register multitone generator interrupt enable flag f osc /8, f osc /4 f osc /2, f osc 288
13.1.3 pin configuration table 13-1 shows the pin configuration of the multitone generator. table 13-1 pin configuration name abbrev. i/o function multitone output reference level vt ref reference-level voltage for power supply pin multitone output multitone signal output pin tonem output multitone signal output 13.1.4 register configuration table 13-2 shows the register configuration of the multitone generator. table 13-2 multitone generator registers name abbrev. r/w initial value address multitone control register mtcr r/w h'10 h'ff90 effective bit length register eblr r/w h'80 h'ff91 frame register frmr r/w h'00 h'ff92 fine-tuning register ftnr r/w h'00 h'ff93 initial level register itlr r/w h'e0 h'ff94 mtg ram r/w undefined h'ff80 to h'ff8f 289
13.2 register descriptions 13.2.1 multitone control register (mtcr) mtcr is an 8-bit read/write register that enables d/a output, enables operation of the multitone generator, specifies the initial direction of change of the output level, and selects the clock sources of the frame counter and fine-tuning counter. upon reset, mtcr is initialized to h'10. bit 7: d/a output enable (daoe) bit 7 enables or disables analog output at the tonem pin. bit 7 daoe description 0 analog output is disabled (high impedance) (initial value) 1 analog output is enabled bit 6: multitone generator enable (mten) bit 6 enables or disables operation of the multitone generator. bit 6 mten description 0 the multitone generator is halted (initial value) 1 the multitone generator operates bit initial value read/write 7 daoe 0 r/w 6 mten 0 r/w 5 dir 0 r/w 4 1 3 fr1 0 r/w 0 ft0 0 r/w 2 fr0 0 r/w 1 ft1 0 r/w 290
bit 5: initial direction (dir) bit 5 specifies the initial direction of change (increment or decrement) of the analog output level from the tonem pin when the multitone generator starts operating. bit 5 dir description 0 the level is initially incremented (initial value) 1 the level is initially decremented a setting of dir = 0 is invalid if bits 4 to 0 in the initial level register are set to 11111. a setting of dir = 1 is invalid if these bits are set to 00000. bit 4: reserved bit bit 4 is reserved; it is always read as 1, and cannot be modified. bits 3 and 2: frame counter clock source select 1 and 0 (fr1, fr0) bits 3 and 2 select the frame counter clock source. that is, they select the division ratio of the osc clock (f osc ). the clock source should be changed only when mten = 0. bit 3 bit 2 fr1 fr0 description 0 0 division ratio = t osc (counter clock = f osc ) 0 1 division ratio = 2 t osc (counter clock = f osc /2) 1 0 division ratio = 4 t osc (counter clock = f osc /4) 1 1 division ratio = 8 t osc (counter clock = f osc /8) bits 1 and 0: fine-tuning counter clock source select 1 and 0 (ft1, ft0) bits 1 and 0 select the fine-tuning counter clock source. that is, they select the division ratio of the osc clock (f osc ). the clock source should be changed only when mten = 0. bit 1 bit 0 ft1 ft0 description 0 0 division ratio = t osc (counter clock = f osc ) 0 1 division ratio = 2 t osc (counter clock = f osc /2) 1 0 division ratio = 4 t osc (counter clock = f osc /4) 1 1 division ratio = 8 t osc (counter clock = f osc /8) 291
13.2.2 effective bit length register (eblr) eblr is an 8-bit read/write register that specifies the effective bit length (position of the last bit) on mtg ram. upon reset, eblr is initialized to h'80. bit 7: reserved bit bit 7 is reserved; it is always read as 1, and cannot be modified. bits 6 to 0: effective bit length 6 to 0 (ebl6 to ebl0) bits 6 to 0 specify the effective bit length (position of the last bit) of the bit pattern set on mtg ram. the register setting is the effective bit length minus 1. eblr should be set to a value of h'83 or greater. the effective bit length should be changed only when mten = 0 in mtcr. 13.2.3 frame register (frmr) frmr is an 8-bit read/write register that specifies the reload value of the frame counter (the period of 1 bit frame in the bit pattern). the reload value is automatically reloaded into the frame counter. the frame counter starts counting down from that value. when the counter value reaches h'01, the frame counter is reloaded with the reload value, and starts counting down from that value again. frmr should be set to a value of h'02 or greater. the frame counter reload value should be changed only when mten = 0 in mtcr. upon reset, frmr is initialized to h'00. bit initial value read/write 7 1 6 ebl6 0 r/w 5 ebl5 0 r/w 4 ebl4 0 r/w 3 ebl3 0 r/w 0 ebl0 0 r/w 2 ebl2 0 r/w 1 ebl1 0 r/w bit initial value read/write 7 frm7 0 r/w 6 frm6 0 r/w 5 frm5 0 r/w 4 frm4 0 r/w 3 frm3 0 r/w 0 frm0 0 r/w 2 frm2 0 r/w 1 frm1 0 r/w 292
13.2.4 fine-tuning register (ftnr) ftnr is an 8-bit read/write register that specifies the reload value of the fine-tuning counter. the reload value is automatically reloaded into the fine-tuning counter. the fine-tuning counter starts counting down from that value. when the counter value reaches h'01, the fine-tuning counter is reloaded with the reload value, and starts counting down from that value again. the fine-tuning counter reload value should be changed only when mten = 0 in mtcr. upon reset, ftnr is initialized to h'00. 13.2.5 initial level register (itlr) itlr is an 8-bit read/write register that specifies the analog output level when the multitone generator starts operating. upon reset, itlr is initialized to h'e0. bits 7 to 5: reserved bits bits 7 to 5 are reserved; they are always read as 1, and cannot be modified. bits 4 to 0: initial level 4 to 0 (itl4 to itl0) bits 4 to 0 specify the initial analog level output from the tonem pin when the multitone generator starts operating. the multitone generator commences output from this initial level, then changes the level according to the bit pattern. bit initial value read/write 7 ftn7 0 r/w 6 ftn6 0 r/w 5 ftn5 0 r/w 4 ftn4 0 r/w 3 ftn3 0 r/w 0 ftn0 0 r/w 2 ftn2 0 r/w 1 ftn1 0 r/w bit initial value read/write 7 1 6 1 5 1 4 itl4 0 r/w 3 itl3 0 r/w 0 itl0 0 r/w 2 itl2 0 r/w 1 itl1 0 r/w 293
13.3 operation 13.3.1 output waveform the multitone generator outputs a staircase approximation to a sine wave or other analog waveform (figure 13-2). one step in the staircase waveform consists of one or more bit frames produced by dividing the osc clock frequency (f osc ) in the frame counter. the eblr setting determines the number of bit frames in one cycle of the waveform. the output frequency is f osc divided by the frame counter and by the effective bit length. the fine-tuning counter can also be used to fine-tune the output frequency. the output level changes according to the bit pattern on mtg ram. any bit pattern can be set, to generate an arbitrary waveform. figure 13-2 multitone generator output waveform 1 cycle = (frame register value clock source effective bit length) + (fine-tuning register value clock source) f osc fine-tuning output level initial level 1 step fine- tuning enlarged view time bit pattern level changes on 1 gnd vt ref 00000 001000101 10101001 1 bit frame = frame register value clock source t osc fine-tuning register value clock source t 2 fine-tuning period = osc 1 f osc (t = ) osc note: clock source = clock division ratio: 1, 2, 4, or 8 294
13.3.2 flow of operation figure 13-3 shows a flow chart of the operation of the multitone generator. the circled numbers in the flow chart correspond to the numbers of the steps below. initial setup: set desired values in the dir, fr1, fr0, ft1, and ft0 bits in mtcr, and in eblr, frmr, ftnr, and itlr, and write bit pattern data in mtg ram. set the daoe and mten bits to 1 in mtcr. the multitone generator starts operating at this point. a the initial output level set in itlr is output from the tonem pin. the level will start changing in the direction (increment or decrement) specified by the dir bit in mtcr. ? during each bit frame the output level is held constant. the length of a bit frame is the frame register value frame counter clock source (clock division ratio) t osc . ? the output level changes according to the bit pattern. wherever a 1 occurs in the bit pattern the output level is incremented or decremented by 1/32 of vt ref . where a 0 occurs in the bit pattern the output level is held fixed. ? the output level is checked when incremented or decremented. if the output level is at its maximum or minimum value, that level is output for one-half the fine-tuning interval to fine- tune the output frequency. one-half the fine-tuning interval is the fine-tuning register value fine-tuning counter clock source (clock division ratio) t osc 1/2. if the value in the fine- tuning register is odd, fine-tuning is extended by one count at the minimum level. if the value in the fine-tuning register is even, fine-tuning is extended by one count at both the maximum and minimum levels. ? the bit counter is incremented to move on to the next bit in the bit pattern. if this does not make the bit counter value equal to the effective bit length, the process returns to step ? . if the bit counter value equals the effective bit length (the end of one output cycle), the bit counter is cleared. ? after the bit counter is cleared in step ? , the mten bit in mtcr is checked. if mten is 1, the multitone generator returns to step ? and continues operating. if mten is 0, operation halts. mten can be set or cleared at any point in the output cycle. (the same applies to output from the tonem pin and the setting or clearing of the daoe bit in mtcr.) always clear mten to 0 to halt the multitone generator before changing the clock source of the frame counter or fine-tuning counter (bits fr1, fr0, ft1, and ft0 in mtcr), the effective bit length (eblr), or the reload value of the frame counter or fine-tuning counter (frmr, ftnr). 295
figure 13-3 flow chart of multitone generator operation fine-tuning = interval 1/2 fine-tuning register value fine-tuning counter clock source (clock division ratio) t initial settings start initial level output initial direction of level change? increment output level decrement output level bit value in bit pattern? (output value does not change) (output value does not change) maximum output level? minimum output level? increment bit counter (switch-over the direction of the output level change) bit count = effective bit length? clear bit counter clear bit counter mten = 0? mten = 0? end   # change in multitone output level (vertical axis) change in multitone output time (horizontal axis) ? ? ? ? ? a no no yes yes yes yes no no 0 1 0 1 yes yes no no osc 1 bit frame = frame counter value frame counter clock source (clock division ratio) t osc 2 bit value in bit pattern? increment bit counter bit count = effective bit length?           increment output level decrement output level 296
13.4 register settings 13.4.1 how to calculate register settings the settings of the frame register and fine-tuning register can be calculated as explained below from the osc clock frequency (f osc ) and the desired output frequency (the set frequency). symbols used in the explanation are defined as follows. f osc : osc clock frequency f: set frequency fout: output frequency d1: frame counter clock source (clock division ratio; 1, 2, 4, or 8) d2: fine-tuning counter clock source (clock division ratio; 1, 2, 4, or 8) n: total division ratio bl: effective bit length (4 to 128) c1: frame register value (frame counter reload value; 2 to 255) c2: fine-tuning register value (fine-tuning counter reload value; 0 to 255) s : frequency deviation parameter relationships the output frequency (fout) is obtained by dividing the osc clock frequency (f osc ), and is expressed as follows: fout = f osc /(bl?1?1 + c2?2) ( f) ............................................(1) ? from the osc clock frequency (f osc ) and set frequency (f), calculate the total division ratio (n), which is equivalent to the denominator in equation (1). n f osc /f (round off n to the nearest integer) - divide the total division ratio (n) by the effective bit length (bl) and frame counter clock source (clock division ratio, d1) to obtain the frame register value (c1). if the result is greater than 255, increase d1 to obtain a result of 255 or less. c1 n/bl/d1 (round c1 down to the nearest lower integer, since fine-tuning is always in the positive direction) ? subtract the effective bit time (bl?1?1) from the total division ratio (n) to obtain the fine- tuning time (c2?2). if the result is greater than 255, increase d2 to obtain a result of 255 or less, as in step 2. c2 (n ?bl?1?1)/d2 (round off c2 to the nearest integer) 297
substitute the settings found in steps ? to - into equation (1) to calculate the output frequency (fout). the frequency deviation ( s ) can be calculated from the set frequency and output frequency. s = (fout ?f)/f 100 (%) 13.4.2 typical register settings table 13-3 shows typical settings of the multitone generator registers. the setting of the effective bit length register (eblr) should be the value shown in table 13-3 minus 1. the effective bit length in these settings been adjusted so that the fine-tuning interval does not exceed 1% of the cycle length. table 13-3 typical multitone generator register settings (1) frame counter fine-tuning counter reload clock reload clock output frequency value * 1 source * 2 value * 3 source * 4 frequency (hz) deviation (%) 10 40.0 250000 125 250 8 0 1 40.0000 ?.0 40.1 249377 125 249 8 188 2 40.1001 +0.0002 1000 10000 125 80 1 0 1 1000.00 ?.0 1001 9990 128 78 1 6 1 1001.00 +0.0001 3998 2501 125 20 1 1 1 3998.40 +0.0100 4000 2500 125 20 1 0 1 4000.00 ?.0 9.834 40.0 245760 128 240 8 0 1 40.0000 ?.0 40.1 245147 124 247 8 123 1 40.1000 +0.0001 1000 9830 126 78 1 2 1 1000.04 +0.0041 1001 9821 109 90 1 11 1 1000.96 ?.0043 3998 2459 117 21 1 2 1 3997.72 ?.0069 4000 2458 117 21 1 1 1 3999.35 ?.0163 8 40.0 200000 125 200 8 0 1 40.0000 ?.0 40.1 199501 107 233 8 53 1 40.1000 +0.0001 1000 8000 125 64 1 0 1 1000.00 ?.0 1001 7992 121 66 1 6 1 1001.00 +0.0001 3998 2001 125 16 1 1 1 3998.00 +0.0000 4000 2000 125 16 1 0 1 4000.00 ?.0 7.3723 40.0 184320 128 180 8 0 1 40.0000 ?.0 40.1 183860 111 207 8 44 1 40.1001 +0.0002 1000 7373 110 67 1 3 1 999.97 ?.0027 1001 7365 115 64 1 5 1 1001.06 +0.0059 3998 1844 115 16 1 4 1 3998.26 +0.0066 4000 1843 115 16 1 3 1 4000.43 +0.0109 6 40.0 150000 125 150 8 0 1 40.0000 ?.0 40.1 149626 110 170 8 26 1 40.10000 ?.0000 1000 6000 125 48 1 0 1 1000.00 ?.0 1001 5994 111 54 1 0 1 1001.00 +0.0001 3998 1501 125 12 1 1 1 3997.34 ?.0166 4000 1500 125 12 1 0 1 4000.00 ?.0 notes: 1. set in register frmr. (continued on next page) 2. set in register mtcr (fr1, fr0). 3. set in register ftnr. 4. set in register mtcr (ft1, ft0). osc set fre- total effective clock quency division bit (mhz) (hz) ratio length 298
table 13-3 typical multitone generator register settings (2) frame counter fine-tuning counter reload clock reload clock output frequency value * 1 source * 2 value * 3 source * 4 frequency (hz) deviation (%) 4.9152 40.0 122880 128 240 4 0 1 40.0000 ?.0 40.1 122574 111 138 8 30 1 40.0999 ?.0004 1000 4915 126 39 1 1 1 1000.04 +0.0041 1001 4910 109 45 1 5 1 1001.06 +0.0059 3998 1229 111 11 1 8 1 3999.35 +0.0337 4000 1229 111 11 1 8 1 3999.35 ?.0163 4.19304 40.0 104826 123 213 4 30 1 40.0000 ?.0 40.1 104565 121 216 4 21 1 40.0998 ?.0004 1000 4193 127 33 1 2 1 1000.01 +0.0010 1001 4189 123 34 1 7 1 1000.96 ?.0036 3998 1049 116 9151 3997.18 ?.0206 4000 1048 116 9141 4000.99 +0.0248 4 40.0 100000 125 200 4 0 1 40.0000 ?.0 40.1 99751 107 233 4 27 1 40.0998 +0.0004 1000 4000 125 32 1 0 1 1000.00 ?.0 1001 3996 111 36 1 0 1 1001.00 +0.0001 3998 1001 125 8111 3996.00 ?.0499 4000 1000 125 8101 4000.00 ?.0 3.579545 40.0 89489 119 188 4 1 1 39.9998 ?.0004 40.1 89265 111 201 4 21 1 40.1002 +0.0005 1000 3580 119 30 1 10 1 999.87 ?.0127 1001 3576 119 30 1 6 1 1000.99 ?.0009 3998 895 127 7161 3999.49 +0.0373 4000 895 127 7161 3999.49 ?.127 2.4576 40.0 61440 128 240 2 0 1 40.0000 ?.0 40.1 61287 111 138 4 15 1 40.0999 ?.0004 1000 2458 117 21 1 1 1 999.84 ?.0163 1001 2455 98 25 1 5 1 1001.06 +0.0059 3998 615 123 5101 3996.10 ?.0476 4000 614 102 6121 4002.61 +0.0651 2 40.0 50000 125 200 2 0 1 40.0000 ?.0 40.1 49875 107 233 2 13 1 40.1003 ?.0006 1000 2000 125 16 1 0 1 1000.00 ?.0 1001 1998 111 18 1 0 1 1001.00 +0.0001 3998 500 125 4101 4000.00 +0.0500 4000 500 125 4101 4000.00 ?.0 1 40.0 25000 125 200 1 0 1 40.0000 ?.0 40.1 24938 107 233 1 7 1 40.0994 ?.0014 1000 1000 125 8101 1000.00 ?.0 1001 999 111 9101 1001.00 +0.0001 3998 250 83 3111 4000.00 +0.0500 4000 250 83 3111 4000.00 ?.0 notes: 1. set in register frmr. 2. set in register mtcr (fr1, fr0). 3. set in register ftnr. 4. set in register mtcr (ft1, ft0). osc set fre- total effective clock quency division bit (mhz) (hz) ratio length 299
13.5 bit pattern setting on mtg ram 13.5.1 bit pattern on mtg ram mtg ram is a 16-byte area from address h'ff80 to address h'ff8f, which can hold a bit pattern of up to 128 bits. the bit pattern can be set to give a sine wave or other waveform, such as a triangle wave or a trapezoid wave with a variable duty cycle. the mtg ram data is sent to the increment/decrement circuit starting from bit 0 at address h'ff80 (figure 13-4). figure 13-4 bit pattern on mtg ram 0 1 0 0 0 1 1 0 0 1 1 0 0 0 1 0 70 h'15 h'a8 transfer mtg ram data increment/ decrement circuit data relation of output to mtg ram data (example) output waveform mtg ram 70 address h'ff80 h'ff81 h'ff8e h'ff8f 300
13.5.2 typical bit pattern settings typical bit pattern settings for output of a sine wave, triangle wave, and trapezoid wave are shown below (figures 13-5 to 13-7). 1. sine wave (starting at center point) initial level: 0f effective bit length: 128 initial direction: increment the settings of individual bits can be found by the following integer approximation to the sine function. vout/vt ref = int[(sin(bit/128*2 p ) + 1)/2*31]/32 figure 13-5 typical bit pattern for sine wave vt ref initial level (15/32) gnd (15/32) 10111011 32 64 96 128 01101101 01010101 00101010 10101101 10110111 01111011 01101101 01010101 0001000000000010 00101010 10101101 10110111 0001000000000010 (15/32) ( 0 /32) (31/32) h' ff80 h' ff81 h' ff82 h' ff83 h' ff84 h' ff85 h' ff86 h' ff87 h'ff88 h' ff89 h' ff8a h' ff8b h' ff8c h' ff8d h' ff8e h' ff8f h' dd h' b6 h' aa h' 08 h' 40 h' 54 h' b5 h' ed h' dd h' b6 h' aa h' 08 h' 40 h' 54 h' b5 h' ed note: numbers in parentheses are output levels. time (unit: bit) output level mtg ram address mtg ram data 301
2. triangle wave initial level: 0 effective bit length: 124 initial direction: increment figure 13-6 typical bit pattern for triangle wave 3. trapezoid wave (50% duty) initial level: 0 effective bit length: 128 initial direction: increment figure 13-7 typical bit pattern for trapezoid wave (50% duty) vt ref initial level (0/32) 32 64 96 128 0101 (31/32) h' ff80 h' ff81 h' ff82 h' ff83 h' ff84 h' ff85 h' ff86 h' ff87 h'ff88 h' ff89 h' ff8a h' ff8b h' ff8c h' ff8d h' ff8e h' ff8f h' aa h' aa h' aa h' aa h' aa h' aa h' aa h' aa h' aa h' aa h' aa h' aa h' aa h' aa h' aa h' 0a note: numbers in parentheses are output levels. time (unit: bit) 01010101 01010101 01010101 01010101 01010101 01010101 01010101 01010101 01010101 01010101 01010101 01010101 01010101 01010101 01010101 gnd output level mtg ram address mtg ram data vt ref initial level (0/32) gnd 32 64 96 128 (31/32) h' ff80 h' ff81 h' ff82 h' ff83 h' ff84 h' ff85 h' ff86 h' ff87 h'ff88 h' ff89 h' ff8a h' ff8b h' ff8c h' ff8d h' ff8e h' ff8f h' 00 h' 00 h' 00 h' 00 h' fe h' ff h' ff h' ff h' 00 h' 00 h' 00 h' 00 h' fe h' ff h' ff h' ff note: numbers in parentheses are output levels. time (unit: bit) 11111111 01111111 00000000000000000000000000000000 11111111 11111111 01111111 11111111 11111111 11111111 00000000000000000000000000000000 output level mtg ram address mtg ram data 302
13.5.3 modification of bit patterns the multitone generator generates an interrupt every half-cycle (when the bit count in the bit counter equals the value set in the effective bit length register or half that value). the output waveform can be controlled for every one cycle by modifying the bit pattern (or data that is already output) every half cycle. the effective bit length, frame register value, frame counter clock source, fine-tuning register, and fine-tuning counter clock source should be left unaltered. figure 13-8 shows the timing of the interrupts and the timing of modification of bit pattern data. this figure shows two transmit waveforms. waveforms ? and ? have the same bit pattern. the direction of level change depends on the direction of change in the previous interval. note that if the waveform reverses the direction of change in the output level (waveform 2 in this figure), the bit pattern must be set so that the value of the output level at the end of the cycle becomes reverse of the output level at the beginning of the cycle. (for example, if the starting level is 15/32, the ending level should be 16/32.) figure 13-8 timing of interrupts and bit pattern data modification example: msk modem transmit data start transmit waveform bit pattern data modification interrupt (irrmt) 1200 bps 833 s 1 1200 hz 0 1800 hz 1001 (mark) (space) a ? ?? 1st half of ? ? ? 2nd half of 1st half of a 1st half of 2nd half of 1st half of 2nd half of 1st half of ? 2nd half of a 2nd half of 16 32 16 32 16 32 15 32 15 32 15 32 303
13.6 application notes make sure the effective bit length setting matches the length of the bit pattern. if a large amount of fine-tuning is necessary per cycle, make allowances for the fine-tuning when setting the bit pattern. do not change the settings of bits fr1, fr0, ft1, and ft0 in mtcr, or of eblr, frmr, or ftnr, while the multitone generator is operating. the multitone generator can operate at any oscillator frequency, but if the dtmf generator is also used, the osc clock frequency ( osc ) should be an integer multiple of 400 khz between 1.2 mhz and 10 mhz. the output level changes by 1/32?tref at each bit having a value of 1 in the bit pattern, so it is not possible to output a steep waveform with changes of 2/32?t ref or more per bit. if a waveform has a steep portion, the bit pattern should be modified by adjusting the preceding and following parts to obtain a continuous output waveform. the multitone generator operates from the stop control (by setting mten = 0) to the end of the cycle for the current output operation. therefore, if the next operation is started immediately after the stop control, it must be set to wait for at least one cycle. 304
section 14 electrical characteristics 14.1 absolute maximum ratings table 14-1 lists the absolute maximum ratings. table 14-1 absolute maximum ratings item symbol value unit notes power supply voltage v cc ?.3 to +7.0 v 1 analog power supply voltage av cc ?.3 to +7.0 v 1 av ref ?.3 to av cc +0.3 v 1 reference level supply voltage vt ref ?.3 to v cc +0.3 v 1 programming voltage v pp ?.3 to +13.0 v 1 input voltage ports other than port b v in ?.3 to v cc +0.3 v 1 port b av in ?.3 to av cc +0.3 v 1 operating temperature t opr 0 to 75 ? 1 storage temperature t stg ?5 to +125 ? 1 note: 1. permanent damage may occur to the chip if maximum ratings are exceeded. normal operation should be under the conditions specified in electrical characteristics. exceeding these values can result in incorrect operation and reduced reliability. 305
14.2 electrical characteristics 14.2.1 power supply voltage and operating range the power supply voltage and operating range are indicated by the shaded region in the figures below. 1. power supply voltage vs. oscillator frequency range 10.0 2.5 4.0 5.5 v (v) cc f (mhz) osc 32.768 2.5 4.0 5.5 v (v) cc fw (khz) active mode (high and medium speeds) sleep mode all operating modes 5.0 2.0 306
2. power supply voltage vs. clock frequency range 3. analog power supply voltage vs. a/d converter operating range 625.0 2.5 4.0 5.5 v (v) cc ?(khz) 5.0 2.5 4.0 5.5 v (v) cc ?(mhz) 16.384 2.5 4.0 5.5 v (v) cc ? (khz) sub active mode (high speed) sleep mode (except cpu) subactive mode subsleep mode (except cpu) watch mode (except cpu) active mode (medium speed) 8.192 4.096 2.5 0.5 500.0 312.5 62.5 2.5 4.0 5.5 av (v) cc ?(mhz) 2.5 4.0 5.5 av (v) cc ?(khz) 625.0 312.5 active (high speed) mode sleep mode active (medium speed) mode 500.0 5.0 2.5 0.5 62.5 307
14.2.2 dc characteristics table 14-2 lists the dc characteristics. table 14-2 dc characteristics v cc = 2.5 v to 5.5 v, av cc = 2.5 v to 5.5 v, v ss = av ss = 0.0 v, t a = 0 to +75?, including subactive mode, unless otherwise indicated. item symbol applicable pins min typ max unit test condition note input high v ih res, nmi, 0.8 v cc ? cc +0.3 v v cc = 4.0 v to 5.5 v voltage wkp 0 to wkp 7 , irq 0 to irq 4 , tmif, tmig, 0.9 v cc ? cc +0.3 sck 1 , sck 3 , adtrg si 1 , rxd 0.7 v cc ? cc +0.3 v v cc = 4.0 v to 5.5 v 0.8 v cc ? cc +0.3 osc 1 v cc ?.5 v cc +0.3 v v cc = 4.0 v to 5.5 v v cc ?.3 v cc +0.3 p1 0 to p1 7 0.7 v cc ? cc +0.3 v v cc = 4.0 v to 5.5 v p2 0 to p2 7 p5 0 to p5 7 p6 0 to p6 7 p7 0 to p7 7 p8 0 to p8 7 0.8 v cc ? cc +0.3 p9 0 to p9 7 pa 0 to pa 3 pd 0 to pd 7 pe 0 to pe 3 pb 0 to pb 7 0.7 v cc ?v cc +0.3 v v cc = 4.0 v to 5.5 v 0.8 v cc ?v cc +0.3 input low v il res, nmi, ?.3 0.2 v cc vv cc = 4.0 v to 5.5 v voltage wkp 0 to wkp 7 , irq 0 to irq 4 , tmif, tmig, ?.3 0.1 v cc sck 1 , sck 3 , adtrg si 1 , rxd ?.3 0.3 v cc vv cc = 4.0 v to 5.5 v ?.3 0.2 v cc osc 1 ?.3 0.5 v v cc = 4.0 v to 5.5 v ?.3 0.3 note: connect pin test to v ss . 308
table 14-2 dc characteristics (cont) v cc = 2.5 v to 5.5 v, av cc = 2.5 v to 5.5 v, v ss = av ss = 0.0 v, t a = 0 to +75?, including subactive mode, unless otherwise indicated. item symbol applicable pins min typ max unit test condition note input low v il p1 0 to p1 7 ?.3 0.3 v cc vv cc = 4.0 v to 5.5 v voltage p2 0 to p2 7 p5 0 to p5 7 p6 0 to p6 7 p7 0 to p7 7 p8 0 to p8 7 p9 0 to p9 7 ?.3 0.2 v cc pa 0 to pa 3 pb 0 to pb 7 pd 0 to pd 7 pe 0 to pe 3 output v oh p1 0 to p1 7 v cc ?1.0 v v cc = 4.0 v to 5.5 v high voltage p2 0 to p2 7 ? oh = 1.0 ma p5 0 to p5 7 p6 0 to p6 7 v cc ?0.5 v cc = 4.0 v to 5.5 v p7 0 to p7 7 ? oh = 0.5 ma p8 0 to p8 7 p9 0 to p9 7 v cc ?0.5 ? oh = 0.1 ma pa 0 to pa 3 pd 0 to pd 7 pe 0 to pe 3 output v ol p5 0 to p5 7 0.5 v i ol = 0.4 ma low voltage p6 0 to p6 7 p7 0 to p7 7 p8 0 to p8 7 p9 0 to p9 7 pa 0 to pa 3 pd 0 to pd 7 pe 0 to pe 3 1.5 v cc = 4.0 v to 5.5 v i ol = 10 ma 0.6 v cc = 4.0 v to 5.5 v i ol = 1.6 ma 0.5 i ol = 0.4 ma note: connect pin test to v ss . p1 0 to p1 7 p2 0 to p2 7 309
table 14-2 dc characteristics (cont) v cc = 2.5 v to 5.5 v, av cc = 2.5 v to 5.5 v, v ss = av ss = 0.0 v, t a = 0 to +75?, including subactive mode, unless otherwise indicated. item symbol applicable pins min typ max unit test condition note |i il | res, nmi 20 a 3 1 2 osc 1 1 a v in = 0.5 v to p1 0 to p1 7 v cc ?0.5 v p2 0 to p2 7 p5 0 to p5 7 p6 0 to p6 7 p7 0 to p7 7 p8 0 to p8 7 p9 0 to p9 7 pa 0 to pa 3 pd 0 to pd 7 pe 0 to pe 3 pb 0 to pb 7 1 v in = 0.5 v to av cc ?0.5 v ? p p1 0 to p1 7 50 300 ? v cc = 5 v, p2 0 to p2 7 v in = 0 v p5 0 to p5 7 35 ? v cc = 2.7 v, reference p6 0 to p6 7 v in = 0 v value input c in all input pins except 15 pf capacitance power supply pins res 60 3 nmi 30 notes: 2. applies to hd6433875n, hd6433876n, and hd6433877n. 3. applies to hd6473877n. v in = 0.5 v to v cc ?0.5 v f = 1 mhz, v in = 0 v t a = 25? input leakage current pull-up mos current 310
table 14-2 dc characteristics (cont) v cc = 2.5 v to 5.5 v, av cc = 2.5 v to 5.5 v, v ss = av ss = 0.0 v, t a = 0 to +75?, including subactive mode, unless otherwise indicated. applicable item symbol pins min typ max unit test condition notes i ope1 v cc 12 24 ma active mode (high speed), 4, 5 v cc = 5 v, f osc = 10 mhz i ope2 v cc 2.5 5 ma active mode (medium speed), 4, 5 v cc = 5 v, f osc = 10 mhz sleep mode i sleep v cc 5 10 ma v cc = 5 v, f osc = 10 mhz 4, 5 current dissipation subactive mode i sub v cc 50 130 ? v cc = 2.5 v, 4, 5 current 32-khz crystal oscillator dissipation ( sub = w/2) ?0av cc = 2.5 v, reference 32-khz crystal oscillator value ( sub = w/8) 4, 5 subsleep mode i subsp v cc ?090av cc = 2.5 v, 4, 5 current 32-khz crystal oscillator dissipation ( sub = w/2) watch mode i watch v cc 6 av cc = 2.7 v, 4, 5 current 32-khz crystal oscillator dissipation standby mode i stby v cc 5 a 32-khz crystal oscillator 4, 5 current not used dissipation ram data v ram v cc 2v retaining voltage notes: 4. pin states during current measurement are shown below. other mode pins internal state oscillator pins active mode v cc operates system clock oscillator: crystal (high and medium subclock oscillator: pin x 1 = v cc speed) sleep mode v cc only timer operates subactive mode v cc operates subsleep mode v cc only timer operates, cpu stops watch mode v cc only time-base clock operates, cpu stops standby mode v cc cpu and timers all system clock oscillator: crystal stop subclock oscillator: pin x 1 = v cc notes: 5. excludes current in pull-up mos transistors and output buffers. active mode current dissipation system clock oscillator: crystal subclock oscillator: crystal 311
table 14-2 dc characteristics (cont) v cc = 2.5 v to 5.5 v, av cc = 2.5 v to 5.5 v, v ss = av ss = 0.0 v, t a = 0 to +75?, including subactive mode, unless otherwise indicated. applicable item symbol pins min typ max unit test condition allowable output i ol output pins except in 2 ma v cc = 4.0 v to 5.5 v low current (per pin) ports 1 and 2 ports 1 and 2 10 v cc = 4.0 v to 5.5 v all output pins 0.5 allowable output s i ol output pins except in 40 ma v cc = 4.0 v to 5.5 v low current (total) ports 1 and 2 ports 1 and 2 80 v cc = 4.0 v to 5.5 v all output pins 20 ? oh all output pins 2 ma v cc = 4.0 v to 5.5 v 0.2 s ? oh all output pins 15 ma v cc = 4.0 v to 5.5 v 10 allowable output high current (per pin) allowable output high current (total) 312
14.2.3 ac characteristics table 14-3 lists the control signal timing, and tables 14-4 and 14-5 list the serial interface timing. table 14-3 control signal timing v cc = 2.5 v to 5.5 v, av cc = 2.5 v to 5.5 v, v ss = av ss = 0.0 v, t a = 0 to +75?, including subactive mode, unless otherwise specified. applicable item symbol pins min typ max units test condition note f osc osc 1 , osc 2 2 10 mhz v cc = 4.0 v to 5.5 v 2 5 t osc osc 1 , osc 2 100 1000 ns v cc = 4.0 v to 5.5 v 1 200 1000 figure 14-3 t cyc 2 16t osc 1 2000 ns subclock oscillation f w x 1 , x 2 32.768 khz frequency watch clock cycle t w x 1 , x 2 30.5 s time ( w ) subclock ( sub ) t subcyc 2 8 t w 2 cycle time instruction cycle time 2 t cyc t subcyc t rc osc 1 , osc 2 40 ms v cc = 4.0 v to 5.5 v 60 oscillation stabilization t rc x 1 , x 2 2 s time t cph osc 1 40 ns v cc = 4.0 v to 5.5 v figure 14-3 80 t cpl osc 1 40 ns v cc = 4.0 v to 5.5 v figure 14-3 80 external clock rise time t cpr 15 ns v cc = 4.0 v to 5.5 v 20 external clock fall time t cpf 15 ns v cc = 4.0 v to 5.5 v 20 pin res low width t rel res 10 t cyc figure 14-4 t subcyc notes: 1. a frequency between 1 mhz to 10 mhz is required when an external clock is input. 2. selected with sa1 and sa0 of system clock control register 2 (syscr2). system clock oscillation frequency osc clock ( osc ) cycle time system clock (? cycle time oscillation stabilization time (crystal oscillator) external clock high width external clock low width 313
table 14-3 control signal timing (cont) v cc = 2.5 v to 5.5 v, av cc = 2.5 v to 5.5 v, v ss = av ss = 0.0 v, t a = 0 to +75?, including subactive mode, unless otherwise specified. applicable reference item symbol pins min typ max units test condition figure input pin high width t ih nmi, 2 t cyc figure 14-5 irq 0 to irq 4 ,t subcyc wkp 0 to wkp 7 , adtrg, tmif, tmig input pin low width t il nmi, 2 t cyc figure 14-5 irq 0 to irq 4 ,t subcyc wkp 0 to wkp 7 , adtrg, tmif, tmig table 14-4 serial interface timing (sci1) v cc = 2.5 v to 5.5 v, av cc = 2.5 v to 5.5 v, v ss = av ss = 0.0 v, t a = 0 to +75?, unless otherwise specified. applicable reference item symbol pins min typ max unit test condition figure input serial clock t scyc sck 1 2 t cyc figure 14-6 cycle time input serial clock t sckh sck 1 0.4 t scyc figure 14-6 high width input serial clock t sckl sck 1 0.4 t scyc figure 14-6 low width t sckr sck 1 60 ns v cc = 4.0 v to 5.5 v figure 14-6 80 t sckf sck 1 60 ns v cc = 4.0 v to 5.5 v figure 14-6 80 t sod so 1 200 ns v cc = 4.0 v to 5.5 v figure 14-6 350 t sis si 1 200 ns v cc = 4.0 v to 5.5 v figure 14-6 400 t sih si 1 200 ns v cc = 4.0 v to 5.5 v figure 14-6 400 input serial clock rise time input serial clock fall time serial output data delay time serial input data setup time serial input data hold time 314
table 14-5 serial interface timing (sci3) v cc = 2.5 v to 5.5 v, av cc = 2.5 v to 5.5 v, v ss = av ss = 0.0 v, t a = 0 to +75?, unless otherwise specified. reference item symbol min typ max unit test condition figure input clock cycle asynchronous t scyc 4 t cyc figure 14-7 synchronous 6 input clock pulse width t sckw 0.4 0.6 t scyc figure 14-7 t txd 1 t cyc v cc = 4.0 v to 5.5 v figure 14-8 1 t rxs 200 ns v cc = 4.0 v to 5.5 v figure 14-8 400 t rxh 200 ns v cc = 4.0 v to 5.5 v figure 14-8 400 transmit data delay time (synchronous mode) receive data setup time (synchronous mode) receive data hold time (synchronous mode) 315
14.2.4 a/d converter characteristics table 14-6 shows the a/d converter characteristics. table 14-6 a/d converter characteristics av cc = v cc = 4.0 v to 5.5 v, av ss = v ss = 0.0 v, t a = 0 to +75?, unless otherwise specified. applicable item symbol pins min typ max unit test condition note av cc av cc 4.0 5.5 v 1 av ref av ref 2.5 av cc + 0.3 v analog input av in an 0 to an 7 ?.3 av cc + 0.3 v voltage ai ope av cc , av ref 1.5 ma av cc = 5.0 v 4 ai stop1 av cc , av ref 150 a 2, 4 reference value ai stop2 av cc , av ref 5 a 3, 4 analog input c ain an 0 to an 7 30 pf capacitance allowable signal r ain 10 k source impedance resolution 8 bit non-linearity ?.0 lsb error quantization ?.5 lsb error absolute ?.5 lsb av ref = 4.0 v to accuracy 5.5 v ?.0 lsb av ref = 2.5 v to 5.5 v conversion time 12.4 248 ? av cc = 4.5 v to 5.5 v 24.8 248 ? av cc = 4.0 v to 5.5 v notes: 1. set av cc = v cc when the a/d converter is not used. 2. ai stop1 is the current in active and sleep modes while the a/d converter is idle. 3. ai stop2 is the current at reset and in standby, watch, subactive, and subsleep modes while the a/d converter is idle. 4. indicates the current when av cc and av ref are common pins. analog power supply current analog power supply voltage 316
14.2.5 dtmf and multitone generator characteristics table 14-7 lists the dtmf generator and multitone generator characteristics. table 14-7 dtmf characteristics v cc = 2.5 v to 5.5 v, av cc = 2.5 v to 5.5 v, v ss = av ss = 0.0 v, t a = 0 to +75?c, unless otherwise specified applicable item symbol pins min typ max unit test condition note reference level vt ref vt ref 2.5 v cc + 0.3 v supply voltage dtmf output v or toned 625 825 mvrms vt ref ?gnd = 2.5 v figure 14-1 voltage (row) r l = 100 k 1 dtmf output v oc toned 650 865 mvrms vt ref ?gnd = 2.5 v figure 14-1 voltage (column) r l = 100 k 1 dtmf output %disdt toned 3 7 % vt ref ?gnd = 2.5 v figure 14-1 distortion r l = 100 k dtmf output db cr toned 2.5 db vt ref ?gnd = 2.5 v figure 14-1 level r l = 100 k notes: 1. v or and v oc indicate the output voltage during single wave output. table 14-8 multitone generator characteristics v cc = 3.0 v to 5.5 v, av cc = 2.7 v to 5.5 v, v ss = av ss = 0.0 v, t a = 0 to +75?c, unless otherwise specified applicable item symbol pins min typ max unit test condition note reference level vt ref vt ref 3.0 v cc + 0.3 v supply voltage mtg output v omt tonem 720 960 mvrms vt ref ?gnd = 3.0 v figure 14-2 voltage r l = 100 k sine wave output 2 mtg output %dismt tonem 1 3 % vt ref ?gnd = 3.0 v figure 14-2 distortion r l = 100 k sine wave output 2 note:2. tonem output is voltage-driven, so avoid high-current loads. 317
figure 14-1 toned load circuit figure 14-2 tonem load circuit toned r = 100 k w l gnd tonem r = 100 k w l gnd 318
14.3 operation timing figures 14-3 to 14-8 show operation timings. figure 14-3 system clock input timing figure 14-4 res low width timing figure 14-5 input timing t osc v ih v il t cph t cpl t cpr osc1 t cpf res v il t rel v ih v il t il irq to irq wkp to wkp adtrg tmif, tmig t ih 04 07 nmi 319
figure 14-6 serial interface 1 input/output timing t scyc t sckf t sckl t sckh t sod v v oh ol * * t sis t sih sck so si 1 1 1 t sckr v or v ih oh * v or v il ol * notes: * output timing reference levels output high: output low: refer to figure 14-9 for output load condition. v = 2.0 v v = 0.8 v oh ol 320
figure 14-7 sck 3 input clock timing figure 14-8 input/output timing of serial interface 3 in synchronous mode sck 3 t sckw t scyc sck rxd (receive data) txd (transmit data) 3 t scyc t txd t rxh t rxs v or v ih oh * v or v il ol v oh v ol * * * notes: * output timing reference levels output high: output low: refer to figure 14-9 for output load condition. v = 2.0 v v = 0.8 v oh ol 321
14.4 output load circuits figure 14-9 shows an output load condition. figure 14-9 output load condition v cc 2.4 k w 12 k w 30 pf output pin 322
appendix a cpu instruction set a.1 instructions operation notation rd8/16 general register (destination) (8 or 16 bits) rs8/16 general register (source) (8 or 16 bits) rn8/16 general register (8 or 16 bits) ccr condition code register n n (negative) flag in ccr z z (zero) flag in ccr v v (overflow) flag in ccr c c (carry) flag in ccr pc program counter sp stack pointer #xx: 3/8/16 immediate data (3, 8, or 16 bits) d: 8/16 displacement (8 or 16 bits) @aa: 8/16 absolute address (8 or 16 bits) + addition subtraction multiplication division logical and logical or ? exclusive logical or ? move logical complement condition code notation symbol modified according to the instruction result * undefined (value not guaranteed) 0 always cleared to 0 not affected by the instruction execution result 323
table a-1 lists the h8/300l cpu instruction set. table a-1 instruction set mnemonic operation i h n z v c mov.b #xx:8, rd b #xx:8 ? rd8 2 0? mov.b rs, rd b rs8 ? rd8 2 0? mov.b @rs, rd b @rs16 ? rd8 2 0? mov.b @(d:16, rs), rd b @(d:16, rs16) ? rd8 4 0? mov.b @rs+, rd b @rs16 ? rd8 2 0? rs16+1 ? rs16 mov.b @aa:8, rd b @aa:8 ? rd8 2 0? mov.b @aa:16, rd b @aa:16 ? rd8 4 0? mov.b rs, @rd b rs8 ? @rd16 2 0? mov.b rs, @(d:16, rd) b rs8 ? @(d:16, rd16) 4 0? mov.b rs, @ ?rd b rd16 ?1 ? rd16 2 0? rs8 ? @rd16 mov.b rs, @aa:8 b rs8 ? @aa:8 2 0? mov.b rs, @aa:16 b rs8 ? @aa:16 4 0? mov.w #xx:16, rd w #xx:16 ? rd 4 0? mov.w rs, rd w rs16 ? rd16 2 0? mov.w @rs, rd w @rs16 ? rd16 2 0? mov.w @(d:16, rs), rd w @(d:16, rs16) ? rd16 4 0? mov.w @rs+, rd w @rs16 ? rd16 2 0? rs16+2 ? rs16 mov.w @aa:16, rd w @aa:16 ? rd16 4 0? mov.w rs, @rd w rs16 ? @rd16 2 0? mov.w rs, @(d:16, rd) w rs16 ? @(d:16, rd16) 4 0? mov.w rs, @ ?rd w rd16 ?2 ? rd16 2 0? rs16 ? @rd16 mov.w rs, @aa:16 w rs16 ? @aa:16 4 0? pop rd w @sp ? rd16 2 0? sp+2 ? sp push rs w sp ?2 ? sp 2 0? rs16 ? @sp #xx: 8/16 rn @rn @(d:16, rn) @?n/@rn+ @aa: 8/16 @(d:8, pc) @@aa implied no. of states addressing mode/ instruction length (bytes) condition code operand size 324
table a-1 instruction set (cont) mnemonic operation i h n z v c add.b #xx:8, rd b rd8+#xx:8 ? rd8 2 2 add.b rs, rd b rd8+rs8 ? rd8 2 2 add.w rs, rd w rd16+rs16 ? rd16 2 2 addx.b #xx:8, rd b rd8+#xx:8 +c ? rd8 2 2 addx.b rs, rd b rd8+rs8 +c ? rd8 2 2 adds.w #1, rd w rd16+1 ? rd16 2 2 adds.w #2, rd w rd16+2 ? rd16 2 2 inc.b rd b rd8+1 ? rd8 2 ? daa.b rd b rd8 decimal adjust ? rd8 2 * * a 2 sub.b rs, rd b rd8 ?rs8 ? rd8 2 2 sub.w rs, rd w rd16 ?rs16 ? rd16 2 2 subx.b #xx:8, rd b rd8 ?#xx:8 ?c ? rd8 2 2 subx.b rs, rd b rd8 ?rs8 ?c ? rd8 2 2 subs.w #1, rd w rd16 ?1 ? rd16 2 2 subs.w #2, rd w rd16 ?2 ? rd16 2 2 dec.b rd b rd8 ?1 ? rd8 2 ? das.b rd b rd8 decimal adjust ? rd8 2 * * ? neg.b rd b 0 ?rd ? rd 2 2 cmp.b #xx:8, rd b rd8 ?#xx:8 2 2 cmp.b rs, rd b rd8 ?rs8 2 2 cmp.w rs, rd w rd16 ?rs16 2 2 #xx: 8/16 rn @rn @(d:16, rn) @?n/@rn+ @aa: 8/16 @(d:8, pc) @@aa implied no. of states addressing mode/ instruction length (bytes) condition code operand size 325
table a-1 instruction set (cont) mnemonic operation i h n z v c mulxu.b rs, rd b rd8 rs8 ? rd16 2 14 divxu.b rs, rd b rd16 ? rs8 ? rd16 2 ?? 14 (rdh: remainder, rdl: quotient) and.b #xx:8, rd b rd8 #xx:8 ? rd8 2 0? and.b rs, rd b rd8 rs8 ? rd8 2 0? or.b #xx:8, rd b rd8 #xx:8 ? rd8 2 0? or.b rs, rd b rd8 rs8 ? rd8 2 0? xor.b #xx:8, rd b rd8 ? #xx:8 ? rd8 2 0? xor.b rs, rd b rd8 ? rs8 ? rd8 2 0? not.b rd b rd ? rd 2 0? shal.b rd b 2 2 shar.b rd b 2 0 2 shll.b rd b 2 0 2 shlr.b rd b 2 0 0 2 rotxl.b rd b 2 0 2 rotxr.b rd b 2 0 2 b 7 b 0 0 c c b 7 b 0 b 7 b 0 0 c b 7 b 0 0c c b 7 b 0 c b 7 b 0 #xx: 8/16 rn @rn @(d:16, rn) @?n/@rn+ @aa: 8/16 @(d:8, pc) @@aa implied no. of states addressing mode/ instruction length (bytes) condition code operand size 326
table a-1 instruction set (cont) mnemonic operation i h n z v c rotl.b rd b 2 0 2 rotr.b rd b 2 0 2 bset #xx:3, rd b (#xx:3 of rd8) ? 1 2 2 bset #xx:3, @rd b (#xx:3 of @rd16) ? 1 4 8 bset #xx:3, @aa:8 b (#xx:3 of @aa:8) ? 1 4 8 bset rn, rd b (rn8 of rd8) ? 1 2 2 bset rn, @rd b (rn8 of @rd16) ? 1 4 8 bset rn, @aa:8 b (rn8 of @aa:8) ? 1 4 8 bclr #xx:3, rd b (#xx:3 of rd8) ? 0 2 2 bclr #xx:3, @rd b (#xx:3 of @rd16) ? 0 4 8 bclr #xx:3, @aa:8 b (#xx:3 of @aa:8) ? 0 4 8 bclr rn, rd b (rn8 of rd8) ? 0 2 2 bclr rn, @rd b (rn8 of @rd16) ? 0 4 8 bclr rn, @aa:8 b (rn8 of @aa:8) ? 0 4 8 bnot #xx:3, rd b (#xx:3 of rd8) ? 2 2 (#xx:3 of rd8) bnot #xx:3, @rd b (#xx:3 of @rd16) ? 4 8 (#xx:3 of @rd16) bnot #xx:3, @aa:8 b (#xx:3 of @aa:8) ? 4 8 (#xx:3 of @aa:8) bnot rn, rd b (rn8 of rd8) ? 2 2 (rn8 of rd8) bnot rn, @rd b (rn8 of @rd16) ? 4 8 (rn8 of @rd16) bnot rn, @aa:8 b (rn8 of @aa:8) ? 4 8 (rn8 of @aa:8) #xx: 8/16 rn @rn @(d:16, rn) @?n/@rn+ @aa: 8/16 @(d:8, pc) @@aa implied no. of states addressing mode/ instruction length (bytes) condition code operand size c b 7 b 0 c b 7 b 0 327
table a-1 instruction set (cont) mnemonic operation i h n z v c btst #xx:3, rd b (#xx:3 of rd8) ? z 2 2 btst #xx:3, @rd b (#xx:3 of @rd16) ? z 4 6 btst #xx:3, @aa:8 b (#xx:3 of @aa:8) ? z 4 6 btst rn, rd b (rn8 of rd8) ? z 2 2 btst rn, @rd b (rn8 of @rd16) ? z 4 6 btst rn, @aa:8 b (rn8 of @aa:8) ? z 4 6 bld #xx:3, rd b (#xx:3 of rd8) ? c 2 2 bld #xx:3, @rd b (#xx:3 of @rd16) ? c 4 6 bld #xx:3, @aa:8 b (#xx:3 of @aa:8) ? c 4 6 bild #xx:3, rd b (#xx:3 of rd8) ? c 2 2 bild #xx:3, @rd b (#xx:3 of @rd16) ? c 4 6 bild #xx:3, @aa:8 b (#xx:3 of @aa:8) ? c 4 6 bst #xx:3, rd b c ? (#xx:3 of rd8) 2 2 bst #xx:3, @rd b c ? (#xx:3 of @rd16) 4 8 bst #xx:3, @aa:8 b c ? (#xx:3 of @aa:8) 4 8 bist #xx:3, rd b c ? (#xx:3 of rd8) 2 2 bist #xx:3, @rd b c ? (#xx:3 of @rd16) 4 8 bist #xx:3, @aa:8 b c ? (#xx:3 of @aa:8) 4 8 band #xx:3, rd b c (#xx:3 of rd8) ? c 2 2 band #xx:3, @rd b c (#xx:3 of @rd16) ? c 4 6 band #xx:3, @aa:8 b c (#xx:3 of @aa:8) ? c 4 6 biand #xx:3, rd b c (#xx:3 of rd8) ? c 2 2 biand #xx:3, @rd b c (#xx:3 of @rd16) ? c 4 6 biand #xx:3, @aa:8 b c (#xx:3 of @aa:8) ? c 4 6 bor #xx:3, rd b c (#xx:3 of rd8) ? c 2 2 bor #xx:3, @rd b c (#xx:3 of @rd16) ? c 4 6 bor #xx:3, @aa:8 b c (#xx:3 of @aa:8) ? c 4 6 bior #xx:3, rd b c (#xx:3 of rd8) ? c 2 2 bior #xx:3, @rd b c (#xx:3 of @rd16) ? c 4 6 #xx: 8/16 rn @rn @(d:16, rn) @?n/@rn+ @aa: 8/16 @(d:8, pc) @@aa implied no. of states addressing mode/ instruction length (bytes) condition code operand size 328
table a-1 instruction set (cont) mnemonic operation i h n z v c bior #xx:3, @aa:8 b c (#xx:3 of @aa:8) ? c 4 6 bxor #xx:3, rd b c ? (#xx:3 of rd8) ? c 2 2 bxor #xx:3, @rd b c ? (#xx:3 of @rd16) ? c 4 6 bxor #xx:3, @aa:8 b c ? (#xx:3 of @aa:8) ? c 4 6 bixor #xx:3, rd b c ? (#xx:3 of rd8) ? c 2 2 bixor #xx:3, @rd b c ? (#xx:3 of @rd16) ? c 4 6 bixor #xx:3, @aa:8 b c ? (#xx:3 of @aa:8) ? c 4 6 bra d:8 (bt d:8) pc ? pc+d:8 2 4 brn d:8 (bf d:8) pc ? pc+2 2 4 bhi d:8 c z = 0 2 4 bls d:8 c z = 1 2 4 bcc d:8 (bhs d:8) c = 0 2 4 bcs d:8 (blo d:8) c = 1 2 4 bne d:8 z = 0 2 4 beq d:8 z = 1 2 4 bvc d:8 v = 0 2 4 bvs d:8 v = 1 2 4 bpl d:8 n = 0 2 4 bmi d:8 n = 1 2 4 bge d:8 n ? v = 0 2 4 blt d:8 n ? v = 1 2 4 bgt d:8 z (n ? v) = 0 2 4 ble d:8 z (n ? v) = 1 2 4 jmp @rn pc ? rn16 2 4 jmp @aa:16 pc ? aa:16 4 6 jmp @@aa:8 pc ? @aa:8 2 8 bsr d:8 sp ?2 ? sp 2 6 pc ? @sp pc ? pc+d:8 #xx: 8/16 rn @rn @(d:16, rn) @?n/@rn+ @aa: 8/16 @(d:8, pc) @@aa implied no. of states addressing mode/ instruction length (bytes) condition code operand size if condition is true then pc ? pc+d:8 else next; branching condition 329
table a-1 instruction set (cont) mnemonic operation i h n z v c jsr @rn sp ?2 ? sp 2 6 pc ? @sp pc ? rn16 jsr @aa:16 sp ?2 ? sp 4 8 pc ? @sp pc ? aa:16 jsr @@aa:8 sp ?2 ? sp 2 8 pc ? @sp pc ? @aa:8 rts pc ? @sp 2 8 sp+2 ? sp rte ccr ? @sp 2 10 sp+2 ? sp pc ? @sp sp+2 ? sp sleep transit to sleep mode. 2 2 ldc #xx:8, ccr b #xx:8 ? ccr 2 2 ldc rs, ccr b rs8 ? ccr 2 2 stc ccr, rd b ccr ? rd8 2 2 andc #xx:8, ccr b ccr #xx:8 ? ccr 2 2 orc #xx:8, ccr b ccr #xx:8 ? ccr 2 2 xorc #xx:8, ccr b ccr ? #xx:8 ? ccr 2 2 nop pc ? pc+2 2 2 eepmov if r4l 0 then 4 4 repeat @r5 ? @r6 r5 + 1 ? r5 r6 + 1 ? r6 r4l ?1 ? r4l until r4l = 0 else next; notes: set to 1 when there is a carry or borrow from bit 11; otherwise cleared to 0. if the result is zero, the previous value of the flag is retained; otherwise the flag is cleared to 0. a set to 1 if decimal adjustment produces a carry; otherwise retains value prior to arithmetic operation. ? the number of states required for execution is 4n + 9 (n = value of r4l). ? set to 1 if the divisor is negative; otherwise cleared to 0. ? set to 1 if the divisor is zero; otherwise cleared to 0. #xx: 8/16 rn @rn @(d:16, rn) @?n/@rn+ @aa: 8/16 @(d:8, pc) @@aa implied no. of states addressing mode/ instruction length (bytes) condition code operand size 330
a.2 operation code map table a-2 is an operation code map. it shows the operation codes contained in the first byte of the instruction code (bits 15 to 8 of the first instruction word). instruction when first bit of byte 2 (bit 7 of first instruction word) is 0. instruction when first bit of byte 2 (bit 7 of first instruction word) is 1. 331
   
 " #                  " # high low 0123456789abcdef 0 1 2 3 4 5 6 7 8 9 a b c d e f nop bra mulxu bset shll shal sleep brn divxu bnot shlr shar stc bhi bclr rotxl rotl ldc bls btst rotxr rotr orc or bcc rts xorc xor bcs bsr bor bior bxor bixor band biand andc and bne rte ldc beq not neg bld bild bst bist add sub bvc bvs mov inc dec bpl jmp adds subs bmi eepmov mov cmp bge blt addx subx bgt jsr daa das ble mov add addx cmp subx or xor and mov mov *    # note: bit-manipulation instructions the push and pop instructions are identical in machine language to mov instructions. * table a-2 operation code map 332
a.3 number of execution states the following describes the operation status in each instruction provided for the h8/300 l cpu, as well as a calculation of the number of execution states. table a-4 gives the number of cycles (as the operation status) for such operations as an instruction fetch, data read/write performed during an instruction execution. table a-3 gives the number of execution states required for each cycle (operation status). the total number of states required for the execution of an instruction can be calculated by using the following equation: execution states = i s i + j s j + k s k + l s l + m s m + n s n examples: when instruction is fetched from on-chip rom, and an on-chip ram is accessed. bset #0, @ff00 from table a-4: i = l = 2, j = k = m = n= 0 from table a-3: s i = 2, s l = 2 number of states required for execution = 2 2 + 2 2 = 8 when instruction is fetched from on-chip rom, branch address is read from on-chip rom, and on-chip ram is used for stack area. jsr @@ 30 from table a-4: i = 2, j = k = 1, l = m = n = 0 from table a-3: s i = s j = s k = 2 number of states required for execution = 2 2 + 1 2+ 1 2 = 8 333
table a-3 number of cycles in each instruction access location on-chip memory on-chip peripheral module instruction fetch s i 2 branch address read s j stack operation s k byte data access s l 2 or 3 * word data access s m internal operation s n 1 note: * depends on which on-chip module is accessed. see 2.9.1, notes on data access for details. execution status (instruction cycle) 334
table a-4 number of cycles in each instruction instruction branch stack byte data word data internal fetch addr. read operation access access operation instruction mnemonic i j k l m n add add.b #xx:8, rd 1 add.b rs, rd 1 add.w rs, rd 1 adds adds.w #1, rd 1 adds.w #2, rd 1 addx addx.b #xx:8, rd 1 addx.b rs, rd 1 and and.b #xx:8, rd 1 and.b rs, rd 1 andc andc #xx:8, ccr 1 band band #xx:3, rd 1 band #xx:3, @rd 2 1 band #xx:3, @aa:8 2 1 bcc bra d:8 (bt d:8) 2 brn d:8 (bf d:8) 2 bhi d:8 2 bls d:8 2 bcc d:8 (bhs d:8) 2 bcs d:8 (blo d:8) 2 bne d:8 2 beq d:8 2 bvc d:8 2 bvs d:8 2 bpl d:8 2 bmi d:8 2 bge d:8 2 blt d:8 2 bgt d:8 2 ble d:8 2 bclr bclr #xx:3, rd 1 bclr #xx:3, @rd 2 2 bclr #xx:3, @aa:8 2 2 bclr rn, rd 1 335
table a-4 number of cycles in each instruction (cont) instruction branch stack byte data word data internal fetch addr. read operation access access operation instruction mnemonic i j k l m n bclr bclr rn, @rd 2 2 bclr rn, @aa:8 2 2 biand biand #xx:3, rd 1 biand #xx:3, @rd 2 1 biand #xx:3, @aa:8 2 1 bild bild #xx:3, rd 1 bild #xx:3, @rd 2 1 bild #xx:3, @aa:8 2 1 bior bior #xx:3, rd 1 bior #xx:3, @rd 2 1 bior #xx:3, @aa:8 2 1 bist bist #xx:3, rd 1 bist #xx:3, @rd 2 2 bist #xx:3, @aa:8 2 2 bixor bixor #xx:3, rd 1 bixor #xx:3, @rd 2 1 bixor #xx:3, @aa:8 2 1 bld bld #xx:3, rd 1 bld #xx:3, @rd 2 1 bld #xx:3, @aa:8 2 1 bnot bnot #xx:3, rd 1 bnot #xx:3, @rd 2 2 bnot #xx:3, @aa:8 2 2 bnot rn, rd 1 bnot rn, @rd 2 2 bnot rn, @aa:8 2 2 bor bor #xx:3, rd 1 bor #xx:3, @rd 2 1 bor #xx:3, @aa:8 2 1 bset bset #xx:3, rd 1 bset #xx:3, @rd 2 2 bset #xx:3, @aa:8 2 2 bset rn, rd 1 bset rn, @rd 2 2 336
table a-4 number of cycles in each instruction (cont) instruction branch stack byte data word data internal fetch addr. read operation access access operation instruction mnemonic i j k l m n bset bset rn, @aa:8 2 2 bsr bsr d:8 2 1 bst bst #xx:3, rd 1 bst #xx:3, @rd 2 2 bst #xx:3, @aa:8 2 2 btst btst #xx:3, rd 1 btst #xx:3, @rd 2 1 btst #xx:3, @aa:8 2 1 btst rn, rd 1 btst rn, @rd 2 1 btst rn, @aa:8 2 1 bxor bxor #xx:3, rd 1 bxor #xx:3, @rd 2 1 bxor #xx:3, @aa:8 2 1 cmp cmp. b #xx:8, rd 1 cmp. b rs, rd 1 cmp.w rs, rd 1 daa daa.b rd 1 das das.b rd 1 dec dec.b rd 1 divxu divxu.b rs, rd 1 12 eepmov eepmov 2 2n+2* 1 inc inc.b rd 1 jmp jmp @rn 2 jmp @aa:16 2 2 jmp @@aa:8 2 1 2 jsr jsr @rn 2 1 jsr @aa:16 2 1 2 jsr @@aa:8 2 1 1 ldc ldc #xx:8, ccr 1 ldc rs, ccr 1 mov mov.b #xx:8, rd 1 mov.b rs, rd 1 mov.b @rs, rd 1 1 note: n: initial value in r4l. the source and destination operands are accessed n + 1 times each. 337
table a-4 number of cycles in each instruction (cont) instruction branch stack byte data word data internal fetch addr. read operation access access operation instruction mnemonic i j k l m n mov mov.b @(d:16, rs), rd 2 1 mov.b @rs+, rd 1 1 2 mov.b @aa:8, rd 1 1 mov.b @aa:16, rd 2 1 mov.b rs, @rd 1 1 mov.b rs, @(d:16, rd) 2 1 mov.b rs, @?d 1 1 2 mov.b rs, @aa:8 1 1 mov.b rs, @aa:16 2 1 mov.w #xx:16, rd 2 mov.w rs, rd 1 mov.w @rs, rd 1 1 mov.w @(d:16, rs), rd 2 1 mov.w @rs+, rd 1 1 2 mov.w @aa:16, rd 2 1 mov.w rs, @rd 1 1 mov.w rs, @(d:16, rd) 2 1 mov.w rs, @?d 1 1 2 mov.w rs, @aa:16 2 1 mulxu mulxu.b rs, rd 1 12 neg neg.b rd 1 nop nop 1 not not.b rd 1 or or.b #xx:8, rd 1 or.b rs, rd 1 orc orc #xx:8, ccr 1 pop pop rd 1 1 2 push push rs 1 1 2 rotl rotl.b rd 1 rotr rotr.b rd 1 rotxl rotxl.b rd 1 rotxr rotxr.b rd 1 rte rte 2 2 2 rts rts 2 1 2 338
table a-4 number of cycles in each instruction (cont) instruction branch stack byte data word data internal fetch addr. read operation access access operation instruction mnemonic i j k l m n shll shll.b rd 1 shal shal.b rd 1 shar shar.b rd 1 shlr shlr.b rd 1 sleep sleep 1 stc stc ccr, rd 1 sub sub.b rs, rd 1 sub.w rs, rd 1 subs subs.w #1, rd 1 subs.w #2, rd 1 subx subx.b #xx:8, rd 1 subx.b rs, rd 1 xor xor.b #xx:8, rd 1 xor.b rs, rd 1 xorc xorc #xx:8, ccr 1 339
appendix b on-chip registers b.1 i/o registers (1) bit names bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 h'90 mtcr daoe mten dir fr1 fr2 ft1 ft0 h'91 eblr ebl6 ebl5 ebl4 ebl3 ebl2 ebl1 ebl0 h'92 frmr frm7 frm6 frm5 frm4 frm3 frm2 frm1 frm0 h'93 ftnr ftn7 ftn6 ftn5 ftn4 ftn3 ftn2 ftn1 ftn0 h'94 itlr itl4 itl3 itl2 itl1 itl0 h'95 h'96 h'97 h'98 pmr1 irq3 irq2 irq1 tmig tmofh tmofl tmow h'99 pmr2 irq0 pof1 ncs so1 si1 sck1 irq4 h'9a h'9b pmr5 wkp7 wkp6 wkp5 wkp4 wkp3 wkp2 wkp1 wkp0 h'9c pucr1 pucr1 7 pucr1 6 pucr1 5 pucr1 4 pucr1 3 pucr1 2 pucr1 1 pucr1 0 h'9d pucr2 pucr2 7 pucr2 6 pucr2 5 pucr2 4 pucr2 3 pucr2 2 pucr2 1 pucr2 0 h'9e pucr5 pucr5 7 pucr5 6 pucr5 5 pucr5 4 pucr5 3 pucr5 2 pucr5 1 pucr5 0 h'9f pucr6 pucr6 7 pucr6 6 pucr6 5 pucr6 4 pucr6 3 pucr6 2 pucr6 1 pucr6 0 h'a0 scr1 snc1 snc0 cks3 cks2 cks1 cks0 sci1 h'a1 scsr1 sol orer stf h'a2 sdru sdru7 sdru6 sdru5 sdru4 sdru3 sdru2 sdru1 sdru0 h'a3 sdrl sdrl7 sdrl6 sdrl5 sdrl4 sdrl3 sdrl2 sdrl1 sdrl0 h'a4 h'a5 h'a6 h'a7 h'a8 smr com chr pe pm stop mp cks1 cks0 sci3 h'a9 brr brr7 brr6 brr5 brr4 brr3 brr2 brr1 brr0 h'aa scr3 tie rie te re mpie teie cke1 cke0 h'ab tdr tdr7 tdr6 tdr5 tdr4 tdr3 tdr2 tdr1 tdr0 h'ac ssr tdre rdrf oer fer per tend mpbr mpbt h'ad rdr rdr7 rdr6 rdr5 rdr4 rdr3 rdr2 rdr1 rdr0 h'ae h'af notation sci1: serial communication interface 1 sci3: serial communication interface 3 address register (low) name module name i/o ports multi- tone gener- ator 340
bit names bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 h'b0 tma tma7 tma6 tma5 tma3 tma2 tma1 tma0 timer a h'b1 tca tca7 tca6 tca5 tca4 tca3 tca2 tca1 tca0 h'b2 dtcr dten cloe rwoe clf1 clf0 rwf1 rwf0 h'b3 dtlr dtl4 dtl3 dtl2 dtl1 dtl0 h'b4 h'b5 h'b6 tcrf tolh cksh2 cksh1 cksh0 toll cksl2 cksl1 cksl0 timer f h'b7 tcsrf ovfh cmfh ovieh cclrh ovfl cmfl oviel cclrl h'b8 tcfh tcfh7 tcfh6 tcfh5 tcfh4 tcfh3 tcfh2 tcfh1 tcfh0 h'b9 tcfl tcfl7 tcfl6 tcfl5 tcfl4 tcfl3 tcfl2 tcfl1 tcfl0 h'ba ocrfh ocrfh7 ocrfh6 ocrfh5 ocrfh4 ocrfh3 ocrfh2 ocrfh1 ocrfh0 h'bb ocrfl ocrfl7 ocrfl6 ocrfl5 ocrfl4 ocrfl3 ocrfl2 ocrfl1 ocrfl0 h'bc tmg ovfh ovfl ovie iiegs cclr1 cclr0 cks1 cks0 timer g h'bd icrgf icrgf7 icrgf6 icrgf5 icrgf4 icrgf3 icrgf2 icrgf1 icrgf0 h'be icrgr icrgr7 icrgr6 icrgr5 icrgr4 icrgr3 icrgr2 icrgr1 icrgr0 h'bf h'c0 h'c1 h'c2 h'c3 h'c4 amr cks trge cks1 ch3 ch2 ch1 ch0 h'c5 adrr adr7 adr6 adr5 adr4 adr3 adr2 adr1 adr0 h'c6 adsr adsf h'c7 h'c8 h'c9 h'ca h'cb h'cc h'cd h'ce h'cf address register (low) name module name dtmf gener- ator a/d convert- er 341
bit names bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 h'd0 h'd1 h'd2 pdrd pd 7 pd 6 pd 5 pd 4 pd 3 pd 2 pd 1 pd 0 h'd3 pdre pe 3 pe 2 pe 1 pe 0 h'd4 pdr1 p1 7 p1 6 p1 5 p1 4 p1 3 p1 2 p1 1 p1 0 h'd5 pdr2 p2 7 p2 6 p2 5 p2 4 p2 3 p2 2 p2 1 p2 0 h'd6 h'd7 h'd8 pdr5 p5 7 p5 6 p5 5 p5 4 p5 3 p5 2 p5 1 p5 0 h'd9 pdr6 p6 7 p6 6 p6 5 p6 4 p6 3 p6 2 p6 1 p6 0 h'da pdr7 p7 7 p7 6 p7 5 p7 4 p7 3 p7 2 p7 1 p7 0 h'db pdr8 p8 7 p8 6 p8 5 p8 4 p8 3 p8 2 p8 1 p8 0 h'dc pdr9 p9 7 p9 6 p9 5 p9 4 p9 3 p9 2 p9 1 p9 0 h'dd pdra pa 3 pa 2 pa 1 pa 0 h'de pdrb pb 7 pb 6 pb 5 pb 4 pb 3 pb 2 pb 1 pb 0 h'df h'e0 h'e1 h'e2 pcrd pcrd 7 pcrd 6 pcrd 5 pcrd 4 pcrd 3 pcrd 2 pcrd 1 pcrd 0 h'e3 pcre pcre 3 pcre 2 pcre 1 pcre 0 h'e4 pcr1 pcr1 7 pcr1 6 pcr1 5 pcr1 4 pcr1 3 pcr1 2 pcr1 1 pcr1 0 h'e5 pcr2 pcr2 7 pcr2 6 pcr2 5 pcr2 4 pcr2 3 pcr2 2 pcr2 1 pcr2 0 h'e6 h'e7 h'e8 pcr5 pcr5 7 pcr5 6 pcr5 5 pcr5 4 pcr5 3 pcr5 2 pcr5 1 pcr5 0 h'e9 pcr6 pcr6 7 pcr6 6 pcr6 5 pcr6 4 pcr6 3 pcr6 2 pcr6 1 pcr6 0 h'ea pcr7 pcr7 7 pcr7 6 pcr7 5 pcr7 4 pcr7 3 pcr7 2 pcr7 1 pcr7 0 h'eb pcr8 pcr8 7 pcr8 6 pcr8 5 pcr8 4 pcr8 3 pcr8 2 pcr8 1 pcr8 0 h'ec pcr9 pcr9 7 pcr9 6 pcr9 5 pcr9 4 pcr9 3 pcr9 2 pcr9 1 pcr9 0 h'ed pcra pcra 3 pcra 2 pcra 1 pcra 0 h'ee h'ef address register (low) name module name i/o ports i/o ports i/o ports i/o ports 342
bit names bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 h'f0 syscr1 ssby sts2 sts1 sts0 lson h'f1 syscr2 nesel dton mson sa1 sa0 h'f2 iegr nmieg ieg4 ieg3 ieg2 ieg1 ieg0 h'f3 ienr1 ienta iens1 ienwp ien4 ien3 ien2 ien1 ien0 h'f4 ienr2 iendt ienad ienmt ientg ientfh ientfl h'f5 h'f6 irr1 irrta irrs1 irri4 irri3 irri2 irri1 irri0 h'f7 irr2 irrdt irrad irrmt irrtg irrtfh irrtfl h'f8 h'f9 iwpr iwpf7 iwpf6 iwpf5 iwpf4 iwpf3 iwpf2 iwpf1 iwpf0 system control h'fa h'fb h'fc h'fd h'fe h'ff h'ff address register (low) name module name system control system control 343
b.2 i/o registers (2) mtcr?ultitone control register h'90 multitone generator register name address to which the register is mapped name of on-chip supporting module register acronym bit numbers initial bit values names of the bits. dashes (? indicate reserved bits. full name of bit descriptions of bit settings read only write only read and write r w r/w possible types of access bit initial value read/write 7 da0e 0 r/w 6 mten 0 r/w 5 dir 0 r/w 3 fr1 0 0 ft0 0 r/w 2 fr0 0 r/w 1 ft1 0 r/w 4 1 fine-tuning counter clock source select ft0 0 1 0 1 clock division ratio 1t osc (counter clock = f osc ) 2t osc (counter clock = f osc /2) 4t osc (counter clock = f osc /4) 8t osc (counter clock = f osc /8) ft1 0 0 1 1 frame counter clock source select fr0 0 1 0 1 clock division ratio 1t osc (counter clock = f osc ) 2t osc (counter clock = f osc /2) 4t osc (counter clock = f osc /4) 8t osc (counter clock = f osc /8) fr1 0 0 1 1 344
mtcr?ultitone control register h'90 multitone generator bit initial value read/write 7 daoe 0 r/w 6 mten 0 r/w 5 dir 0 r/w 4 1 3 fr1 0 r/w 0 ft0 0 r/w 2 fr0 0 r/w 1 ft1 0 r/w fine-tuning counter clock source select ft0 0 1 0 1 clock division ratio 1t osc (counter clock = f osc ) 2t osc (counter clock = f osc /2) 4t osc (counter clock = f osc /4) 8t osc (counter clock = f osc /8) initial direction 0 1 level is initially incremented level is initially decremented ft1 0 0 1 1 frame counter clock source select ft0 0 1 0 1 clock division ratio 1t osc (counter clock = f osc ) 2t osc (counter clock = f osc /2) 4t osc (counter clock = f osc /4) 8t osc (counter clock = f osc /8) ft1 0 0 1 1 multitone generator enable 0 1 multitone generator is halted multitone generator operates d/a output enable 0 1 analog output is disabled (high impedance) analog output is enabled 345
eblr?ffective bit length register h'91 multitone generator frmr?rame register h'92 multitone generator ftnr?ine-tuning register h'93 multitone generator itlr?nitial level register h'94 multitone generator bit initial value read/write 7 1 6 ebl6 0 r/w 5 ebl5 0 r/w 4 ebl4 0 r/w 3 ebl3 0 r/w 0 ebl0 0 r/w 2 ebl2 0 r/w 1 ebl1 0 r/w effective bit length ?1 bit initial value read/write 7 frm7 0 r/w 6 frm6 0 r/w 5 frm5 0 r/w 4 frm4 0 r/w 3 frm3 0 r/w 0 frm0 0 r/w 2 frm2 0 r/w 1 frm1 0 r/w value reloaded into frame counter bit initial value read/write 7 ftn7 0 r/w 6 ftn6 0 r/w 5 ftn5 0 r/w 4 ftn4 0 r/w 3 ftn3 0 r/w 0 ftn0 0 r/w 2 ftn2 0 r/w 1 ftn1 0 r/w value reloaded into fine-tuning counter bit initial value read/write 7 1 6 1 5 1 4 itl4 0 r/w 3 itl3 0 r/w 0 itl0 0 r/w 2 itl2 0 r/w 1 itl1 0 r/w initial analog output level 346
pmr1?ort mode register 1 h'98 i/o ports bit initial value read/write 7 irq3 0 r/w 6 irq2 0 r/w 5 irq1 0 r/w 4 1 3 tmig 0 r/w 0 tmow 0 r/w 2 tmofh 0 r/w 1 tmofl 0 r/w p1 /tmow pin function switch 0 functions as p1 i/o pin 1 functions as tmow output pin p1 /tmig pin function switch 0 functions as p1 i/o pin 1 functions as tmig input pin p1 /tmofl pin function switch 0 functions as p1 i/o pin 1 functions as tmofl output pin p1 /tmofh pin function switch 0 functions as p1 i/o pin 1 functions as tmofh output pin p1 /irq pin function switch p1 /irq pin function switch 1 0 functions as p1 i/o pin 1 functions as irq input pin 0 functions as p1 i/o pin 1 functions as irq input pin p1 /irq /tmif pin function switch 1 0 functions as p1 i/o pin 1 functions as irq /tmif input pin 0 3 1 2 5 6 7 0 3 1 2 5 6 7 1 2 3 1 2 3 347
pmr2?ort mode register 2 h'99 i/o ports bit initial value read/write 7 irq0 0 r/w 6 1 5 pof1 0 r/w 4 ncs 0 r/w 3 so1 0 r/w 0 irq4 0 r/w 2 si1 0 r/w 1 sck1 0 r/w p2 /sck pin function switch 0 functions as p2 i/o pin 1 functions as sck i/o pin p2 /si pin function switch 0 functions as p2 i/o pin 1 functions as si input pin tmig noise canceller select 0 noise canceller function not selected 1 noise canceller function selected p2 /so pin pmos control p2 /irq /adtrg pin function switch 1 0 cmos output 1 nmos open drain output 0 functions as p2 i/o pin 1 functions as irq /adtrg input pin 1 2 3 0 1 0 1 4 4 1 p2 /so pin function switch 1 0 functions as p2 i/o pin 1 functions as so output pin 3 3 1 1 1 1 2 1 p2 /irq pin function switch 1 0 functions as p2 i/o pin 1 functions as irq input pin 7 7 0 0 348
pmr5?ort mode register 5 h'9b i/o ports pucr1?ort pull-up control register 1 h'9c i/o ports pucr2?ort pull-up control register 2 h'9d i/o ports pucr5?ort pull-up control register 5 h'9e i/o ports bit initial value read/write 7 wkp 0 r/w 6 wkp 0 r/w 5 wkp 0 r/w 4 wkp 0 r/w 3 wkp 0 r/w 0 wkp 0 r/w 2 wkp 0 r/w 1 wkp 0 r/w 0 functions as p5 i/o pin 1 functions as wkp input pin n n 7 65432 10 p5 /wkp pin function switch nn (n = 7 to 0) bit initial value read/write 7 pucr1 0 r/w 6 pucr1 0 r/w 5 pucr1 0 r/w 4 pucr1 0 r/w 3 pucr1 0 r/w 0 pucr1 0 r/w 2 pucr1 0 r/w 1 pucr1 0 r/w 7 65432 10 bit initial value read/write 7 pucr2 0 r/w 6 pucr2 0 r/w 5 pucr2 0 r/w 4 pucr2 0 r/w 3 pucr2 0 r/w 0 pucr2 0 r/w 2 pucr2 0 r/w 1 pucr2 0 r/w 7 65432 10 bit initial value read/write 7 pucr5 0 r/w 6 pucr5 0 r/w 5 pucr5 0 r/w 4 pucr5 0 r/w 3 pucr5 0 r/w 0 pucr5 0 r/w 2 pucr5 0 r/w 1 pucr5 0 r/w 7 65432 10 349
pucr6?ort pull-up control register 6 h'9f i/o ports scr1?erial control register 1 h'a0 sci1 bit initial value read/write 7 pucr6 0 r/w 6 pucr6 0 r/w 5 pucr6 0 r/w 4 pucr6 0 r/w 3 pucr6 0 r/w 0 pucr6 0 r/w 2 pucr6 0 r/w 1 pucr6 0 r/w 7 65432 10 bit initial value read/write 7 snc1 0 r/w 6 snc0 0 r/w 5 0 r/w 4 0 r/w 3 cks3 0 r/w 0 cks0 0 r/w 2 cks2 0 r/w 1 cks1 0 r/w operation mode select clock source select 0 clock source is prescaler s, and pin sck is output pin 1 clock source is external clock, and pin sck is input pin 0 8-bit synchronous mode 16-bit synchronous mode 0 1 1 continuous clock output mode reserved 0 1 clock select bit 2 cks2 cks1 cks0 bit 1 bit 0 0 ?1024 ?256 1 1 0 ?64 ?32 1 ?16 100 1 ?8 00 ?4 10 1 ?2 ?= 5 mhz 204.8 s 51.2 s 12.8 s 6.4 s 3.2 s 1.6 s 0.8 s ?= 2.5 mhz 409.6 s 102.4 s 25.6 s 12.8 s 6.4 s 3.2 s 1.6 s 0.8 s synchronous transfer clock cycle 1 1 prescaler division 350
scsr1?erial control/status register 1 h'a1 sci1 sdru?erial data register u h'a2 sci1 bit initial value read/write 7 1 6 sol 0 r/w 5 orer 0 r/(w) 4 0 3 0 0 stf 0 r/w 2 0 1 0 r/w extended data bit overrun error flag 0 read write * start flag 0 indicates that transfer is stopped invalid 1 read write read write indicates transfer in progress starts a transfer operation 1 read write so 1 pin output level is low so 1 pin output level changes to low so 1 pin output level is high so 1 pin output level changes to high note: only a write of 0 for flag clearing is possible. * 0 [clearing condition] after reading 1, cleared by writing 0 1 [setting condition] set if a clock pulse is input after transfer is complete, when an external clock is used bit initial value read/write 7 sdru7 undefined r/w 6 sdru6 undefined r/w 5 sdru5 undefined r/w 4 sdru4 undefined r/w 3 sdru3 undefined r/w 0 sdru0 undefined r/w 2 sdru2 undefined r/w 1 sdru1 undefined r/w stores transmit and receive data 8-bit transfer mode: 16-bit transfer mode: not used upper 8 bits of data 351
sdrl?erial data register l h'a3 sci1 bit initial value read/write 7 sdrl7 undefined r/w 6 sdrl6 undefined r/w 5 sdrl5 undefined r/w 4 sdrl4 undefined r/w 3 sdrl3 undefined r/w 0 sdrl0 undefined r/w 2 sdrl2 undefined r/w 1 sdrl1 undefined r/w stores transmit and receive data 8-bit transfer mode: 16-bit transfer mode: 8-bit data lower 8 bits of data 352
smr?erial mode register h'a8 sci3 brr?it rate register h'a9 sci3 bit initial value read/write 7 com 0 r/w 6 chr 0 r/w 5 pe 0 r/w 4 pm 0 r/w 3 stop 0 r/w 0 cks0 0 r/w 2 mp 0 r/w 1 cks1 0 r/w parity enable 0 parity bit adding and checking disabled 1 parity bit adding and checking enabled clock select 0, 1 0 0 1 10 1 ?clock ?4 clock ?16 clock ?64 clock multiprocessor mode 0 multiprocessor communication function disabled 1 multiprocessor communication function enabled stop bit length 0 1 stop bit 1 2 stop bits parity mode 0 even parity 1 odd parity character length 0 8-bit data 1 7-bit data communication mode 0 asynchronous mode 1 synchronous mode bit initial value read/write 7 brr7 1 r/w 6 brr6 1 r/w 5 brr5 1 r/w 4 brr4 1 r/w 3 brr3 1 r/w 0 brr0 1 r/w 2 brr2 1 r/w 1 brr1 1 r/w 353
scr3?erial control register 3 h'aa sci3 bit initial value read/write 7 tie 0 r/w 6 rie 0 r/w 5 te 0 r/w 4 re 0 r/w 3 mpie 0 r/w 0 cke0 0 r/w 2 teie 0 r/w 1 cke1 0 r/w clock enable cke1 bit 1 cke0 bit 0 description transmit end interrupt enable 0 transmit end interrupt (tei) disabled communication mode clock source sck pin function 3 1 transmit end interrupt (tei) enabled multiprocessor interrupt enable 0 multiprocessor interrupt request disabled (ordinary receive operation) 1 multiprocessor interrupt request enabled until a multiprocessor bit value of 1 is received, the receive data full interrupt (rxi) and receive error interrupt (eri) are disabled, and serial status register (ssr) flags rdrf, fer, and oer are not set. 0 0 asynchronous internal clock i/o port synchronous internal clock serial clock output 1 asynchronous internal clock clock output synchronous reserved 1 0 asynchronous external clock clock input synchronous external clock serial clock input 1 asynchronous reserved synchronous reserved [clearing condition] multiprocessor bit receives a data value of 1 transmit enable 0 transmit operation disabled (txd is a general i/o port) 1 transmit operation enabled (txd is the transmit data pin) receive enable 0 receive operation disabled (rxd is a general i/o port) 1 receive operation enabled (rxd is the receive data pin) receive interrupt enable 0 receive data full interrupt request (rxi) and receive error interrupt request (eri) disabled 1 receive data full interrupt request (rxi) and receive error interrupt request (eri) enabled transmit interrupt enable 0 transmit data empty interrupt request (txi) disabled 1 transmit data empty interrupt request (txi) enabled reserved reserved reserved 354
tdr?ransmit data register h'ab sci3 bit initial value read/write 7 tdr7 1 r/w 6 tdr6 1 r/w 5 tdr5 1 r/w 4 tdr4 1 r/w 3 tdr3 1 r/w 0 tdr0 1 r/w 2 tdr2 1 r/w 1 tdr1 1 r/w data to be transferred to tsr 355
ssr?erial status register h'ac sci3 bit initial value read/write 7 tdre 1 r/(w) 6 rdrf 0 r/(w) 5 oer 0 r/(w) 4 fer 0 r/(w) 3 per 0 r/(w) 0 mpbt 0 r/w 2 tend 1 r 1 mpbr 0 r * * * * * note: * only a write of 0 for flag clearing is possible. 0 the multiprocessor bit in transmit data is 0 multiprocessor bit transmit 1 the multiprocessor bit in transmit data is 1 0 indicates reception of data in which the multiprocessor bit is 0 multiprocessor bit receive 1 indicates reception of data in which the multiprocessor bit is 1 0 indicates that transmission is in progress transmit end [clearing conditions] after reading tdre = 1, cleared by writing 0 to tdre. when data is written to tdr by an instruction. 1 indicates that a transmission has ended [setting conditions] when bit te in serial control register 3 (scr3) is 0. if tdre is set to 1 when the last bit of a transmitted character is sent. 0 indicates that data receiving is in progress or has been completed parity error [clearing conditions] after reading per = 1, cleared by writing 0 1 indicates that a parity error occurred in data receiving [setting conditions] when the sum of 1s in received data plus the parity bit does not match the parity mode bit (pm) setting in the serial mode register (smr) 0 indicates that data receiving is in progress or has been completed framing error [clearing conditions] after reading fer = 1, cleared by writing 0 1 indicates that a framing error occurred in data receiving [setting conditions] the stop bit at the end of receive data is checked and found to be 0 0 indicates that data receiving is in progress or has been completed overrun error [clearing conditions] after reading oer = 1, cleared by writing 0 1 indicates that an overrun error occurred in data receiving [setting conditions] when data receiving is completed while rdrf is set to 1 0 indicates there is no receive data in rdr receive data register full [clearing conditions] after reading rdrf = 1, cleared by writing 0. when data is read from rdr by an instruction. 1 indicates that there is receive data in rdr [setting conditions] when receiving ends normally, with receive data transferred from rsr to rdr 0 indicates that transmit data written to tdr has not been transferred to tsr transmit data register empty [clearing conditions] after reading tdre = 1, cleared by writing 0. when data is written to tdr by an instruction. 1 indicates that no transmit data has been written to tdr, or the transmit data written to tdr has been transferred to tsr [setting conditions] when bit te in serial control register 3 (scr3) is 0. when data is transferred from tdr to tsr. 356
rdr?eceive data register h'ad sci3 tma?imer mode register a h'b0 timer a bit initial value read/write 7 rdr7 0 r 6 rdr6 0 r 5 rdr5 0 r 4 rdr4 0 r 3 rdr3 0 r 0 rdr0 0 r 2 rdr2 0 r 1 rdr1 0 r bit initial value read/write 7 tma7 0 r/w 6 tma6 0 r/w 5 tma5 0 r/w 0 tma0 0 r/w 2 tma2 0 r/w 1 tma1 0 r/w internal clock select tma3 tma2 0 pss pss pss pss 0 4 1 clock output select 0 ?32 ?16 tma1 0 1 tma0 0 0 1 1 pss pss pss pss 10 1 0 0 1 1 1 psw psw psw psw 00 1 0 0 1 1 psw and tca are reset 10 1 0 0 1 1 prescaler and divider ratio or overflow period ?8192 ?4096 ?2048 ?512 ?256 ?128 ?32 ?8 1 s 0.5 s 0.25 s 0.03125 s interval timer time base function 0 0 1 ?8 ?4 10 1 1 00 1 10 1 ? /32 w ? /16 w ? /8 w ? /4 w 3 tma3 0 r/w 357
tca?imer counter a h'b1 timer a bit initial value read/write 7 tca7 0 r 6 tca6 0 r 5 tca5 0 r 4 tca4 0 r 3 tca3 0 r 0 tca0 0 r 2 tca2 0 r 1 tca1 0 r count value 358
dtcr?tmf control register h'b2 dtmf generator bit initial value read/write 7 dten 0 r/w 6 1 5 cloe 0 r/w 4 rwoe 0 r/w 3 clf1 0 r/w 0 rwf0 0 r/w 2 clf0 0 r/w 1 rwf1 0 r/w dtmf row signal output frequency 1 and 0 rwf0 0 1 0 1 dtmf row signal output frequency 697 hz (r1) 770 hz (r2) 852 hz (r3 941 hz (r4) row output enable 0 1 dtmf row signal output is disabled (high-impedance) dtmf row signal output is enabled rwf1 0 1 dtmf column signal output frequency 1 and 0 clf0 0 1 0 1 dtmf column signal output frequency 1209 hz (c1) 1336 hz (c2) 1447 hz (c3) 1633 hz (c4) clf1 0 1 column output enable 0 1 dtmf column signal output is disabled (high-impedance) dtmf column signal output is enabled dtmf generator enable 0 1 dtmf generator is halted dtmf generator operates 359
dtlr?tmf load register h'b3 dtmf generator bit initial value read/write 7 1 6 1 5 1 4 dtl4 0 r/w 3 dtl3 0 r/w 0 dtl0 0 r/w 2 dtl2 0 r/w 1 dtl1 0 r/w osc clock division ratio 4 to 0 dtl3 0 0 0 0 0 1 1 1 division ratio illegal setting illegal setting illegal setting 3 4 25 illegal setting illegal setting dtl4 0 0 0 0 0 1 1 1 dtl2 0 0 0 0 1 0 0 1 dtl1 0 0 1 1 0 0 1 dtl0 0 1 0 1 0 1 osc clock frequency 1.2 mhz 1.6 mhz 10 mhz * * * (initial value) * note: don? care 360
tcrf?imer control register f h'b6 timer f bit initial value read/write 7 tolh 0 w 6 cksh2 0 w 5 cksh1 0 w 3 toll 0 w 0 cksl0 0 w 2 cksl2 0 w 1 cksl1 0 w 4 cksh0 0 w toggle output level h clock select l 0 1 00 1 10 1 internal clock: internal clock: internal clock: internal clock: ?32 ?16 ?4 note: don? care * external event (tmif): rising or falling edge ** ?2 toggle output level l 0 low level 1 high level clock select h 0 1 00 1 10 1 internal clock: internal clock: internal clock: internal clock: ?32 ?16 ?4 16-bit mode selected. tcfl overflow signals are counted. ** ?2 0 low level 1 high level 361
tcsrf?imer control/status register f h'b7 timer f bit initial value read/write 7 ovfh 0 r/(w) 6 cmfh 0 r/(w) 5 ovieh 0 r/w 4 cclrh 0 r/w 3 ovfl 0 r/(w) 0 cclrl 0 r/w 2 cmfl 0 r/(w) 1 oviel 0 r/w timer overflow flag h timer overflow interrupt enable l 0 [clearing condition] after reading ovfh = 1, cleared by writing 0 to ovfh 1 [setting condition] when the value of tcfh goes from h'ff to h'00 0 tcfl overflow interrupt disabled 1 tcfl overflow interrupt enabled timer overflow interrupt enable h compare match flag h 0 [clearing condition] after reading cmfh = 1, cleared by writing 0 to cmfh 1 [setting condition] when the tcfh value matches the ocrfh value 0 tcfh overflow interrupt disabled 1 tcfh overflow interrupt enabled counter clear h 0 16-bit mode: 8-bit mode: 1 tcf clearing by compare match disabled tcfh clearing by compare match disabled 16-bit mode: 8-bit mode: tcf clearing by compare match enabled tcfh clearing by compare match enabled timer overflow flag l 0 [clearing condition] after reading ovfl = 1, cleared by writing 0 to ovfl 1 [setting condition] when the value of tcfl goes from h'ff to h'00 compare match flag l 0 [clearing condition] after reading cmfl = 1, cleared by writing 0 to cmfl 1 [setting condition] when the tcfl value matches the ocrfl value counter clear l 0 tcfl clearing by compare match disabled 1 tcfl clearing by compare match enabled 362
tcfh?-bit timer counter fh h'b8 timer f tcfl?-bit timer counter fl h'b9 timer f ocrfh?utput compare register fh h'ba timer f ocrfl?utput compare register fl h'bb timer f bit initial value read/write 7 tcfh7 0 r/w 6 tcfh6 0 r/w 5 tcfh5 0 r/w 4 tcfh4 0 r/w 3 tcfh3 0 r/w 0 tcfh0 0 r/w 2 tcfh2 0 r/w 1 tcfh1 0 r/w count value bit initial value read/write 7 tcfl7 0 r/w 6 tcfl6 0 r/w 5 tcfl5 0 r/w 4 tcfl4 0 r/w 3 tcfl3 0 r/w 0 tcfl0 0 r/w 2 tcfl2 0 r/w 1 tcfl1 0 r/w count value bit initial value read/write 7 ocrfh7 1 r/w 6 ocrfh6 1 r/w 5 ocrfh5 1 r/w 4 ocrfh4 1 r/w 3 ocrfh3 1 r/w 0 ocrfh0 1 r/w 2 ocrfh2 1 r/w 1 ocrfh1 1 r/w bit initial value read/write 7 ocrfl7 1 r/w 6 ocrfl6 1 r/w 5 ocrfl5 1 r/w 4 ocrfl4 1 r/w 3 ocrfl3 1 r/w 0 ocrfl0 1 r/w 2 ocrfl2 1 r/w 1 ocrfl1 1 r/w 363
tmg?imer mode register g h'bc timer g bit initial value read/write 7 ovfh 0 r/(w) 6 ovfl 0 r/(w) 5 ovie 0 r/w 4 iiegs 0 r/w 3 cclr1 0 r/w 0 cks0 0 r/w 2 cclr0 0 r/w 1 cks1 0 r/w timer overflow flag h 0 [clearing condition] after reading ovfh = 1, cleared by writing 0 to ovfh 1 [setting condition] when the value of tcg overflows from h'ff to h'00 note: only a write of 0 for flag clearing is possible. * ** timer overflow interrupt enable timer overflow flag l 0 [clearing condition] after reading ovfl = 1, cleared by writing 0 to ovfl 1 [setting condition] when the value of tcg overflows from h'ff to h'00 0 tcg overflow interrupt disabled 1 tcg overflow interrupt enabled input capture interrupt edge select 0 interrupts are requested at the rising edge of the input capture signal 1 interrupts are requested at the falling edge of the input capture signal clock select 0 internal clock: internal clock: 0 1 internal clock: internal clock: 10 1 ?64 ?32 ?2 ? /2 w counter clear 0 tcg is not cleared tcg is cleared at the falling edge of the input capture signal 0 1 tcg is cleared at the rising edge of the input capture signal tcg is cleared at both edges of the input capture signal 10 1 364
icrgf?nput capture register gf h'bd timer g icrgr?nput capture register gr h'be timer g bit initial value read/write 7 icrgf7 0 r 6 icrgf6 0 r 5 icrgf5 0 r 4 icrgf4 0 r 3 icrgf3 0 r 0 icrgf0 0 r 2 icrgf2 0 r 1 icrgf1 0 r bit initial value read/write 7 icrgr7 0 r 6 icrgr6 0 r 5 icrgr5 0 r 4 icrgr4 0 r 3 icrgr3 0 r 0 icrgr0 0 r 2 icrgr2 0 r 1 icrgr1 0 r 365
amr?/d mode register h'c4 a/d converter bit initial value read/write 7 cks 0 r/w 6 trge 0 r/w 4 1 3 ch3 0 r/w 0 ch0 0 r/w 2 ch2 0 r/w 1 ch1 0 r/w channel select no channel selected bit 3 0 bit 2 analog input channel ch3 ch2 0 ch1 ch0 bit 1 bit 0 0an 1 1 0 1 1 1 00 external trigger select 0 disables start of a/d conversion by external trigger 1 enables start of a/d conversion by rising or falling edge of external trigger at pin adtrg 5 cks1 0 r/w 4 an 5 an 6 an 7 reserved ** 100 1 10 1 an 0 an 1 an 2 an 3 clock select reserved bit 5 0 conversion period cks1 124/ 0 ?= 2 mhz 62 ? ?= 5 mhz 24.8 ? conversion time note: * operation is not guaranteed if the conversion time is less than 12.4 ?. set bits 5 and 7 for a value of at least 12.4 ?. don? care * bit 7 0 cks 1 62/ 1 31 ? 12.4 ? 0 31/ 1 15.5 ? 1 * ** 366
adrr?/d result register h'c5 a/d converter adsr?/d start register h'c6 a/d converter pdrd?ort data register d h'd2 i/o ports bit initial value read/write 7 adr7 undefined r 6 adr6 undefined r 5 adr5 undefined r 4 adr4 undefined r 3 adr3 undefined r 0 adr0 undefined r 2 adr2 undefined r 1 adr1 undefined r a/d conversion result bit initial value read/write 7 pd 0 r/w 6 pd 0 r/w 5 pd 0 r/w 4 pd 0 r/w 3 pd 0 r/w 0 pd 0 r/w 2 pd 0 r/w 1 pd 0 r/w 76543210 bit initial value read/write 7 adsf 0 r/w 6 1 5 1 4 1 3 1 0 1 2 1 1 1 a/d start flag 0 [read] indicates the completion of a/d conversion 1 [write] stops a/d conversion [read] indicates a/d conversion in progress [write] starts a/d conversion 367
pdre?ort data register e h'd3 i/o ports pdr1?ort data register 1 h'd4 i/o ports pdr2?ort data register 2 h'd5 i/o ports pdr5?ort data register 5 h'd8 i/o ports pdr6?ort data register 6 h'd9 i/o ports bit initial value read/write 7 1 6 1 5 1 4 1 3 pe 0 r/w 0 pe 0 r/w 2 pe 0 r/w 1 pe 0 r/w 3210 bit initial value read/write 7 p1 0 r/w 6 p1 0 r/w 5 p1 0 r/w 4 p1 0 r/w 3 p1 0 r/w 0 p1 0 r/w 2 p1 0 r/w 1 p1 0 r/w 76543 0 21 bit initial value read/write 7 p2 0 r/w 6 p2 0 r/w 5 p2 0 r/w 4 p2 0 r/w 3 p2 0 r/w 0 p2 0 r/w 2 p2 0 r/w 1 p2 0 r/w 76543 0 21 bit initial value read/write 7 p5 0 r/w 6 p5 0 r/w 5 p5 0 r/w 4 p5 0 r/w 3 p5 0 r/w 0 p5 0 r/w 2 p5 0 r/w 1 p5 0 r/w 30 21 4 5 6 7 bit initial value read/write 7 p6 0 r/w 6 p6 0 r/w 5 p6 0 r/w 4 p6 0 r/w 3 p6 0 r/w 0 p6 0 r/w 2 p6 0 r/w 1 p6 0 r/w 30 21 4 5 6 7 368
pdr7?ort data register 7 h'da i/o ports pdr8?ort data register 8 h'db i/o ports pdr9?ort data register 9 h'dc i/o ports pdra?ort data register a h'dd i/o ports pdrb?ort data register b h'de i/o ports bit initial value read/write 7 p7 0 r/w 6 p7 0 r/w 5 p7 0 r/w 4 p7 0 r/w 3 p7 0 r/w 0 p7 0 r/w 2 p7 0 r/w 1 p7 0 r/w 30 21 4 5 6 7 bit initial value read/write 7 p8 0 r/w 6 p8 0 r/w 5 p8 0 r/w 4 p8 0 r/w 3 p8 0 r/w 0 p8 0 r/w 2 p8 0 r/w 1 p8 0 r/w 30 21 4 5 6 7 bit initial value read/write 7 p9 0 r/w 6 p9 0 r/w 5 p9 0 r/w 4 p9 0 r/w 3 p9 0 r/w 0 p9 0 r/w 2 p9 0 r/w 1 p9 0 r/w 30 21 4 5 6 7 bit initial value read/write 7 1 6 1 5 1 4 1 3 pa 0 r/w 0 pa 0 r/w 2 pa 0 r/w 1 pa 0 r/w 30 21 bit initial value read/write 7 pb r 6 pb r 5 pb r 4 pb r 3 pb r 0 pb r 2 pb r 1 pb r 30 21 4 5 6 7 369
pcrd?ort control register d h'e2 i/o ports pcre?ort control register e h'e3 i/o ports pcr1?ort control register 1 h'e4 i/o ports bit initial value read/write 7 pcrd 0 w 6 pcrd 0 w 5 pcrd 0 w 4 pcrd 0 w 3 pcrd 0 w 0 pcrd 0 w 2 pcrd 0 w 1 pcrd 0 w 30 21 4 5 6 7 port d input/output select 0 input pin 1 output pin bit initial value read/write 7 1 6 1 5 1 4 1 3 pcre 0 w 0 pcre 0 w 2 pcre 0 w 1 pcre 0 w 30 21 port e input/output select 0 input pin 1 output pin bit initial value read/write 7 pcr1 0 w 6 pcr1 0 w 5 pcr1 0 w 4 pcr1 0 w 3 pcr1 0 w 0 pcr1 0 w 2 pcr1 0 w 1 pcr1 0 w port 1 input/output select 0 input pin 1 output pin 76543 0 21 370
pcr2?ort control register 2 h'e5 i/o ports pcr5?ort control register 5 h'e8 i/o ports pcr6?ort control register 6 h'e9 i/o ports bit initial value read/write 7 pcr2 0 w 6 pcr2 0 w 5 pcr2 0 w 4 pcr2 0 w 3 pcr2 0 w 0 pcr2 0 w 2 pcr2 0 w 1 pcr2 0 w port 2 input/output select 0 input pin 1 output pin 76543 0 21 bit initial value read/write 7 pcr5 0 w 6 pcr5 0 w 5 pcr5 0 w 4 pcr5 0 w 3 pcr5 0 w 0 pcr5 0 w 2 pcr5 0 w 1 pcr5 0 w port 5 input/output select 0 input pin 1 output pin 76543 0 21 bit initial value read/write 7 pcr6 0 w 6 pcr6 0 w 5 pcr6 0 w 4 pcr6 0 w 3 pcr6 0 w 0 pcr6 0 w 2 pcr6 0 w 1 pcr6 0 w port 6 input/output select 0 input pin 1 output pin 76543 0 21 371
pcr7?ort control register 7 h'ea i/o ports pcr8?ort control register 8 h'eb i/o ports pcr9?ort control register 9 h'ec i/o ports bit initial value read/write 7 pcr7 0 w 6 pcr7 0 w 5 pcr7 0 w 4 pcr7 0 w 3 pcr7 0 w 0 pcr7 0 w 2 pcr7 0 w 1 pcr7 0 w port 7 input/output select 0 input pin 1 output pin 76543 0 21 bit initial value read/write 7 pcr8 0 w 6 pcr8 0 w 5 pcr8 0 w 4 pcr8 0 w 3 pcr8 0 w 0 pcr8 0 w 2 pcr8 0 w 1 pcr8 0 w port 8 input/output select 0 input pin 1 output pin 76543 0 21 bit initial value read/write 7 pcr9 0 w 6 pcr9 0 w 5 pcr9 0 w 4 pcr9 0 w 3 pcr9 0 w 0 pcr9 0 w 2 pcr9 0 w 1 pcr9 0 w port 9 input/output select 0 input pin 1 output pin 76543 0 21 372
pcra?ort control register a h'ed i/o ports syscr1?ystem control register 1 h'f0 system control bit initial value read/write 7 1 6 1 5 1 4 1 3 pcra 0 w 0 pcra 0 w 2 pcra 0 w 1 pcra 0 w 30 21 port a input/output select 0 input pin 1 output pin bit initial value read/write 7 ssby 0 r/w 6 sts2 0 r/w 5 sts1 0 r/w 3 lson 0 r/w 0 1 2 1 1 1 4 sts0 0 r/w software standby 0 when a sleep instruction is executed in active mode, a transition is made to sleep mode. 1 standby timer select 2 to 0 0 wait time = 8,192 states wait time = 16,384 states 0 0 1 wait time = 32,768 states wait time = 65,536 states 10 1 1 * wait time = 131,072 states low speed on flag 0 the cpu operates on the system clock (? 1 the cpu operates on the subclock (? ) sub * when a sleep instruction is executed in subactive mode, a transition is made to subsleep mode. when a sleep instruction is executed in active mode, a transition is made to standby mode or watch mode. when a sleep instruction is executed in subactive mode, a transition is made to watch mode. note: don? care * 373
syscr2?ystem control register 2 h'f1 system control bit initial value read/write 7 1 6 1 5 1 3 dton 0 r/w 0 sa0 0 r/w 2 mson 0 r/w 1 sa1 0 r/w 4 nesel 0 r/w direct transfer on flag 0 when a sleep instruction is executed in active mode, a transition is made to standby mode, watch mode, or sleep mode. 1 when a sleep instruction is executed in subactive mode, a transition is made to watch mode or subsleep mode. when a sleep instruction is executed in active (high-speed) mode, a direct transition is made to active (medium-speed) mode if ssby = 0, mson = 1, and lson = 0, or to subactive mode if ssby = 1, tma3 = 1, and lson = 1. subactive mode clock select 0 /8 ? /4 0 1 1 /2 * w w w noise elimination sampling frequency select 0 sampling rate is ? /16 1 sampling rate is ? /4 osc osc when a sleep instruction is executed in active (medium-speed) mode, a direct transition is made to active (high-speed) mode if ssby = 0, mson = 0, and lson = 0, or to subactive mode if ssby = 1, tma3 = 1, and lson = 1. when a sleep instruction is executed in subactive mode, a direct transition is made to active (high-speed) mode if ssby = 1, tma3 = 1, lson = 0, and mson = 0, or to active (medium-speed) mode if ssby = 1, tma3 = 1, lson = 0, and mson = 1. medium speed on flag 0 operates in active (high-speed) mode 1 operates in active (medium-speed) mode note: don? care * 374
iegr?rq edge select register h'f2 system control bit initial value read/write 7 nmieg 0 r/w 6 1 5 1 4 ieg4 0 r/w 3 ieg3 0 r/w 0 ieg0 0 r/w 2 ieg2 0 r/w 1 ieg1 0 r/w irq edge select 0 falling edge of irq pin input is detected 1 rising edge of irq pin input is detected 0 0 0 irq edge select 0 falling edge of irq pin input is detected 1 rising edge of irq pin input is detected 1 1 1 irq edge select 0 falling edge of irq pin input is detected 1 rising edge of irq pin input is detected 2 2 2 irq edge select 0 falling edge of irq /tmif pin input is detected 1 rising edge of irq /tmif pin input is detected 3 3 3 irq edge select 0 falling edge of irq /adtrg pin input is detected 1 rising edge of irq /adtrg pin input is detected 4 4 4 nmi edge select 0 falling edge of nmi pin input is detected 1 rising edge of nmi pin input is detected 375
ienr1?nterrupt enable register 1 h'f3 system control bit initial value read/write 7 ienta 0 r/w 6 iens1 0 r/w 5 ienwp 0 r/w 4 ien4 0 r/w 3 ien3 0 r/w 0 ien0 0 r/w 2 ien2 0 r/w 1 ien1 0 r/w irq to irq interrupt enable 0 disables interrupt requests from irq to irq 1 4 4 0 0 enables interrupt requests from irq to irq 40 wakeup interrupt enable 0 disables interrupt requests from wkp to wkp 1 70 enables interrupt requests from wkp to wkp 70 sci1 interrupt enable 0 disables sci1 interrupts 1 enables sci1 interrupts timer a interrupt enable 0 disables timer a interrupts 1 enables timer a interrupts 376
ienr2?nterrupt enable register 2 h'f4 system control bit initial value read/write 7 iendt 0 r/w 6 ienad 0 r/w 5 ienmt 0 r/w 4 ientg 0 r/w 3 ientfh 0 r/w 0 1 2 ientfl 0 r/w 1 1 timer fh interrupt enable 0 disables timer fh interrupts 1 enables timer fh interrupts timer fl interrupt enable 0 disables timer fl interrupts 1 enables timer fl interrupts timer g interrupt enable 0 disables timer g interrupts 1 enables timer g interrupts a/d converter interrupt enable 1 0 1 0 disables a/d converter interrupt requests 1 enables a/d converter interrupt requests direct transfer interrupt enable 1 0 disables direct transfer interrupt requests 1 enables direct transfer interrupt requests disables multitone generator interrupts enables multitone generator interrupts multitone generator interrupt enable 377
irr1?nterrupt request register 1 h'f6 system control bit initial value read/write 7 irrta 0 r/w 6 irrs1 0 r/w 5 1 4 irri4 0 r/w 3 irri3 0 r/w 0 irri0 0 r/w 2 irri2 0 r/w 1 irri1 0 r/w timer a interrupt request flag 0 [clearing condition] when irrta = 1, it is cleared by writing 0 1 [setting condition] when the timer a counter overflows from h'ff to h'00 note: only a write of 0 for flag clearing is possible. * ** ** sci1 interrupt request flag 0 [clearing condition] when irrs1 = 1, it is cleared by writing 0 1 [setting condition] when an sci1 transfer is completed irq to irq interrupt request flag 0 [clearing condition] when irrin = 1, it is cleared by writing 0 to irrin. 1 [setting condition] when pin irq is set to interrupt input and the designated signal edge is detected. *** 40 n (n = 4 to 0) 378
irr2?nterrupt request register 2 h'f7 system control bit initial value read/write 7 irrdt 0 r/w 6 irrad 0 r/w 5 irrmt 0 r/w 4 irrtg 0 r/w 3 irrtfh 0 r/w 0 1 2 irrtfl 0 r/w 1 1 direct transfer interrupt request flag 0 [clearing condition] 1 [setting condition] note: only a write of 0 for flag clearing is possible. * ** ** * * when irrdt = 1, it is cleared by writing 0 a sleep instruction is executed when dton = 1 and a direct transfer is made a/d converter interrupt request flag 0 [clearing condition] 1 [setting condition] when irrad = 1, it is cleared by writing 0 when a/d conversion is completed and adsf is reset multitone generator interrupt request flag 0 [clearing condition] 1 [setting condition] when irrmt = 1, it is cleared by writing 0 when the multitone generator has output one-half cycle of data timer g interrupt request flag 0 [clearing condition] 1 [setting condition] when irrtg = 1, it is cleared by writing 0 when pin tmig is set to tmig input and the designated signal edge is detected timer fh interrupt request flag 0 [clearing condition] 1 [setting condition] when irrtfh = 1, it is cleared by writing 0 when counter fh matches output compare register fh in 8-bit mode, or when 16-bit counter f (tcfl, tcfh) matches 16-bit output compare register f (ocrfl, ocrfh) in 16-bit mode timer fl interrupt request flag 0 [clearing condition] 1 [setting condition] when irrtfl = 1, it is cleared by writing 0 when tcfl matches in 8-bit mode 379
iwpr?akeup interrupt request register h'f9 system control bit initial value read/write 7 iwpf7 0 r/w 6 iwpf6 0 r/w 5 iwpf5 0 r/w 4 iwpf4 0 r/w 3 iwpf3 0 r/w 0 iwpf0 0 r/w 2 iwpf2 0 r/w 1 iwpf1 0 r/w note: only a write of 0 for flag clearing is possible. * ** ** wakeup interrupt request flag 0 [clearing condition] when iwpfn = 1, it is cleared by writing 0. 1 [setting condition] when pin wkp is set to interrupt input and a falling signal edge is detected. *** * n (n = 7 to 0) 380
appendix c i/o port block diagrams c.1 port 1 block diagrams figure c-1 (a) port 1 block diagram (pins p1 7 to p1 5 ) sby (low level during reset and in standby mode) pucr1 n pmr1 n pdr1 n pcr1 n internal data bus pdr1: pcr1: pmr1: pucr1: n = 5 to 7 port data register 1 port control register 1 port mode register 1 port pull-up control register 1 v cc v cc irq n ?4 v ss p1 n 381
figure c-1 (b) port 1 block diagram (pin p1 4 ) sby pucr1 4 pdr1 4 pcr1 4 internal data bus pdr1: pcr1: pucr1: port data register 1 port control register 1 port pull-up control register 1 v cc p1 4 v cc v ss 382
figure c-1 (c) port 1 block diagram (pin p1 3 ) sby pucr1 3 pmr1 3 pdr1 3 pcr1 3 internal data bus pdr1: pcr1: pmr1: pucr1: port data register 1 port control register 1 port mode register 1 port pull-up control register 1 tmig timer g module p1 3 v cc v cc v ss 383
figure c-1 (d) port 1 block diagram (pins p1 2 and p1 1 ) sby pucr1 n pmr1 n pdr1 n pcr1 n internal data bus tmofh (p1 ) tmofl (p1 ) pdr1: pcr1: pmr1: pucr1: n = 2, 1 port data register 1 port control register 1 port mode register 1 port pull-up control register 1 timer f module 2 1 v cc p1 n v cc v ss 384
figure c-1 (e) port 1 block diagram (pin p1 0 ) sby pucr1 0 pmr1 0 pdr1 0 pcr1 0 internal data bus tmow pdr1: pcr1: pmr1: pucr1: port data register 1 port control register 1 port mode register 1 port pull-up control register 1 timer a module v cc p1 0 v cc v ss 385
c.2 port 2 block diagrams figure c-2 (a) port 2 block diagram (pin p2 7 ) sby pucr2 7 pmr2 7 pdr2 7 pcr2 7 internal data bus pdr2: pcr2: pmr2: pucr2: port data register 2 port control register 2 port mode register 2 port pull-up control register 2 irq 0 v cc p2 7 v cc v ss 386
figure c-2 (b) port 2 block diagram (pin p2 6 ) sby pucr2 6 pdr2 6 pcr2 6 internal data bus txd te pdr2: pcr2: pucr2: port data register 2 port control register 2 port pull-up control register 2 sci3 module v cc p2 6 v cc v ss 387
figure c-2 (c) port 2 block diagram (pin p2 5 ) sby pucr2 5 pdr2 5 pcr2 5 re rxd pdr2: pcr2: pucr2: port data register 2 port control register 2 port pull-up control register 2 sci3 module v cc p2 5 v cc v ss internal data bus 388
figure c-2 (d) port 2 block diagram (pin p2 4 ) sby pdr2 4 pcr2 4 sckie sckoe scko scki pdr2: pcr2: pucr2: port data register 2 port control register 2 port pull-up control register 2 sci3 module p2 4 v cc v ss internal data bus v cc pucr2 4 389
figure c-2 (e) port 2 block diagram (pin p2 3 ) sby pucr2 3 pmr2 3 pdr2 3 pcr2 3 internal data bus so pdr2: pcr2: pmr2: pucr2: port data register 2 port control register 2 port mode register 2 port pull-up control register 2 sci1 module v cc p2 3 v cc v ss 1 pmr2 3 390
figure c-2 (f) port 2 block diagram (pin p2 2 ) sby pucr2 2 pmr2 2 pdr2 2 pcr2 2 internal data bus pdr2: pcr2: pmr2: pucr2: port data register 2 port control register 2 port mode register 2 port pull-up control register 2 si sci module p2 2 v cc v cc v ss 391
figure c-2 (g) port 2 block diagram (pin p2 1 ) sby pucr2 1 pmr2 1 pdr2 1 pcr2 1 exck scko scki pdr2: pcr2: pmr2: pucr2: port data register 2 port control register 2 port mode register 2 port pull-up control register 2 sci module v cc p2 1 v cc v ss internal data bus 392
figure c-2 (h) port 2 block diagram (pin p2 0 ) sby pucr2 0 pmr2 0 pdr2 0 pcr2 0 internal data bus pdr2: pcr2: pmr2: pucr2: port data register 2 port control register 2 port mode register 2 port pull-up control register 2 irq 4 p2 0 v cc v ss v cc 393
c.3 port 5 block diagram figure c-3 port 5 block diagram sby pucr5 n pmr5 n pdr5 n pcr5 n internal data bus pdr5: pcr5: pmr5: pucr5: n = 0 to 7 port data register 5 port control register 5 port mode register 5 port pull-up control register 5 wkp n v cc p5 n v cc v ss 394
c.4 port 6 block diagram figure c-4 port 6 block diagram sby pucr6 n pdr6 n pcr6 n internal data bus pdr6: pcr6: pucr6: n = 0 to 7 port data register 6 port control register 6 port pull-up control register 6 v cc p6 n v cc v ss 395
c.5 port 7 block diagram figure c-5 port 7 block diagram sby pdr7 n pcr7 n internal data bus pdr7: pcr7: n = 0 to 7 port data register 7 port control register 7 p7 n v cc v ss 396
c.6 port 8 block diagram figure c-6 port 8 block diagram sby pdr8 n pcr8 n internal data bus pdr8: pcr8: n = 0 to 7 port data register 8 port control register 8 p8 n v cc v ss 397
c.7 port 9 block diagram figure c-7 port 9 block diagram sby pdr9 n pcr9 n internal data bus pdr9: pcr9: n = 0 to 7 port data register 9 port control register 9 p9 n v cc v ss 398
c.8 port a block diagram figure c-8 port a block diagram sby pdra n pcra n internal data bus pdra: pcra: n = 0 to 3 port data register a port control register a pa n v cc v ss 399
c.9 port b block diagram figure c-9 port b block diagram dec internal data bus amr to amr v a/d module 03 in pb n n = 0 to 7 400
c.10 port d block diagram figure c-10 port d block diagram sby pdrd n pcrd n internal data bus pdrd: pcrd: n = 0 to 7 port data register d port control register d pd n v cc v ss 401
c.11 port e block diagram figure c-11 port e block diagram sby pdre n pcre n internal data bus pdre: pcre: n = 3 to 0 port data register e port control register e pe n v cc v ss 402
appendix d port states in the different processing states table d-1 port states overview port reset sleep subsleep standby watch subactive active p1 7 to p1 0 high retained retained high retained functional functional impedance impedance * p2 7 to p2 0 high retained retained high retained functional functional impedance impedance * p5 7 to p5 0 high retained retained high retained functional functional impedance impedance * p6 7 to p6 0 high retained retained high retained functional functional impedance impedance * p7 7 to p7 0 high retained retained high retained functional functional impedance impedance p8 7 to p8 0 high retained retained high retained functional functional impedance impedance p9 7 to p9 0 high retained retained high retained functional functional impedance impedance pa 3 to pa 0 high retained retained high retained functional functional impedance impedance pb 7 to pb 0 high high high high high high high impedance impedance impedance impedance impedance impedance impedance pd 7 to pd 0 high retained retained high retained functional functional impedance impedance pe 3 to pe 0 high retained retained high retained functional functional impedance impedance note: * high level output when mos pull-up is in on state. 403
appendix e product line-up products product code mark code package h8/3877n ztat standard hd6473877nh hd6473877nh 100 pin qfp version products (fp-100b) hd6473877nf hd6473877nf 100 pin qfp (fp-100a) hd6473877nx hd6473877nx 100 pin tqfp (tfp-100b) mask rom standard hd6433877nh hd6433877n( *** )h 100 pin qfp version products (fp-100b) hd6433877nf hd6433877n( *** )f 100 pin qfp (fp-100a) hd6433877nx hd6433877n( *** )x 100 pin tqfp (tfp-100b) h8/3876n mask rom standard hd6433876nh hd6433876n( *** )h 100 pin qfp version products (fp-100b) hd6433876nf hd6433876n( *** )f 100 pin qfp (fp-100a) hd6433876nx hd6433876n( *** )x 100 pin tqfp (tfp-100b) h8/3875n mask rom standard hd6433875nh hd6433875n( *** )h 100 pin qfp version products (fp-100b) hd6433875nf hd6433875n( *** )f 100 pin qfp (fp-100a) hd6433875nx hd6433875n( *** )x 100 pin qfp (tfp-100b) note: 1. ( *** ) in mask rom versions is the rom code. 404
appendix f package dimensions dimensional drawings of the h8/3877n series in fp-100b, fp-100a and tfp-100b packages are shown in figure f-1, f-2 and f-3, respectively. unit: mm figure f-1 fp-100b package dimensions note: in case of inconsistencies arising within figures, dimensional drawings listed in the hitachi semiconductor packages manual take precedence and are considered correct. 0.10 16.0 0.3 1.0 0.5 0.2 16.0 0.3 3.05 max 75 51 50 26 1 25 76 100 14 0 ?8 0.5 0.08 m 0.22 0.05 2.70 0.17 0.05 0.12 +0.13 ?.12 1.0 0.20 0.04 0.15 0.04 dimension including the plating thickness base material dimension 405
unit: mm figure f-2 fp-100a package dimensions 406 0.13 m 0 ?10 0.32 0.08 0.17 0.05 3.10 max 1.2 0.2 24.8 0.4 20 80 51 50 31 30 1 100 81 18.8 0.4 14 0.15 0.65 2.70 2.4 0.20 +0.10 ?.20 0.58 0.83 0.30 0.06 0.15 0.04 dimension including the plating thickness base material dimension
unit: mm figure f-3 tfp-100b package dimensions 407 16.0 0.2 14 0.08 0.10 0.5 0.1 16.0 0.2 0.5 0.10 0.10 1.20 max 0.17 0.05 0 ?8 75 51 125 76 100 26 50 m 0.22 0.05 1.0 1.00 1.0 0.20 0.04 0.15 0.04 dimension including the plating thickness base material dimension
h8/3877n series hardware manual publication date: 1st edition, march 1995 2nd edition, march 1997 published by: semiconductor and ic div. hitachi, ltd. edited by: technical documentation center hitachi microcomputer system ltd. copyright hitachi, ltd., 1995. all rights reserved. printed in japan.


▲Up To Search▲   

 
Price & Availability of HD6433876NXXXF

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


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