Download Print this page

Hitachi H8/3062 Hardware Manual

Single-chip microcomputer h8/3062 series; h8/3062b series; h8/3062f-ztat series; h8/3064f-ztat series.
Hide thumbs
   
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Table of Contents
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995

Advertisement

To all our customers
Regarding the change of names mentioned 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 microcomputer, logic, analog
and discrete devices, and memory chips other than DRAMs (flash memory, SRAMs etc.)
Accordingly, although Hitachi, Hitachi, Ltd., Hitachi Semiconductors, and other Hitachi brand
names are mentioned in the document, these names have in fact all been changed to Renesas
Technology Corp. Thank you for your understanding. Except 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: http://www.renesas.com
Renesas Technology Corp.
Customer Support Dept.
April 1, 2003

Advertisement

   Also See for Hitachi H8/3062

   Related Manuals for Hitachi H8/3062

   Summary of Contents for Hitachi H8/3062

  • Page 1

    To all our customers Regarding the change of names mentioned 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 microcomputer, logic, analog and discrete devices, and memory chips other than DRAMs (flash memory, SRAMs etc.)

  • Page 2

    Cautions Keep safety first in your circuit designs! Renesas Technology Corporation puts the maximum effort into making semiconductor products better and more reliable, but there is always the possibility that trouble may occur with them. Trouble with semiconductors may lead to personal injury, fire or property damage.

  • Page 3

    Hitachi Single-Chip Microcomputer H8/3062 Series H8/3062 HD6433062 H8/3061 HD6433061 H8/3060 HD6433060 H8/3062B Series H8/3064B HD6433064B H8/3062B HD6433062B H8/3061B HD6433061B H8/3060B HD6433060B H8/3062F-ZTAT™ HD64F3062, HD64F3062R, HD64F3062B H8/3064F-ZTAT™ HD64F3064B Hardware Manual ADE-602-136D The revision list can be viewed directly by clicking the title page.

  • Page 4

    Cautions 1. Hitachi neither warrants nor grants licenses of any rights of Hitachi’s or any third party’s patent, copyright, trademark, or other intellectual property rights for information contained in this document. Hitachi bears no responsibility for problems that may arise with third party’s rights, including intellectual property rights, in connection with use of the information contained in this document.

  • Page 5

    Note: * F-ZTAT is a trademark of Hitachi, Ltd. Intended Readership: This manual is intended for users undertaking the design of an application system using the H8/3062 Series. Readers using this manual require a basic knowledge of electrical circuits, logic circuits, and microcomputers.

  • Page 6

    C/C++ Compiler, Assembler, Optimizing Linkage Editor User’s Manual ADE-702-247 H8S, H8/300 Series Simulator/Debugger User’s Manual ADE-702-037 Hitachi Embedded Workshop User’s Manual ADE-702-201 H8S, H8/300 Series Hitachi Embedded Workshop, Hitachi Debugging ADE-702-231 Interface User’s Manual Application Note: Manual Title ADE No.

  • Page 7

    There are 11 members of the H8/3062 Series: the H8/3062F-ZTAT, H8/3062F-ZTAT R-mask version, H8/3062F-ZTAT B-mask version, and H8/3064F-ZTAT B-mask version (all with on-chip flash memory), and the H8/3062 mask ROM version, H8/3061 mask ROM version, H8/3060 mask ROM version, H8/3064 mask ROM B-mask version, H8/3062 mask ROM B-mask version, H8/3061 mask ROM B-mask version, and H8/3060 mask ROM B-mask version.

  • Page 8

    H8/3064: see section 18. Mask ROM B-mask versions of H8/3062, H8/3061, and H8/3060: see section Electrical See table 22.1, Comparison of H8/3062 Series Electrical Characteristics, in section 22 charac- teristics (operating frequency) 1 to 20 MHz 2 to 25 MHz...

  • Page 9

    H8/3061 Mask ROM H8/3060 Mask B-Mask Version, ROM Version H8/3060 Mask ROM B-Mask Version Registers See table B.1, Comparison of H8/3062 Series Internal I/O Register Specifications, in appendix B See appendix See appendix See appendix See appendix See appendix Mask ROM B-mask B.1, Address List...

  • Page 11

    Description Section Page Item (See Manual for Details) — The H8/3064 mask ROM B-mask version, H8/3062 mask ROM B-mask version, H8/3061 mask ROM B-mask version, and H8/3060 mask ROM B- mask version are added to the product line-up. 1. Overview 1.3.3 Pin Assignments in...

  • Page 12

    18.13 Notes on Ordering Mask ROM Version Chips 18.14 Notes on Converting the F-ZTAT Application Software to the Mask ROM Versions • 19. H8/3062 Internal 575 to 626 All The title of the section is Voltage Step-Down changed from Flash Version ROM Memory.

  • Page 13

    Section Page Item (See Manual for Details) 19. H8/3062 Internal 19.12 Mask ROM Newly added. Voltage Step-Down (H8/3062 Mask ROM B- Version ROM Mask Version, H8/3061 [H8/3062F-ZTAT B-Mask Mask ROM B-Mask Version, Mask ROM Version, H8/3060 Mask B-Mask Versions of...

  • Page 14

    Description Section Page Item (See Manual for Details) 22. Electrical 701, 702, 22.3.3 AC Table 22.24 Clock Timing, Characteristics 703, 705 Characteristics Table 22.25 Control Signal Timing, Table 22.26 Bus Timing, and Table 22.27 Timing of On-Chip Supporting Modules • A new condition is added.

  • Page 15

    Characteristics • A new condition is added. 740 to 752 22.6 Electrical Newly added Characteristics of H8/3062 Mask ROM B-Mask Version, H8/3061 Mask ROM B-Mask Version, and H8/3060 Mask ROM B-Mask Version 753 to 761 22.7 Operational Timing The section is moved from 22.5.

  • Page 17: Table Of Contents

    Differences between H8/3062F-ZTAT and H8/3062F-ZTAT R-Mask Version. 23 Notes on H8/3064F-ZTAT B-Mask Version, H8/3062F-ZTAT B-Mask Version, H8/3064 Mask ROM B-Mask Version, H8/3062 Mask ROM B-Mask Version, H8/3061 Mask ROM B-Mask Version, and H8/3060 Mask ROM B-Mask Version ..24 1.5.1 Pin Arrangement....................

  • Page 18: Table Of Contents

    Mode 6........................73 3.4.7 Mode 7........................73 Pin Functions in Each Operating Mode................73 Memory Map in Each Operating Mode................74 3.6.1 Comparison of H8/3062 Series Memory Maps............ 74 3.6.2 Reserved Areas..................... 75 Section 4 Exception Handling ..................85 Overview..........................85 4.1.1...

  • Page 19: Table Of Contents

    4.1.3 Exception Vector Table..................86 Reset ..........................88 4.2.1 Overview ......................88 4.2.2 Reset Sequence..................... 88 4.2.3 Interrupts after Reset .................... 91 Interrupts..........................92 Trap Instruction ......................... 92 Stack Status after Exception Handling ................93 Notes on Stack Usage......................94 Section 5 Interrupt Controller ..................

  • Page 20: Table Of Contents

    6.2.2 Access State Control Register (ASTCR).............. 127 6.2.3 Wait Control Registers H and L (WCRH, WCRL)..........128 6.2.4 Bus Release Control Register (BRCR) ..............132 6.2.5 Bus Control Register (BCR) ................133 6.2.6 Chip Select Control Register (CSCR)..............135 6.2.7 Address Control Register (ADRCR)..............

  • Page 21: Table Of Contents

    7.6.1 Overview ......................181 7.6.2 Register Descriptions.................... 182 Port 6..........................184 7.7.1 Overview ......................184 7.7.2 Register Descriptions.................... 185 Port 7..........................188 7.8.1 Overview ......................188 7.8.2 Register Description ..................... 189 Port 8..........................190 7.9.1 Overview ......................190 7.9.2 Register Descriptions.................... 191 7.10 Port 9..........................

  • Page 22: Table Of Contents

    8.4.1 Overview ......................251 8.4.2 Basic Functions ....................251 8.4.3 Synchronization....................259 8.4.4 PWM Mode ......................261 8.4.5 Phase Counting Mode ..................265 8.4.6 16-Bit Timer Output Timing ................267 Interrupts..........................268 8.5.1 Setting of Status Flags..................268 8.5.2 Timing of Clearing of Status Flags ..............270 8.5.3 Interrupt Sources ....................

  • Page 23: Table Of Contents

    9.7.6 Contention between TCOR Write and Input Capture .......... 318 9.7.7 Contention between 8TCNT Byte Write and Increment in 16-Bit Count Mode (Cascaded Connection) ..................319 9.7.8 Contention between Compare Matches A and B ..........320 9.7.9 8TCNT Operation and Internal Clock Source Switchover ........320 Section 10 Programmable Timing Pattern Controller (TPC) ........

  • Page 24: Table Of Contents

    11.2.4 Notes on Register Rewriting ................355 11.3 Operation ........................... 357 11.3.1 Watchdog Timer Operation.................. 357 11.3.2 Interval Timer Operation..................358 11.3.3 Timing of Setting of Overflow Flag (OVF) ............358 11.3.4 Timing of Setting of Watchdog Timer Reset Bit (WRST) ........359 11.4 Interrupts..........................

  • Page 25: Table Of Contents

    13.2.4 Serial Control Register (SCR)................428 13.3 Operation ........................... 429 13.3.1 Overview ......................429 13.3.2 Pin Connections....................429 13.3.3 Data Format......................430 13.3.4 Register Settings....................432 13.3.5 Clock ........................434 13.3.6 Transmitting and Receiving Data................. 436 13.4 Usage Notes ........................443 Section 14 A/D Converter ....................

  • Page 26: Table Of Contents

    17.8.1 Socket Adapters and Memory Map..............513 17.8.2 Notes on Use of PROM Mode................514 17.9 Flash Memory Programming and Erasing Precautions ............. 515 17.10 Mask ROM (H8/3062 Mask ROM Version, H8/3061 Mask ROM Version, H8/3060 Mask ROM Version) Overview................520 17.10.1 Block Diagram ..................... 520 17.11 Notes on Ordering Mask ROM Version Chips..............

  • Page 27: Table Of Contents

    Section 18 H8/3064 Internal Voltage Step-Down Version ROM [H8/3064F-ZTAT B-Mask Version, H8/3064 Mask ROM B-Mask Version] ..........523 18.1 Overview..........................523 18.1.1 Differences from H8/3062F-ZTAT and H8/3062F-ZTAT R-Mask Version..524 18.2 Features..........................525 18.2.1 Block Diagram...................... 526 18.2.2 Pin Configuration ....................527 18.2.3 Register Configuration ..................

  • Page 28: Table Of Contents

    19.10.2 Notes on Use of PROM Mode................617 19.11 Flash Memory Programming and Erasing Precautions ............. 618 19.12 Mask ROM (H8/3062 Mask ROM B-Mask Version, H8/3061 Mask ROM B-Mask Version, H8/3060 Mask ROM B-Mask Version) Overview ..........624 19.12.1 Block Diagram...................... 624 19.13 Notes on Ordering Mask ROM Version Chips..............

  • Page 29: Table Of Contents

    21.6.3 Usage Notes......................648 21.7 System Clock Output Disabling Function ................. 649 Section 22 Electrical Characteristics ................651 22.1 Electrical Characteristics of H8/3062 Mask ROM Version, H8/3061 Mask ROM Version, and H8/3060 Mask ROM Version..................652 22.1.1 Absolute Maximum Ratings................. 652 xiii...

  • Page 30: Table Of Contents

    22.5.4 A/D Conversion Characteristics ................736 22.5.5 D/A Conversion Characteristics ................737 22.5.6 Flash Memory Characteristics................738 22.6 Electrical Characteristics of H8/3062 Mask ROM B-Mask Version, H8/3061 Mask ROM B-Mask Version, and H8/3060 Mask ROM B-Mask Version..740 22.6.1 Absolute Maximum Ratings................. 740 22.6.2 DC Characteristics....................

  • Page 31: Table Of Contents

    Number of States Required for Execution................. 781 Appendix B Internal I/O Registers ................790 Address List (H8/3062F-ZTAT, H8/3062F-ZTAT R-Mask Version, H8/3062 Mask ROM Version, H8/3061 Mask ROM Version, H8/3060 Mask ROM Version) ........791 Address List (H8/3064F-ZTAT B-Mask Version, H8/3064 Mask ROM B-Mask Version)....801...

  • Page 32

    Appendix H Comparison of H8/300H Series Product Specifications ....939 Differences between H8/3067 and H8/3062 Series, H8/3048 Series, H8/3007 and H8/3006, and H8/3002................. 939 Comparison of Pin Functions of 100-Pin Package Products (FP-100B, TFP-100B)..942...

  • Page 33: Table Of Contents

    Figure 2.18 Pin States during Access to On-Chip Supporting Modules........ 65 Figure 3.1 Memory Map of H8/3062F-ZTAT, H8/3062F-ZTAT R-Mask Version, H8/3062F-ZTAT B-Mask Version, H8/3062 Mask ROM Version, and H8/3062 Mask ROM B-Mask Version in Each Operating Mode ...... 76 xvii...

  • Page 34: Table Of Contents

    Access Area Map for Each Operating Mode............137 Figure 6.3 Memory Map in 16-Mbyte Mode (H8/3062F-ZTAT, H8/3062F-ZTAT B-Mask Version, H8/3062 Mask ROM Version, H8/3061 Mask ROM Version, H8/3062 Mask ROM B-Mask Version, H8/3061 Mask ROM B-Mask Version) (1) ..138 Figure 6.3 Memory Map in 16-Mbyte Mode (H8/3060 Mask ROM Version, H8/3060 Mask ROM B-Mask Version) (2)............

  • Page 35: Table Of Contents

    Figure 6.13 Bus Control Signal Timing for 16-Bit, Three-State-Access Area (3) (Word Access)....................152 Figure 6.14 Bus Control Signal Timing for 16-Bit, Two-State-Access Area (1) (Byte Access to Even Address) ................153 Figure 6.15 Bus Control Signal Timing for 16-Bit, Two-State-Access Area (2) (Byte Access to Odd Address) ................

  • Page 36: Table Of Contents

    Figure 8.17 Setup Procedure for Waveform Output by Compare Match (Example) .... 255 Figure 8.18 0 and 1 Output (TOA = 1, TOB = 0)..............256 Figure 8.19 Toggle Output (TOA = 1, TOB = 0) ..............256 Figure 8.20 Output Compare Output Timing ................

  • Page 37: Table Of Contents

    Figure 9.15 CMFB Flag Setting Timing when Input Capture Occurs ........307 Figure 9.16 Timing of OVF Setting ..................307 Figure 9.17 Example of Pulse Output..................312 Figure 9.18 Contention between 8TCNT Write and Clear............ 313 Figure 9.19 Contention between 8TCNT Write and Increment ..........314 Figure 9.20 Contention between TCOR Write and Compare Match ........

  • Page 38: Table Of Contents

    Figure 12.10 Sample Flowchart for Transmitting Multiprocessor Serial Data ....... 402 Figure 12.11 Example of SCI Transmit Operation (8-Bit Data with Multiprocessor Bit and One Stop Bit)...................... 403 Figure 12.12 Sample Flowchart for Receiving Multiprocessor Serial Data......404 Figure 12.13 Example of SCI Receive Operation (8-Bit Data with Multiprocessor Bit and One Stop Bit)......................

  • Page 39: Table Of Contents

    Mode Transition Timing (Example: Boot Mode → User Mode ↔ User Figure 17.18 Program Mode) ....................519 Figure 17.19 ROM Block Diagram (H8/3062 Mask ROM Version) ........520 Figure 17.20 Mask ROM Addresses and Data ................ 521 Figure 18.1 Block Diagram of Flash Memory............... 526 Figure 18.2...

  • Page 40: Table Of Contents

    Mode Transition Timing (Example: Boot Mode → User Mode ↔ User Figure 19.18 Program Mode) ....................623 Figure 19.19 ROM Block Diagram (H8/3062 Mask ROM B-Mask Version) ......624 Figure 19.20 Mask ROM Addresses and Data ................ 625 Figure 20.1 Block Diagram of Clock Pulse Generator............

  • Page 41: Table Of Contents

    Figure 22.8 Sample LED Circuit ................... 700 Figure 22.9 Output Load Circuit.................... 706 Figure 22.10 Darlington Pair Drive Circuit (Example) ............715 Figure 22.11 Sample LED Circuit ................... 715 Figure 22.12 Output Load Circuit.................... 721 Figure 22.13 Darlington Pair Drive Circuit (Example) ............728 Figure 22.14 Sample LED Circuit ...................

  • Page 42: Table Of Contents

    Figure C.9 (d) Port 9 Block Diagram (Pin P9 )................914 Figure C.9 (e) Port 9 Block Diagram (Pin P9 )................915 Figure C.9 (f) Port 9 Block Diagram (Pin P9 )................916 Figure C.10 (a) Port A Block Diagram (Pins PA and PA )............

  • Page 43: Table Of Contents

    Tables Table 1.1 Features ........................ Table 1.2 Comparison of H8/3062 Series Pin Arrangements ..........Table 1.3 Pin Functions......................13 Table 1.4 Pin Assignments in Each Mode (FP-100B or TFP-100B, FP-100A) ....18 Table 1.5 Differences in H8/3062F-ZTAT and H8/3062F-ZTAT R-Mask Version Markings.......................

  • Page 44: Table Of Contents

    Table 7.2 Port 1 Registers ....................169 Table 7.3 Port 2 Registers ....................173 Table 7.4 Input Pull-Up Transistor States (Port 2)............... 175 Table 7.5 Port 3 Registers ....................176 Table 7.6 Port 4 Registers ....................179 Table 7.7 Input Pull-Up Transistor States (Port 4)............... 181 Table 7.8 Port 5 Registers ....................

  • Page 45: Table Of Contents

    Analog Input Pin Ratings ..................463 Table 15.1 D/A Converter Pins ....................469 Table 15.2 D/A Converter Registers ..................469 Table 16.1 H8/3062 Series On-Chip RAM Specifications ............ 475 Table 16.2 System Control Register..................476 Table 17.1 Operating Modes and ROM ................. 479 Table 17.2 Flash Memory Pins....................

  • Page 46: Table Of Contents

    Table 20.3 (2) Clock Timing for On-Chip Mask ROM Versions..........631 Table 20.4 Frequency Division Register ................633 Table 20.5 Comparison of H8/3062 Series Operating Frequency Ranges......634 Table 21.1 Power-Down State and Module Standby Function ..........636 Table 21.2 Control Register....................

  • Page 47: Table Of Contents

    Table 22.5 Clock Timing......................664 Table 22.6 Control Signal Timing..................665 Table 22.7 Bus Timing ......................666 Table 22.8 Timing of On-Chip Supporting Modules ............. 668 Table 22.9 A/D Conversion Characteristics ................670 Table 22.10 D/A Conversion Characteristics ................672 Table 22.11 Absolute Maximum Ratings.................

  • Page 48: Table Of Contents

    Table A.3 Number of States per Cycle.................. 782 Table A.4 Number of Cycles per Instruction ................ 783 Table B.1 Comparison of H8/3062 Series Internal I/O Register Specifications ....790 Table D.1 Port States......................926 Table F.1 H8/3062 Series ..................... 934 Table H.1...

  • Page 49: Section 1 Overview

    (modes 1 to 7) include two single-chip modes and five expanded modes. In addition to its mask ROM versions, the H8/3062 Series has F-ZTAT™* versions with on-chip flash memory that allows programs to be freely rewritten by the user. This version enables users to respond quickly and flexibly to changing application specifications, growing production volumes, and other conditions.

  • Page 50: Table 1.1 Features

    H8/3064F-ZTAT B-mask version 25 MHz 80 ns 560 ns H8/3062F-ZTAT B-mask version H8/3064 mask ROM B-mask version H8/3062 mask ROM B-mask version H8/3061 mask ROM B-mask version H8/3060 mask ROM B-mask version 16-Mbyte address space Instruction features • 8/16/32-bit data transfer, arithmetic, and logic instructions •...

  • Page 51

    Memory H8/3062F-ZTAT 128 kbytes 4 kbytes H8/3062F-ZTAT R-mask version H8/3062F-ZTAT B-mask version H8/3062 (mask ROM version) H8/3062 mask ROM B-mask version H8/3061 (mask ROM version) 96 kbytes 4 kbytes H8/3061 mask ROM B-mask version H8/3060 (mask ROM version) 64 kbytes...

  • Page 52

    Feature Description • 8-bit timer, 8-bit up-counter (external event count capability) 4 channels • Two time constant registers • Two channels can be connected • Programmable Maximum 16-bit pulse output, using 16-bit timer as time base timing pattern • Up to four 4-bit pulse output groups (or one 16-bit group, or two 8-bit groups) controller (TPC) •...

  • Page 53

    Feature Description Operating modes Seven MCU operating modes Address Address Initial Bus Max. Bus Mode Space Pins Width Width Mode 1 1 Mbyte to A 8 bits 16 bits Mode 2 1 Mbyte to A 16 bits 16 bits Mode 3 16 Mbytes to A 8 bits...

  • Page 54

    H8/3062F-ZTAT 5 V operation HD64F3062BF 100-pin QFP (FP-100B) B-mask version HD64F3062BTE 100-pin TQFP (TFP-100B) HD64F3062BFP 100-pin QFP (FP-100A) H8/3062 mask ROM 5 V operation HD6433062BF 100-pin QFP (FP-100B) B-mask version HD6433062BTE 100-pin TQFP (TFP-100B) HD6433062BFP 100-pin QFP (FP-100A) H8/3061 mask ROM...

  • Page 55: Block Diagram

    Notes: *1 Functions as RESO in the on-chip mask ROM versions, and as FWE in the on-chip flash memory versions. *2 The H8/3064F-ZTAT B-mask version, H8/3062F-ZTAT B-mask version, H8/3064 mask ROM B-mask version, H8/3062 mask ROM B-mask version, H8/3061 mask ROM B-mask version, and H8/3060 mask ROM B-mask version have a V pin, and require the connection of an external capacitor.

  • Page 56: Pin Description

    1.3.1 Pin Arrangement The pin arrangement of the H8/3062 Series is shown in figures 1.2 to 1.5. Differences in the H8/3062 Series pin arrangements are shown in table 1.2. The H8/3064F-ZTAT B-mask version, H8/3062F-ZTAT B-mask version, H8/3064 mask ROM B-mask version, H8/3062 mask ROM...

  • Page 57

    Note: * Functions as RESO in the on-chip mask ROM versions, and as FWE in the on-chip flash memory versions. Figure 1.2 Pin Arrangement of H8/3062F-ZTAT, H8/3062F-ZTAT R-Mask Version, H8/3062 Mask ROM Version, H8/3061 Mask ROM Version, and H8/3060 Mask ROM Version (FP-100B or TFP-100B Package, Top View)

  • Page 58

    Note: * Functions as RESO in the on-chip mask ROM versions, and as FWE in the on-chip flash memory versions. Figure 1.3 Pin Arrangement of H8/3062F-ZTAT, H8/3062F-ZTAT R-Mask Version, H8/3062 Mask ROM Version, H8/3061 Mask ROM Version, and H8/3060 Mask ROM Version (FP-100A Package, Top View)

  • Page 59: H8/3062f-ztat B-mask Version, H8/3064 Mask Rom B-mask Version

    Note: * An external capacitor must be connected to the V pin. Figure 1.4 Pin Arrangement of H8/3064F-ZTAT B-Mask Version, H8/3062F-ZTAT B-Mask Version, H8/3064 Mask ROM B-Mask Version, H8/3062 Mask ROM B-Mask Version, H8/3061 Mask ROM B-Mask Version, and H8/3060 Mask ROM B-Mask Version (FP-100B or TFP-100B Package, Top View)

  • Page 60

    Note: * An external capacitor must be connected to the V pin. Figure 1.5 Pin Arrangement of H8/3064F-ZTAT B-Mask Version, H8/3062F-ZTAT B-Mask Version, H8/3064 Mask ROM B-Mask Version, H8/3062 Mask ROM B-Mask Version, H8/3061 Mask ROM B-Mask Version, and H8/3060 Mask ROM B-Mask Version (FP-100A Package, Top View)

  • Page 61: Pin Functions

    Pin Functions Table 1.3 summarizes the pin functions. The H8/3064F-ZTAT B-mask version, H8/3062F-ZTAT B-mask version, H8/3064 mask ROM B-mask version, H8/3062 mask ROM B-mask version, H8/3061 mask ROM B-mask version, and H8/3060 mask ROM B-mask version have a V pin, and require the connection of an external capacitor.

  • Page 62

    Pin No. FP-100B Type Symbol TFP-100B FP-100A I/O Name and Function Operating 75 to 73 77 to 75 Input Mode 2 to mode 0: For setting the operating mode mode, as follows. Inputs at these pins must control not be changed during operation. Operating Mode Setting prohibited Mode 1...

  • Page 63

    Pin No. FP-100B Type Symbol TFP-100B FP-100A I/O Name and Function Data bus to D 34 to 23, 36 to 25, Input/ Data bus: Bidirectional data bus 21 to 18 23 to 20 output 2 to 5, 4 to 7, Output Chip select: Select signals for areas 7 to 0.

  • Page 64

    Pin No. FP-100B Type Symbol TFP-100B FP-100A I/O Name and Function Serial 13, 12 15, 14 Output Transmit data (channels 0, 1): SCI data communi- output cation 15, 14 17, 16 Input Receive data (channels 0, 1): SCI data input interface (SCI) 17, 16...

  • Page 65

    B data direction register (PBDDR). Notes: *1 In the H8/3062F-ZTAT, H8/3062F-ZTAT R-mask version, H8/3062 mask ROM version, H8/3061 mask ROM version, and H8/3060 mask ROM version *2 In the H8/3064F-ZTAT B-mask version, H8/3062F-ZTAT B-mask version, H8/3064 mask ROM B-mask version, H8/3062 mask ROM B-mask version, H8/3061 mask ROM B-mask version, and H8/3060 mask ROM B-mask version.

  • Page 66: Pin Assignments In Each Mode

    1.3.3 Pin Assignments in Each Mode Table 1.4 lists the pin assignments in each mode. Table 1.4 Pin Assignments in Each Mode (FP-100B or TFP-100B, FP-100A) Pin No. Pin Name FP-100B TFP-100B FP-100A Mode 1 Mode 2 Mode 3 Mode 4 Mode 5 Mode 6 Mode 7...

  • Page 67

    Pin No. Pin Name FP-100B TFP-100B FP-100A Mode 1 Mode 2 Mode 3 Mode 4 Mode 5 Mode 6 Mode 7 /WAIT /WAIT /WAIT /WAIT /WAIT...

  • Page 68

    Pin No. Pin Name FP-100B TFP-100B FP-100A Mode 1 Mode 2 Mode 3 Mode 4 Mode 5 Mode 6 Mode 7 /BREQ P6 /BREQ P6 /BREQ P6 /BREQ P6 /BREQ P6 /BACK P6 /BACK P6 /BACK P6 /BACK P6 /BACK P6 φ...

  • Page 69

    ROM version, H8/3061 mask ROM version, and H8/3060 mask ROM version. In the H8/3064F-ZTAT B-mask version, H8/3062F-ZTAT B-mask version, H8/3064 mask ROM B-mask version, H8/3062 mask ROM B-mask version, H8/3061 mask ROM B-mask version, and H8/3060 mask ROM B-mask version, this pin functions as V...

  • Page 70: Notes On H8/3062f-ztat R-mask Version

    Notes on H8/3062F-ZTAT R-Mask Version There are two models with on-chip flash memory in the H8/3062 Series: the H8/3062F-ZTAT and the H8/3062F-ZTAT R-mask version. Points to be noted when using the H8/3062F-ZTAT R-mask version are given below. 1.4.1 Pin Arrangement The H8/3062F-ZTAT R-mask version has the same pin arrangement as the H8/3062F-ZTAT and the H8/3062 mask ROM version, H8/3061 mask ROM version, and H8/3060 mask ROM version.

  • Page 71: Product Type Names And Markings

    Table 1.5 Differences in H8/3062F-ZTAT and H8/3062F-ZTAT R-Mask Version Markings H8/3062F-ZTAT H8/3062F-ZTAT R-Mask Version TFP-100 Product type name HD64F3062TE HD64F3062RTE Sample markings H8/3062 H8/3062 64F3062TE20 64F3062TE20 JAPAN JAPAN “R” is printed above the type name. FP-100B Product type name HD64F3062F...

  • Page 72: H8/3064 Mask Rom B-mask Version, H8/3062 Mask Rom B-mask Version H8/3061 Mask Rom B-mask Version, And H8/3060 Mask Rom B-mask Version

    Mask ROM B-Mask Version, H8/3061 Mask ROM B-Mask Version, and H8/3060 Mask ROM B-Mask Version The H8/3062 Series includes one model with 128-kbyte on-chip flash memory, the H8/3062F- ZTAT B-mask version developed on the basis of the H8/3062F-ZTAT R-mask version, and one model with 256-kbyte large-capacity on-chip flash memory, the H8/3064F-ZTAT B-mask version.

  • Page 73: Pin Arrangement

    H8/3062F-ZTAT and the H8/3062F-ZTAT R-mask version have the same pin arrangement as the H8/3064F-ZTAT B-mask version, H8/3062F-ZTAT B-mask version, H8/3064 mask ROM B-mask version, H8/3062 mask ROM B-mask version, H8/3061 mask ROM B-mask version, and H8/3060 mask ROM B-mask version.

  • Page 74

    H8/3062 mask ROM version, H8/3064F-ZTAT B-mask version, H8/3061 mask ROM version, H8/3064 mask ROM B-mask version, H8/3060 mask ROM version H8/3062 mask ROM B-mask version, H8/3061 mask ROM B-mask version, H8/3060 mask ROM B-mask version (5 V model) Do not connect the V...

  • Page 75: Notes On Changeover To On-chip Mask Rom Versions And On-chip Mask Rom B-mask Versions

    H8/3064F-ZTAT B-mask version to the on-chip mask ROM B-mask version. power supply H8/3062 Series chip ← Land pattern for on-chip mask ROM versions (0 Ω resistance mounted) ← Land pattern for H8/3062F-ZTAT B-mask version (0.1 µF capacitor mounted)

  • Page 76: Setting Oscillation Settling Wait Time

    Setting Oscillation Settling Wait Time When software standby mode is used, after exiting software standby mode a wait period must be provided to allow the clock to stabilize. Select the length of time for which the CPU and peripheral functions are to wait by setting bits STS2 to STS0 in the system control register (SYSCR) and bits DIV1 and DIV0 in the division ratio control register (DIVCR) according to the operating frequency of the chip.

  • Page 77: Section 2 Cpu

    20 MHz (H8/3062F-ZTAT, H8/3062F-ZTAT R-mask version, H8/3062 mask ROM version, H8/3061 mask ROM version, H8/3060 mask ROM version) 25 MHz (H8/3064F-ZTAT B-mask version, H8/3062F-ZTAT B-mask version, H8/3064 mask ROM B-mask version, H8/3062 mask ROM B-mask version, H8/3061 mask ROM B-mask version, and H8/3060 mask ROM B-mask version)

  • Page 78: Differences From H8/300 Cpu

     8/16/32-bit register-register add/subtract: 100 ns@20 MHz (80 ns@25 MHz)  8 × 8-bit register-register multiply: 700 ns@20 MHz (560 ns@25 MHz)  16 ÷ 8-bit register-register divide: 700 ns@20 MHz (560 ns@25 MHz)  16 × 16-bit register-register multiply: 1.1 µs@20 MHz (0.88 µs@25 MHz) ...

  • Page 79: Cpu Operating Modes

    Figure 2.1 CPU Operating Modes Address Space Figure 2.2 shows a simple memory map for the H8/3062 Series. The H8/300H CPU can address a linear address space with a maximum size of 64 kbytes in normal mode, and 16 Mbytes in advanced mode.

  • Page 80: Register Configuration

    Register Configuration 2.4.1 Overview The H8/300H CPU has the internal registers shown in figure 2.3. There are two types of registers: general registers and control registers. General Registers (ERn) (SP) Control Registers (CR) 6 5 4 3 2 1 0 I UI H U N Z V C Legend: Stack pointer...

  • Page 81: General Registers

    2.4.2 General Registers The H8/300H CPU has eight 32-bit general registers. These general registers are all functionally alike and can be used without distinction between data registers and address registers. When a general register is used as a data register, it can be accessed as a 32-bit, 16-bit, or 8-bit register. When the general registers are used as 32-bit registers or as address registers, they are designated by the letters ER (ER0 to ER7).

  • Page 82: Control Registers

    Free area SP (ER7) Stack area Figure 2.5 Stack 2.4.3 Control Registers The control registers are the 24-bit program counter (PC) and the 8-bit condition code register (CCR). Program Counter (PC): This 24-bit counter indicates the address of the next instruction the CPU will execute.

  • Page 83: Initial Cpu Register Values

    Bit 1—Overflow Flag (V): Set to 1 when an arithmetic overflow occurs, and cleared to 0 at other times. Bit 0—Carry Flag (C): Set to 1 when a carry is generated by execution of an operation, and cleared to 0 otherwise. Used by: •...

  • Page 84: Data Formats

    Data Formats The H8/300H CPU can process 1-bit, 4-bit (BCD), 8-bit (byte), 16-bit (word), and 32-bit (longword) data. Bit-manipulation instructions operate on 1-bit data by accessing bit n (n = 0, 1, 2, …, 7) of byte operand data. The DAA and DAS decimal-adjust instructions treat byte data as two digits of 4-bit BCD data.

  • Page 85: Memory Data Formats

    General Data Type Register Data Format Word data Word data Longword data Legend: ERn : General register General register E General register R MSB : Most significant bit LSB : Least significant bit Figure 2.7 General Register Data Formats 2.5.2 Memory Data Formats Figure 2.8 shows the data formats on memory.

  • Page 86: Figure 2.8 Memory Data Formats

    Data Type Address Data Format 1-bit data Address L Byte data Address L Word data Address 2M Address 2M + 1 Address 2N Longword data Address 2N + 1 Address 2N + 2 Address 2N + 3 Figure 2.8 Memory Data Formats When ER7 (SP) is used as an address register to access the stack, the operand size should be word size or longword size.

  • Page 87: Instruction Set

    Notes: *1 POP.W Rn is identical to MOV.W @SP+, Rn. PUSH.W Rn is identical to MOV.W Rn, @–SP. POP.L ERn is identical to MOV.L @SP+, Rn. PUSH.L ERn is identical to MOV.L Rn, @–SP. *2 Not available in the H8/3062 Series. *3 Bcc is a generic branching instruction.

  • Page 88: Instructions And Addressing Modes

    2.6.2 Instructions and Addressing Modes Table 2.2 indicates the instructions available in the H8/300H CPU. Table 2.2 Instructions and Addressing Modes Addressing Modes (d:16, (d:24, @ERn+/ (d:8, (d:16, Function Instruction @ERn ERn) ERn) @–ERn aa:8 aa:16 aa:24 aa:8 — Data —...

  • Page 89: Tables Of Instructions Classified By Function

    2.6.3 Tables of Instructions Classified by Function Tables 2.3 to 2.10 summarize the instructions in each functional category. The operation notation used in these tables is defined next. Operation Notation General register (destination)* General register (source)* General register* General register (32-bit register or address register)* (EAd) Destination operand (EAs)

  • Page 90: Table 2.3 Data Transfer Instructions

    Moves data between two general registers or between a general register and memory, or moves immediate data to a general register. (EAs) → Rd MOVFPE Cannot be used in the H8/3062 Series. Rs → (EAs) MOVTPE Cannot be used in the H8/3062 Series.

  • Page 91: Table 2.4 Arithmetic Operation Instructions

    Table 2.4 Arithmetic Operation Instructions Instruction Size* Function Rd ± Rs → Rd, Rd ± #IMM → Rd ADD,SUB B/W/L Performs addition or subtraction on data in two general registers, or on immediate data and data in a general register. (Immediate byte data cannot be subtracted from data in a general register.

  • Page 92

    Instruction Size* Function Rd ÷ Rs → Rd DIVXU Performs unsigned division on data in two general registers: either 16 bits ÷ 8 bits → 8-bit quotient and 8-bit remainder or 32 bits ÷ 16 bits → 16-bit quotient and 16-bit remainder Rd ÷...

  • Page 93: Table 2.5 Logic Operation Instructions

    Table 2.5 Logic Operation Instructions Instruction Size* Function Rd ∧ Rs → Rd, Rd ∧ #IMM → Rd B/W/L Performs a logical AND operation on a general register and another general register or immediate data. Rd ∨ Rs → Rd, Rd ∨ #IMM → Rd B/W/L Performs a logical OR operation on a general register and another general register or immediate data.

  • Page 94: Table 2.7 Bit Manipulation Instructions

    Table 2.7 Bit Manipulation Instructions Instruction Size* Function 1 → (<bit-No.> of <EAd>) BSET Sets a specified bit in a general register or memory operand to 1. The bit number is specified by 3-bit immediate data or the lower 3 bits of a general register.

  • Page 95

    Instruction Size* Function C ∨ (<bit-No.> of <EAd>) → C ORs the carry flag with a specified bit in a general register or memory operand and stores the result in the carry flag. The bit number is specified by 3-bit immediate data. C ∨...

  • Page 96: Table 2.8 Branching Instructions

    Table 2.8 Branching Instructions Instruction Size Function — Branches to a specified address if address specified condition is met. The branching conditions are listed below. Mnemonic Description Condition BRA (BT) Always (true) Always BRN (BF) Never (false) Never C ∨ Z = 0 High C ∨...

  • Page 97: Table 2.9 System Control Instructions

    Table 2.9 System Control Instructions Instruction Size* Function TRAPA — Starts trap-instruction exception handling. — Returns from an exception-handling routine. SLEEP — Causes a transition to the power-down state. (EAs) → CCR Moves the source operand contents to the condition code register. The condition code register size is one byte, but in transfer from memory, data is read by word access.

  • Page 98: Basic Instruction Formats

    Table 2.10 Block Transfer Instruction Instruction Size Function if R4L ≠ 0 then EEPMOV.B — @ER5+ → @ER6+, R4L – 1 → R4L repeat until R4L = 0 else next; if R4 ≠ 0 then EEPMOV.W — @ER5+ → @ER6+, R4 – 1 → R4 repeat until R4 = 0 else next;...

  • Page 99: Notes On Use Of Bit Manipulation Instructions

    Operation field only NOP, RTS, etc. Operation field and register fields ADD.B Rn, Rm, etc. Operation field, register fields, and effective address extension MOV.B @(d:16, Rn), Rm EA (disp) Operation field, effective address extension, and condition field EA (disp) BRA d:8 Figure 2.9 Instruction Formats 2.6.5 Notes on Use of Bit Manipulation Instructions...

  • Page 100

    Before Execution of BCLR Instruction Input/output Input Input Output Output Output Output Output Output Execution of BCLR Instruction BCLR #0, P4DDR Execute BCLR instruction on DDR After Execution of BCLR Instruction Input/output Output Output Output Output Output Output Output Input Explanation: To execute the BCLR instruction, the CPU begins by reading P4DDR.

  • Page 101: Addressing Modes And Effective Address Calculation

    Addressing Modes and Effective Address Calculation 2.7.1 Addressing Modes The H8/300H CPU supports the eight addressing modes listed in table 2.11. Each instruction uses a subset of these addressing modes. Arithmetic and logic instructions can use the register direct and immediate modes. Data transfer instructions can use all addressing modes except program- counter relative and memory indirect.

  • Page 102: Table 2.12 Absolute Address Access Ranges

    4 Register Indirect with Post-Increment or Pre-Decrement—@ERn+ or @–ERn: • Register indirect with post-increment—@ERn+ The register field of the instruction code specifies an address register (ERn) the lower 24 bits of which contain the address of a memory operand. After the operand is accessed, 1, 2, or 4 is added to the address register contents (32 bits) and the sum is stored in the address register.

  • Page 103: Effective Address Calculation

    extended to 24 bits and added to the 24-bit PC contents to generate a 24-bit branch address. The PC value to which the displacement is added is the address of the first byte of the next instruction, so the possible branching range is –126 to +128 bytes (–63 to +64 words) or –32766 to +32768 bytes (–16383 to +16384 words) from the branch instruction.

  • Page 104: Table 2.13 Effective Address Calculation

    Table 2.13 Effective Address Calculation...

  • Page 107: Processing States

    Processing States 2.8.1 Overview The H8/300H CPU has five processing states: the program execution state, exception-handling state, power-down state, reset state, and bus-released state. The power-down state includes sleep mode, software standby mode, and hardware standby mode. Figure 2.11 classifies the processing states.

  • Page 108: Exception-handling State

    2.8.3 Exception-Handling State The exception-handling state is a transient state that occurs when the CPU alters the normal program flow due to a reset, interrupt, or trap instruction. The CPU fetches a starting address from the exception vector table and branches to that address. In interrupt and trap exception handling the CPU refers to the stack pointer (ER7) and saves the program counter and condition code register.

  • Page 109: Exception Handling Operation

    Bus request End of bus release Program execution state End of bus SLEEP release instruction with SSBY = 0 request Exception handling source Bus-released state Sleep mode End of SLEEP instruction Interrupt source exception with SSBY = 1 handling NMI, IRQ , IRQ , or IRQ interrupt Exception-handling state Software standby mode...

  • Page 110: Bus-released State

    Figure 2.14 shows the stack after the exception-handling sequence. SP–4 SP (ER7) SP–3 SP+1 SP–2 SP+2 SP–1 SP+3 Stack area SP (ER7) SP+4 Even address Before exception After exception Pushed on stack handling starts handling ends Legend: CCR: Condition code register Stack pointer Notes: 1.

  • Page 111: Power-down State

    Figure 2.15 shows the on-chip memory access cycle. Figure 2.16 indicates the pin states. All H8/3062 Series models except the H8/3062F-ZTAT have a function for changing the method of outputting addresses from the address pins. For details see section 6.3.5, Address...

  • Page 112: On-chip Supporting Module Access Timing

    Bus cycle T state T state φ Internal address bus Address Internal read signal Internal data bus Read data (read access) Internal write signal Internal data bus Write data (write access) Figure 2.15 On-Chip Memory Access Cycle φ Address bus Address RD HWR LWR High...

  • Page 113: Access To External Address Space

    Bus cycle T state T state T state φ Address Address bus Internal read signal Read access Internal data bus Read data Internal write signal Write access Internal data bus Write data Figure 2.17 Access Cycle for On-Chip Supporting Modules φ...

  • Page 115: Section 3 Mcu Operating Modes

    3.1.1 Operating Mode Selection The H8/3062 Series has seven operating modes (modes 1 to 7) that are selected by the mode pins to MD ) as indicated in table 3.1. The input at these pins determines the size of the address space and the initial bus mode.

  • Page 116

    64 kbytes. Mode 7 supports a maximum address space of 1 Mbyte. The H8/3062 Series can be used only in modes 1 to 7. The inputs at the mode pins must select one of these seven modes. The inputs at the mode pins must not be changed during operation. Set the reset state before changing the inputs at these pins.

  • Page 117: System Control Register (syscr)

    Note: The versions with on-chip flash memory have a boot mode in which flash memory can be programmed. In boot mode, the MDS2 bit value is the inverse of the level at the MD pin. System Control Register (SYSCR) SYSCR is an 8-bit register that controls the operation of the H8/3062 Series. SSBY STS2 STS1...

  • Page 118

    When operating on an external clock, care is required in the case of the H8/3064F-ZTAT B-mask version, H8/3062F-ZTAT B-mask version, H8/3064 mask ROM B- mask version, H8/3062 mask ROM B-mask version, H8/3061 mask ROM B-mask version, and H8/3060 mask ROM B-mask version.

  • Page 119

    Bit 3—User Bit Enable (UE): Selects whether to use the UI bit in the condition code register as a user bit or an interrupt mask bit. Bit 3 Description UI bit in CCR is used as an interrupt mask bit UI bit in CCR is used as a user bit (Initial value) Bit 2—NMI Edge Select (NMIEG): Selects the valid edge of the NMI input.

  • Page 120: Operating Mode Descriptions

    Operating Mode Descriptions 3.4.1 Mode 1 Ports 1, 2, and 5 function as address pins A to A , permitting access to a maximum 1-Mbyte address space. The initial bus mode after a reset is 8 bits, with 8-bit access to all areas. If at least one area is designated for 16-bit access in ABWCR, the bus mode switches to 16 bits.

  • Page 121: Mode 6

    3.4.6 Mode 6 This mode operates using the on-chip ROM, RAM, and registers. All I/O ports are available. Mode 6 supports a maximum address space of 64 kbytes. 3.4.7 Mode 7 This mode operates using the on-chip ROM, RAM, and registers. All I/O ports are available. Mode 7 supports a 1-Mbyte address space.

  • Page 122: Memory Map In Each Operating Mode

    Comparison of H8/3062 Series Memory Maps In the H8/3062 Series, the address maps vary according to the size of the on-chip ROM and RAM. The internal I/O register space is the same in all models, and the H8/3062F-ZTAT B-mask version and H8/3062 have the same address map.

  • Page 123: Reserved Areas

    3.6.2 Reserved Areas The H8/3062 Series memory map includes reserved areas to which access (reading or writing) is prohibited. Normal operation cannot be guaranteed if the following reserved areas are accessed. Reserved Area in Internal I/O Register Space: The H8/3062 Series internal I/O register space includes a reserved area to which access is prohibited.

  • Page 124: H8/3062f-ztat B-mask Version, H8/3062 Mask Rom Version, And H8/3062 Mask Rom B-mask Version In Each Operating Mode

    H'FFFFFF Note: * External addresses can be accessed by disabling on-chip RAM. Figure 3.1 Memory Map of H8/3062F-ZTAT, H8/3062F-ZTAT R-Mask Version, H8/3062F-ZTAT B-Mask Version, H8/3062 Mask ROM Version, and H8/3062 Mask ROM B-Mask Version in Each Operating Mode...

  • Page 125

    H'FFFFFF Note: * External addresses can be accessed by disabling on-chip RAM. Figure 3.1 Memory Map of H8/3062F-ZTAT, H8/3062F-ZTAT R-Mask Version, H8/3062F-ZTAT B-Mask Version, H8/3062 Mask ROM Version, and H8/3062 Mask ROM B-Mask Version in Each Operating Mode (cont)

  • Page 126: B-mask Version In Each Operating Mode

    Modes 1 and 2 Modes 3 and 4 (1-Mbyte expanded modes with (16-Mbyte expanded modes with on-chip ROM disabled) on-chip ROM disabled) H'00000 H'000000 Vector area Vector area H'000FF H'0000FF H'007FFF H'07FFF Area 0 Area 0 H'1FFFF H'20000 H'1FFFFF Area 1 H'3FFFF H'200000 H'40000...

  • Page 127

    Mode 5 Mode 6 Mode 7 (16-Mbyte expanded mode with (single-chip normal mode) (single-chip advanced mode) on-chip ROM enabled) H'000000 H'0000 H'00000 Vector area Vector area Vector area H'00FF H'000FF H'0000FF On-chip ROM On-chip ROM On-chip ROM (mask ROM) (mask ROM) (mask ROM) H'007FFF H'07FFF...

  • Page 128: Figure 3.3 Memory Map Of H8/3060 Mask Rom Version And H8/3060 Mask Rom B-mask Version In Each Operating Mode

    Modes 1 and 2 Modes 3 and 4 (1-Mbyte expanded modes with (16-Mbyte expanded modes with on-chip ROM disabled) on-chip ROM disabled) H'000000 H'00000 Vector area Vector area H'000FF H'0000FF H'07FFF H'007FFF Area 0 Area 0 H'1FFFF H'20000 H'1FFFFF Area 1 H'3FFFF H'200000 H'40000...

  • Page 129

    Mode 5 Mode 6 Mode 7 (16-Mbyte expanded mode with (single-chip normal mode) (single-chip advanced mode) on-chip ROM enabled) H'000000 H'0000 H'00000 Vector area Vector area Vector area H'0000FF H'000FF H'00FF On-chip ROM On-chip ROM On-chip ROM (mask ROM) (mask ROM) (mask ROM) H'007FFF H'07FFF...

  • Page 130

    Modes 1 and 2 Modes 3 and 4 (1-Mbyte expanded modes with (16-Mbyte expanded modes with on-chip ROM disabled) on-chip ROM disabled) H'00000 H'000000 Vector area Vector area H'000FF H'0000FF H'07FFF H'007FFF Area 0 Area 0 H'1FFFF H'20000 H'1FFFFF Area 1 H'3FFFF H'200000 H'40000...

  • Page 131

    Mode 5 Mode 6 Mode 7 (16-Mbyte expanded mode with (single-chip normal mode) (single-chip advanced mode) on-chip ROM enabled) H'000000 H'00000 H'0000 Vector area Vector area Vector area H'0000FF H'00FF H'000FF On-chip ROM On-chip ROM (flash memory) On-chip ROM (flash memory) (flash memory) H'007FFF H'07FFF...

  • Page 133: Section 4 Exception Handling

    Section 4 Exception Handling Overview 4.1.1 Exception Handling Types and Priority As table 4.1 indicates, exception handling may be caused by a reset, interrupt, or trap instruction. Exception handling is prioritized as shown in table 4.1. If two or more exceptions occur simultaneously, they are accepted and processed in priority order.

  • Page 134: Exception Vector Table

    4.1.3 Exception Vector Table The exception sources are classified as shown in figure 4.1. Different vectors are assigned to different exception sources. Table 4.2 lists the exception sources and their vector addresses. • Reset External interrupts: NMI, IRQ to IRQ Exception •...

  • Page 135: Table 4.2 Exception Vector Table

    Table 4.2 Exception Vector Table Vector Address * Exception Source Vector Number Advanced Mode Normal Mode Reset H'0000 to H'0003 H'0000 to H'0001 Reserved for system use H'0004 to H'0007 H'0002 to H'0003 H'0008 to H'000B H'0004 to H'0005 H'000C to H'000F H'0006 to H'0007 H'0010 to H'0013 H'0008 to H'0009...

  • Page 136: Reset

    Reset 4.2.1 Overview A reset is the highest-priority exception. When the RES pin goes low, all processing halts and the chip enters the reset state. A reset initializes the internal state of the CPU and the registers of the on-chip supporting modules. Reset exception handling begins when the RES pin changes from low to high.

  • Page 137: Figure 4.2 Reset Sequence (modes 1 And 3)

    Figure 4.2 Reset Sequence (Modes 1 and 3)

  • Page 138: Figure 4.3 Reset Sequence (modes 2 And 4)

    Internal Vector fetch processing Prefetch of first program instruction φ Address bus High to D (1), (3) : Address of reset exception handling vector: (1) = H'000000, (3) = H'000002 (2), (4) : Start address (contents of reset exception handling vector address) Start address First instruction of program Note: After a reset, the wait-state controller inserts three wait states in every bus cycle.

  • Page 139: Interrupts After Reset

    Prefetch of Internal first program processing Vector fetch instruction φ Internal address bus Internal read signal Internal write signal High Internal data bus (16 bits wide) (1) : Address of reset exception handling vector (H'0000) (2) : Start address (contents of reset exception handling vector address) (3) : First instruction of program Figure 4.4 Reset Sequence (Mode 6) 4.2.3...

  • Page 140: Interrupts

    Interrupts Interrupt exception handling can be requested by seven external sources (NMI, IRQ to IRQ ), and 27 internal sources in the on-chip supporting modules. Figure 4.5 classifies the interrupt sources and indicates the number of interrupts of each type. The on-chip supporting modules that can request interrupts are the watchdog timer (WDT), 16-bit timer, 8-bit timer, serial communication interface (SCI), and A/D converter.

  • Page 141: Stack Status After Exception Handling

    Stack Status after Exception Handling Figure 4.6 shows the stack after completion of trap instruction exception handling and interrupt exception handling. → SP–4 SP (ER7) SP–3 SP+1 SP–2 SP+2 SP–1 SP+3 SP (ER7) → Stack area SP+4 Even address Before exception handling After exception handling Pushed on stack a.

  • Page 142: Notes On Stack Usage

    Notes on Stack Usage When accessing word data or longword data, the H8/3062 Series regards the lowest address bit as 0. The stack should always be accessed by word access or longword access, and the value of the stack pointer (SP:ER7) should always be kept even.

  • Page 143: Figure 4.7 Operation When Sp Value Is Odd

    H'FFFEFA H'FFFEFB H'FFFEFC H'FFFEFD H'FFFEFE H'FFFEFF TRAPA instruction executed MOV. B R1L, @-ER7 SP set to H'FFFEFF Data saved above SP CCR contents lost Legend: CCR : Condition code register Program counter R1L : General register R1L Stack pointer Note: The diagram illustrates modes 3 to 5. Figure 4.7 Operation when SP Value is Odd...

  • Page 145: Section 5 Interrupt Controller

    Section 5 Interrupt Controller Overview 5.1.1 Features The interrupt controller has the following features: • Interrupt priority registers (IPRs) for setting interrupt priorities Interrupts other than NMI can be assigned to two priority levels on a module-by-module basis in interrupt priority registers A and B (IPRA and IPRB). •...

  • Page 146

    5.1.2 Block Diagram Figure 5.1 shows a block diagram of the interrupt controller. ISCR IPRA, IPRB input IRQ input IRQ input section ISR Interrupt request Priority decision logic Vector number TEIE Interrupt controller SYSCR Legend: ISCR IRQ sense control register IRQ enable register IRQ status register IPRA...

  • Page 147: Pin Configuration

    5.1.3 Pin Configuration Table 5.1 lists the interrupt pins. Table 5.1 Interrupt Pins Name Abbreviation I/O Function Input Nonmaskable interrupt * , rising edge or Nonmaskable interrupt falling edge selectable to IRQ External interrupt request 5 to 0 Input Maskable interrupts, falling edge or level sensing selectable Note: * In the versions with on-chip flash memory, NMI input is sometimes disabled.

  • Page 148: Interrupt Priority Registers A And B (ipra, Iprb)

    SYSCR is initialized to H'09 by a reset and in hardware standby mode. It is not initialized in software standby mode. SSBY STS2 STS1 STS0 NMIEG SSOE RAME Initial value Read/Write RAM enable Software standby output port enable NMI edge select Standby timer Selects the NMI input edge select 2 to 0...

  • Page 149

    Interrupt Priority Register A (IPRA): IPRA is an 8-bit readable/writable register in which interrupt priority levels can be set. IPRA7 IPRA6 IPRA5 IPRA4 IPRA3 IPRA2 IPRA1 IPRA0 Initial value Read/Write Priority level A0 Selects the priority level of 16-bit timer channel 2 interrupt requests...

  • Page 150

    Bit 7—Priority Level A7 (IPRA7): Selects the priority level of IRQ interrupt requests. Bit 7 IPRA7 Description interrupt requests have priority level 0 (low priority) (Initial value) interrupt requests have priority level 1 (high priority) Bit 6—Priority Level A6 (IPRA6): Selects the priority level of IRQ interrupt requests.

  • Page 151

    Bit 2—Priority Level A2 (IPRA2): Selects the priority level of 16-bit timer channel 0 interrupt requests. Bit 2 IPRA2 Description 16-bit timer channel 0 interrupt requests have priority level 0 (low priority) (Initial value) 16-bit timer channel 0 interrupt requests have priority level 1 (high priority) Bit 1—Priority Level A1 (IPRA1): Selects the priority level of 16-bit timer channel 1 interrupt requests.

  • Page 152

    Interrupt Priority Register B (IPRB): IPRB is an 8-bit readable/writable register in which interrupt priority levels can be set. IPRB7 IPRB6 — — IPRB3 IPRB2 — — Initial value Read/Write Reserved bit Priority level B2 Selects the priority level of SCI channel 1 interrupt requests Priority level B3 Selects the priority level of SCI...

  • Page 153: Irq Status Register (isr)

    Bit 6—Priority Level B6 (IPRB6): Selects the priority level of 8-bit timer channel 2, 3 interrupt requests. Bit 6 IPRB6 Description 8-bit timer channel 2 and 3 interrupt requests have priority level 0 (low priority) (Initial value) 8-bit timer channel 2 and 3 interrupt requests have priority level 1 (high priority) Bits 5 and 4—Reserved: This bit can be written and read, but it does not affect interrupt priority.

  • Page 154: Irq Enable Register (ier)

    — — IRQ5F IRQ4F IRQ3F IRQ2F IRQ1F IRQ0F Initial value R/(W) * R/(W) * R/(W) * R/(W) * R/(W) * R/(W) * Read/Write — — Reserved bits IRQ to IRQ flags These bits indicate IRQ to IRQ flag interrupt request status Note: * Only 0 can be written, to clear flags.

  • Page 155: Irq Sense Control Register (iscr)

    Bits 7 and 6—Reserved: These bits can be written and read, but they do not enable or disable interrupts. Bits 5 to 0—IRQ to IRQ Enable (IRQ5E to IRQ0E): These bits enable or disable to IRQ interrupts. Bits 5 to 0 IRQ5E to IRQ0E Description to IRQ interrupts are disabled...

  • Page 156: Interrupt Sources

    Interrupt Sources The interrupt sources include external interrupts (NMI, IRQ to IRQ ) and 27 internal interrupts. 5.3.1 External Interrupts There are seven external interrupts: NMI, and IRQ to IRQ . Of these, NMI, IRQ , IRQ , and can be used to exit software standby mode. NMI: NMI is the highest-priority interrupt and is always accepted, regardless of the states of the I and UI bits in CCR*.

  • Page 157: Internal Interrupts

    Figure 5.3 shows the timing of the setting of the interrupt flags (IRQnF). φ IRQn input pin IRQnF Note: n = 5 to 0 Figure 5.3 Timing of Setting of IRQnF Interrupts IRQ to IRQ have vector numbers 12 to 17. These interrupts are detected regardless of whether the corresponding pin is set for input or output.

  • Page 158: Table 5.3 Interrupt Sources, Vector Addresses, And Priority

    Table 5.3 Interrupt Sources, Vector Addresses, and Priority Vector Address * Vector Interrupt Source Origin Number Advanced Mode Normal Mode Priority External H'001C to H'001F H'000E to H'000F — High pins H'0030 to H'0033 H'0018 to H'0019 IPRA7 H'0034 to H0037 H'001A to H'001B IPRA6 H'0038 to H'003B H'001C to H'001D...

  • Page 159

    Vector Address * Vector Interrupt Source Origin Number Advanced Mode Normal Mode Priority IMIA2 16-bit timer H'0080 to H'0083 H'0040 to H'0041 IPRA0 High (compare match/ channel 2 input capture A2) IMIB2 H'0084 to H'0087 H'0042 to H'0043 (compare match/ input capture B2) OVI2 (overflow 2) H'0088 to H'008B...

  • Page 160

    Vector Address * Vector Interrupt Source Origin Number Advanced Mode Normal Mode Priority ERI0 H'00D0 to H'00D3 H'0068 to H'0069 IPRB3 High (receive error 0) channel 0 RXI0 (receive H'00D4 to H'00D7 H'006A to H'006B data full 0) TXI0 (transmit H'00D8 to H'00DB H'006C to H'006D data empty 0)

  • Page 161: Interrupt Operation

    5.4.1 Interrupt Handling Process The H8/3062 Series handles interrupts differently depending on the setting of the UE bit. When UE = 1, interrupts are controlled by the I bit. When UE = 0, interrupts are controlled by the I and UI bits.

  • Page 162: Figure 5.4 Process Up To Interrupt Acceptance When Ue = 1

    Program execution state Interrupt requested? Pending Priority level 1? TEI1 TEI1 I = 0 Save PC and CCR ← Read vector address Branch to interrupt service routine Figure 5.4 Process Up to Interrupt Acceptance when UE = 1...

  • Page 163

    • If an interrupt condition occurs and the corresponding interrupt enable bit is set to 1, an interrupt request is sent to the interrupt controller. • When the interrupt controller receives one or more interrupt requests, it selects the highest- priority request, following the IPR interrupt priority settings, and holds other requests pending.

  • Page 164: Figure 5.5 Interrupt Masking State Transitions (example)

    ← All interrupts are Only NMI, IRQ , and ← ← 1, UI unmasked IRQ are unmasked Exception handling, ← ← or I 1, UI ← ← Exception handling, ← or UI All interrupts are masked except NMI Figure 5.5 Interrupt Masking State Transitions (Example) Figure 5.6 is a flowchart showing how interrupts are accepted when UE = 0.

  • Page 165: Figure 5.6 Process Up To Interrupt Acceptance When Ue = 0

    Program execution state Interrupt requested? Pending Priority level 1? TEI1 TEI1 I = 0 I = 0 UI = 0 Save PC and CCR ← ← 1, UI Read vector address Branch to interrupt service routine Figure 5.6 Process Up to Interrupt Acceptance when UE = 0...

  • Page 166: Interrupt Exception Handling Sequence

    5.4.2 Interrupt Exception Handling Sequence Figure 5.7 shows the interrupt exception handling sequence in mode 2 when the program code and stack are in an external memory area accessed in two states via a 16-bit bus. Figure 5.7 Interrupt Exception Handling Sequence...

  • Page 167: Interrupt Response Time

    5.4.3 Interrupt Response Time Table 5.5 indicates the interrupt response time from the occurrence of an interrupt request until the first instruction of the interrupt service routine is executed. Table 5.5 Interrupt Response Time External Memory 8-Bit Bus 16-Bit Bus On-Chip Item Memory...

  • Page 168: Usage Notes

    Usage Notes 5.5.1 Contention between Interrupt and Interrupt-Disabling Instruction When an instruction clears an interrupt enable bit to 0 to disable the interrupt, the interrupt is not disabled until after execution of the instruction is completed. If an interrupt occurs while a BCLR, MOV, or other instruction is being executed to clear its interrupt enable bit to 0, at the instant when execution of the instruction ends the interrupt is still enabled, so its interrupt exception handling is carried out.

  • Page 169: Instructions That Inhibit Interrupts

    5.5.2 Instructions that Inhibit Interrupts The LDC, ANDC, ORC, and XORC instructions inhibit interrupts. When an interrupt occurs, after determining the interrupt priority, the interrupt controller requests a CPU interrupt. If the CPU is currently executing one of these interrupt-inhibiting instructions, however, when the instruction is completed the CPU always continues by executing the next instruction.

  • Page 171: Section 6 Bus Controller

    Section 6 Bus Controller Overview The H8/3062 Series has an on-chip bus controller (BSC) that manages the external address space divided into eight areas. The bus specifications, such as bus width and number of access states, can be set independently for each area, enabling multiple memories to be connected easily.

  • Page 172

    6.1.2 Block Diagram Figure 6.1 shows a block diagram of the bus controller. to CS ABWCR ASTCR Area Internal address bus Internal signals CSCR decoder Chip select ADRCR Bus mode control signal control signals Bus size control signal Bus control circuit Access state control signal Wait request signal...

  • Page 173

    6.1.3 Pin Configuration Table 6.1 summarizes the input/output pins of the bus controller. Table 6.1 Bus Controller Pins Name Abbreviation Function to CS Chip select 0 to 7 Output Strobe signals selecting areas 0 to 7 Address strobe Output Strobe signal indicating valid address output on the address bus Read Output...

  • Page 174

    6.1.4 Register Configuration Table 6.2 summarizes the bus controller’s registers. Table 6.2 Bus Controller Registers Address * Name Abbreviation Initial Value H'FF * H'EE020 Bus width control register ABWCR H'EE021 Access state control register ASTCR H'FF H'EE022 Wait control register H WCRH H'FF H'EE023...

  • Page 175: Access State Control Register (astcr)

    Bits 7 to 0—Area 7 to 0 Bus Width Control (ABW7 to ABW0): These bits select 8-bit access or 16-bit access for the corresponding areas. Bits 7 to 0 ABW7 to ABW0 Description Areas 7 to 0 are 16-bit access areas Areas 7 to 0 are 8-bit access areas ABWCR specifies the data bus width of external memory areas.

  • Page 176: Wait Control Registers H And L (wcrh, Wcrl)

    6.2.3 Wait Control Registers H and L (WCRH, WCRL) WCRH and WCRL are 8-bit readable/writable registers that select the number of program wait states for each area. On-chip memory and registers are accessed in a fixed number of states that does not depend on WCRH/WCRL settings.

  • Page 177

    Bits 5 and 4—Area 6 Wait Control 1 and 0 (W61, W60): These bits select the number of program wait states when area 6 in external space is accessed while the AST6 bit in ASTCR is set to 1. Bit 5 Bit 4 Description Program wait not inserted when external space area 6 is accessed...

  • Page 178

    WCRL Initial value Read/Write Bits 7 and 6—Area 3 Wait Control 1 and 0 (W31, W30): These bits select the number of program wait states when area 3 in external space is accessed while the AST3 bit in ASTCR is set to 1.

  • Page 179

    Bits 3 and 2—Area 1 Wait Control 1 and 0 (W11, W10): These bits select the number of program wait states when area 1 in external space is accessed while the AST1 bit in ASTCR is set to 1. Bit 3 Bit 2 Description Program wait not inserted when external space area 1 is accessed...

  • Page 180: Bus Release Control Register (brcr)

    6.2.4 Bus Release Control Register (BRCR) BRCR is an 8-bit readable/writable register that enables address output on bus lines A to A enables or disables release of the bus to an external device. A23E A22E A21E A20E — — — BRLE Modes Initial value...

  • Page 181: Bus Control Register (bcr)

    Bit 5—Address 21 Enable (A21E): Enables PA to be used as the A address output pin. Writing 0 in this bit enables A output from PA . In modes other than 3, 4, and 5, this bit cannot be modified and PA has its ordinary port functions.

  • Page 182

    BCR is initialized to H'C6 by a reset and in hardware standby mode. It is not initialized in software standby mode. Bit 7—Idle Cycle Insertion 1 (ICIS1): Selects whether one idle cycle state is to be inserted between bus cycles in case of consecutive external read cycles for different areas. Bit 7 ICIS1 Description...

  • Page 183: Chip Select Control Register (cscr)

    Bit 0—WAIT Pin Enable (WAITE): Enables or disables wait insertion by means of the WAIT pin. Bit 0 WAITE Description WAIT pin wait input is disabled, and the WAIT pin can be used as an input/output port (Initial value) WAIT pin wait input is enabled 6.2.6 Chip Select Control Register (CSCR) CSCR is an 8-bit readable/writable register that enables or disables output of chip select signals...

  • Page 184: Address Control Register (adrcr)

    6.2.7 Address Control Register (ADRCR) ADRCR is an 8-bit readable/writable register that selects either address update mode 1 or address update mode 2 as the address output method. — — — — — — — ADRCTL Initial value Read/Write — —...

  • Page 185: Operation

    Operation 6.3.1 Area Division The external address space is divided into areas 0 to 7. Each area has a size of 128 kbytes in the 1- Mbyte modes, or 2 Mbytes in the 16-Mbyte modes. Figure 6.2 shows a general view of the memory map.

  • Page 186: Version, H8/3062 Mask Rom Version, H8/3061 Mask Rom Version, H8/3062 Mask Rom B-mask Version, H8/3061 Mask Rom B-mask Version) (1)

    Note: * Area 6 when the RAME bit is cleared. Figure 6.3 Memory Map in 16-Mbyte Mode (H8/3062F-ZTAT, H8/3062F-ZTAT B-Mask Version, H8/3062 Mask ROM Version, H8/3061 Mask ROM Version, H8/3062 Mask ROM B-Mask Version, H8/3061 Mask ROM B-Mask Version) (1)

  • Page 187: Figure 6.3 Memory Map In 16-mbyte Mode (h8/3060 Mask Rom Version H8/3060 Mask Rom B-mask Version) (2)

    H'000000 Area 0 Area 0 2 Mbytes 2 Mbytes H'1FFFFF H'200000 Area 1 Area 1 2 Mbytes 2 Mbytes H'3FFFFF H'400000 Area 2 2 Mbytes Area 2 H'5FFFFF 8 Mbytes H'600000 Area 3 2 Mbytes H'7FFFFF H'800000 Area 4 2 Mbytes H'9FFFFF H'A00000 Area 5...

  • Page 188

    H'000000 Area 0 Area 0 2 Mbytes 2 Mbytes H'1FFFFF H'200000 Area 1 Area 1 2 Mbytes 2 Mbytes H'3FFFFF H'400000 Area 2 2 Mbytes Area 2 H'5FFFFF 8 Mbytes H'600000 Area 3 2 Mbytes H'7FFFFF H'800000 Area 4 2 Mbytes H'9FFFFF H'A00000 Area 5...

  • Page 189: Bus Specifications

    6.3.2 Bus Specifications The external space bus specifications consist of three elements: bus width, number of access states, and number of program wait states. The bus width and number of access states for on-chip memory and registers are fixed, and are not affected by the bus controller.

  • Page 190: Memory Interfaces

    Chip Select Signals to CS For each of areas 0 to 7, the H8/3062 Series can output a chip select signal (CS ) that goes low when the corresponding area is selected in expanded mode. Figure 6.4 shows the output timing of a CSn signal.

  • Page 191: Address Output Method

    The H8/3062F-ZTAT R-mask version, H8/3062F-ZTAT B-mask version, H8/3062 mask ROM version, H8/3061 mask ROM version, H8/3060 mask ROM version, and H8/3064F-ZTAT B- mask version, H8/3064 mask ROM B-mask version, H8/3062 mask ROM B-mask version, H8/3061 mask ROM B-mask version, and H8/3060 mask ROM B-mask version provide a choice...

  • Page 192: Figure 6.6 Example Of Consecutive External Space Accesses In Address Update Mode 2

    H8/3062F-ZTAT is replaced with the H8/3062F-ZTAT R-mask version, H8/3062 mask ROM version, H8/3064F-ZTAT B-mask version, H8/3062F-ZTAT B-mask version, H8/3064 mask ROM B-mask version, or H8/3062 mask ROM B-mask version. However, the following points should be noted.

  • Page 193: Basic Bus Interface

    Basic Bus Interface 6.4.1 Overview The basic bus interface enables direct connection of ROM, SRAM, and so on. The bus specifications can be selected with ABWCR, ASTCR, WCRH, and WCRL (see table 6.3). 6.4.2 Data Size and Data Alignment Data sizes for the CPU and other internal bus masters are byte, word, and longword. The bus controller has a data alignment function, and when accessing external space, controls whether the upper data bus (D to D...

  • Page 194: Valid Strobes

    In byte access, whether the upper or lower data bus is used is determined by whether the address is even or odd. The upper data bus is used for an even address, and the lower data bus for an odd address.

  • Page 195: Memory Areas

    6.4.4 Memory Areas The initial state of each area is basic bus interface, three-state access space. The initial bus width is selected according to the operating mode. Area 0: Area 0 includes on-chip ROM, and in ROM-disabled expansion mode, all of area 0 is external space.

  • Page 196: Basic Bus Control Signal Timing

    6.4.5 Basic Bus Control Signal Timing 8-Bit, Three-State-Access Areas: Figure 6.9 shows the timing of bus control signals for an 8-bit, three-state-access area. The upper data bus (D to D ) is used in accesses to these areas. The LWR pin is always high. Wait states can be inserted. Bus cycle φ...

  • Page 197: Figure 6.10 Bus Control Signal Timing For 8-bit, Two-state-access Area

    8-Bit, Two-State-Access Areas: Figure 6.10 shows the timing of bus control signals for an 8-bit, ) is used in accesses to these areas. The LWR two-state-access area. The upper data bus (D to D pin is always high. Wait states cannot be inserted. Bus cycle φ...

  • Page 198

    16-Bit, Three-State-Access Areas: Figures 6.11 to 6.13 show the timing of bus control signals for a 16-bit, three-state-access area. In these areas, the upper data bus (D to D ) is used in accesses to even addresses and the lower data bus (D to D ) in accesses to odd addresses.

  • Page 199

    Bus cycle φ Address bus Odd external address in area n to D Invalid Read access to D Valid High Write access to D Undetermined data to D Valid Note: n = 7 to 0 Figure 6.12 Bus Control Signal Timing for 16-Bit, Three-State-Access Area (2) (Byte Access to Odd Address)

  • Page 200

    Bus cycle φ Address bus External address in area n Valid to D Read access to D Valid Write access Valid to D to D Valid Note: n = 7 to 0 Figure 6.13 Bus Control Signal Timing for 16-Bit, Three-State-Access Area (3) (Word Access)

  • Page 201

    16-Bit, Two-State-Access Areas: Figures 6.14 to 6.16 show the timing of bus control signals for a 16-bit, two-state-access area. In these areas, the upper data bus (D to D ) is used in accesses to even addresses and the lower data bus (D to D ) in accesses to odd addresses.

  • Page 202

    Bus cycle φ Address bus Odd external address in area n to D Invalid Read access to D Valid High Write access to D Undetermined data to D Valid Note: n = 7 to 0 Figure 6.15 Bus Control Signal Timing for 16-Bit, Two-State-Access Area (2) (Byte Access to Odd Address)

  • Page 203: Wait Control

    (Word Access) 6.4.6 Wait Control When accessing external space, the H8/3062 Series can extend the bus cycle by inserting wait states (T ). There are two ways of inserting wait states: program wait insertion and pin wait insertion using the WAIT pin.

  • Page 204: Figure 6.17 Example Of Wait State Insertion Timing

    Pin Wait Insertion: Setting the WAITE bit in BCR to 1 enables wait insertion by means of the WAIT pin. When external space is accessed in this state, a program wait is first inserted. If the WAIT pin is low at the falling edge of φ in the last T or T state, another T state is inserted.

  • Page 205: Idle Cycle

    6.5.1 Operation When the H8/3062 Series chip accesses external space, it can insert a 1-state idle cycle (T between bus cycles in the following cases: when read accesses between different areas occur consecutively, and when a write cycle occurs immediately after a read cycle. By inserting an idle cycle it is possible, for example, to avoid data collisions between ROM, which has a long output floating time, and high-speed memory, I/O interfaces, and so on.

  • Page 206: Figure 6.19 Example Of Idle Cycle Operation (icis0 = 1)

    Bus cycle A Bus cycle B Bus cycle A Bus cycle B φ φ Address bus Address bus Data bus Data bus Data collision Long buffer-off time (a) Idle cycle not inserted (b) Idle cycle inserted Figure 6.19 Example of Idle Cycle Operation (ICIS0 = 1) Usage Note: When non-insertion of an idle cycle is specified, the rise (negation) of RD and fall (assertion) of CS may occur simultaneously.

  • Page 207: Pin States In Idle Cycle

    6.5.2 Pin States in Idle Cycle Table 6.5 shows the pin states in an idle cycle. Table 6.5 Pin States in Idle Cycle Pins Pin State to A Next cycle address value to D High impedance High High High High High Bus Arbiter The bus controller has a built-in bus arbiter that arbitrates between different bus masters.

  • Page 208

    BREQ signal goes high. While the bus is released to an external bus master, the H8/3062 Series chip holds the address bus, data bus, bus control signals (AS, RD, HWR, and LWR), and chip select signals (CSn: n = 7 to 0) in the high-impedance state, and holds the BACK pin in the low output state.

  • Page 209: Figure 6.21 Example Of External Bus Master Operation

    CPU cycles External bus released CPU cycles φ High-impedance Address Address bus High-impedance Data bus High-impedance High-impedance High High-impedance HWR, LWR BREQ BACK Minimum 3 cycles Figure 6.21 Example of External Bus Master Operation When making a transition to software standby mode, if there is contention with a bus request from an external bus master, the BACK and strobe states may be indefinite when the transition is made.

  • Page 210: Register And Pin Input Timing

    Register and Pin Input Timing 6.7.1 Register Write Timing ABWCR, ASTCR, WCRH, and WCRL Write Timing: Data written to ABWCR, ASTCR, WCRH, and WCRL takes effect starting from the next bus cycle. Figure 6.22 shows the timing when an instruction fetched from area 0 changes area 0 from three-state access to two-state access. φ...

  • Page 211: Breq Pin Input Timing

    φ Address bus BRCR address to PA to A High-impedance Figure 6.24 BRCR Write Timing BREQ Pin Input Timing 6.7.2 After driving the BREQ pin low, hold it low until BACK goes low. If BREQ returns to the high level before BACK goes lows, the bus arbiter may operate incorrectly. To terminate the external-bus-released state, hold the BREQ signal high for at least three states.

  • Page 213: Section 7 I/o Ports

    Overview The H8/3062 Series has 10 input/output ports (ports 1, 2, 3, 4, 5, 6, 8, 9, A, and B) and one input- only port (port 7). Table 7.1 summarizes the port functions. The pins in each port are multiplexed as shown in table 7.1.

  • Page 214

    Single-Chip Expanded Modes Modes Port Description Pins Mode 1 Mode 2 Mode 3 Mode 4 Mode 5 Mode 6 Mode 7 Port 4 • 8-bit I/O to P4 Data input/output (D to D ) and 8-bit generic Generic input/ port to D input/output output...

  • Page 215

    Single-Chip Expanded Modes Modes Port Description Pins Mode 1 Mode 2 Mode 3 Mode 4 Mode 5 Mode 6 Mode 7 Port 8 • 5-bit I/O and IRQ input, CS and CS and IRQ /IRQ output, and generic port input input and generic input/output •...

  • Page 216

    Single-Chip Expanded Modes Modes Port Description Pins Mode 1 Mode 2 Mode 3 Mode 4 Mode 5 Mode 6 Mode 7 Port B • 8-bit I/O TPC output (TP to TP ) and generic input/output port TPC output (TP to TP ), 8-bit timer input and output TPC output (TP ), CS...

  • Page 217: Port

    Port 1 7.2.1 Overview Port 1 is an 8-bit input/output port also used for address output, with the pin configuration shown in figure 7.1. The pin functions differ according to the operating mode. In modes 1 to 4 (expanded modes with on-chip ROM disabled), they are address bus output pins (A to A In mode 5 (expanded modes with on-chip ROM enabled), settings in the port 1 data direction register (P1DDR) can designate pins for address bus output (A...

  • Page 218

    Port 1 Data Direction Register (P1DDR): P1DDR is an 8-bit write-only register that can select input or output for each pin in port 1. P1 DDR P1 DDR P1 DDR P1 DDR P1 DDR P1 DDR P1 DDR P1 DDR Initial value Modes 1 to 4...

  • Page 219

    Port 1 Data Register (P1DR): P1DR is an 8-bit readable/writable register that stores port 1 output data. When port 1 functions as an output port, the value of this register is output. When this register is read, the pin logic level is read for bits for which the P1DDR setting is 0, and the P1DR value is read for bits for which the P1DDR setting is 1.

  • Page 220

    Port 2 7.3.1 Overview Port 2 is an 8-bit input/output port which also has an address output function. It’s pin configuration is shown in figure 7.2. The pin functions differ according to the operating mode. In modes 1 to 4 (expanded modes with on-chip ROM disabled), port 2 consists of address bus output pins (A to A ).

  • Page 221: Register Descriptions

    7.3.2 Register Descriptions Table 7.3 summarizes the registers of port 2. Table 7.3 Port 2 Registers Initial Value Address * Name Abbreviation R/W Modes 1 to 4 Modes 5 to 7 H'EE001 Port 2 data direction register P2DDR H'FF H'00 H'FFFD1 Port 2 data register P2DR...

  • Page 222

    In modes 5 to 7, P2DDR is a write-only register. Its value cannot be read. All bits return 1 when read. P2DDR is initialized to H'FF in modes 1 to 4, and to H'00 in modes 5 to 7, by a reset and in hardware standby mode.

  • Page 223: Table 7.4 Input Pull-up Transistor States (port 2)

    Table 7.4 summarizes the states of the input pull-ups in each mode. Table 7.4 Input Pull-Up Transistor States (Port 2) Hardware Software Mode Reset Standby Mode Standby Mode Other Modes On/off On/off Legend: : The input pull-up transistor is always off. On/off : The input pull-up transistor is on if P2PCR = 1 and P2DDR = 0.

  • Page 224

    Port 3 7.4.1 Overview Port 3 is an 8-bit input/output port which also functions as a data bus. It’s pin configuration is shown in figure 7.3. Port 3 is a data bus in modes 1 to 5 (expanded modes) and a generic input/output port in modes 6 and 7 (single-chip mode).

  • Page 225

    Port 3 Data Direction Register (P3DDR): P3DDR is an 8-bit write-only register that can select input or output for each pin in port 3. P3 DDR P3 DDR P3 DDR P3 DDR P3 DDR P3 DDR P3 DDR P3 DDR Initial value Read/Write Port 3 data direction 7 to 0...

  • Page 226

    Port 4 7.5.1 Overview Port 4 is an 8-bit input/output port which also functions as a data bus. It’s pin configuration is shown in figure 7.4. The pin functions differ depending on the operating mode. In modes 1 to 5 (expanded modes), when the bus width control register (ABWCR) designates areas 0 to 7 all as 8-bit-access areas, the chip operates in 8-bit bus mode and port 4 is a generic input/output port.

  • Page 227

    7.5.2 Register Descriptions Table 7.6 summarizes the registers of port 4. Table 7.6 Port 4 Registers Address * Name Abbreviation Initial Value H'EE003 Port 4 data direction register P4DDR H'00 H'FFFD3 Port 4 data register P4DR H'00 H'EE03E Port 4 input pull-up MOS control P4PCR H'00 register...

  • Page 228

    ABWCR and P4DDR are not initialized in software standby mode. Therefore, if a transition is made to software standby mode while port 4 is functioning as an input/output port and a P4DDR bit is set to 1, the corresponding pin maintains its output state. Port 4 Data Register (P4DR): P4DR is an 8-bit readable/writable register that stores output data for port 4.

  • Page 229

    Table 7.7 Input Pull-Up Transistor States (Port 4) Hardware Software Mode Reset Standby Mode Standby Mode Other Modes 1 to 5 8-bit bus mode On/off On/off 16-bit bus mode 6 and 7 On/off On/off Legend: : The input pull-up transistor is always off. On/off : The input pull-up transistor is on if P4PCR = 1 and P4DDR = 0.

  • Page 230

    7.6.2 Register Descriptions Table 7.8 summarizes the registers of port 5. Table 7.8 Port 5 Registers Initial Value Address * Name Abbreviation R/W Modes 1 to 4 Modes 5 to 7 H'EE004 Port 5 data direction register P5DDR H'FF H'F0 H'FFFD4 Port 5 data register P5DR H'F0...

  • Page 231

    In modes 5 to 7, P5DDR is a write-only register. Its value cannot be read. All bits return 1 when read. P5DDR is initialized to H'FF in modes 1 to 4, and to H'F0 in modes 5 to 7, by a reset and in hardware standby mode.

  • Page 232

    P5PCR is initialized to H'F0 by a reset and in hardware standby mode. In software standby mode it retains its previous setting. Table 7.9 summarizes the states of the input pull-ups in each mode. Table 7.9 Input Pull-Up Transistor States (Port 5) Mode Reset Hardware Standby Mode...

  • Page 233

    Modes 6 and 7 Port 6 pins Modes 1 to 5 (single-chip mode) (expanded modes) φ φ (input) / φ(output) P6 / (input)/ (output) P6 / (output) (input/output) P6 / (output) (input/output) Port 6 P6 / (output) (input/output) P6 / (output) (input/output) BACK...

  • Page 234

    • Modes 1 to 5 (Expanded Modes) functions as the clock output pin (φ) or an input port. P6 is the clock output pin (ø) if the PSTOP bit in MSTRCH is cleared to 0 (initial value), and an input port if this bit is set to 1. function as bus control output pins (LWR, HWR, RD, and AS), regardless of the to P6 settings of bits P6...

  • Page 235: Table 7.11 Port 6 Pin Functions In Modes 1 To 5

    Table 7.11 Port 6 Pin Functions in Modes 1 to 5 Pin Functions and Selection Method /φ Bit PSTOP in MSTCRH selects the pin function. PSTOP φ output Pin function input Functions as LWR regardless of the setting of bit P6 DDR.

  • Page 236

    Pin Functions and Selection Method /WAIT Bit WAITE in BCR and bit P6 DDR select the pin function as follows. WAITE WAIT input Pin function input output Note: * Do not set bit P6 DDR to 1. Port 7 7.8.1 Overview Port 7 is an 8-bit input port that is also used for analog input to the A/D converter and analog output from the D/A converter.

  • Page 237: Register Description

    7.8.2 Register Description Table 7.12 summarizes the port 7 register. Port 7 is an input port, and port 7 has no data direction register. Table 7.12 Port 7 Data Register Address * Name Abbreviation Initial Value H'FFFD6 Port 7 data register P7DR Undetermined Note: * Lower 20 bits of the address in advanced mode...

  • Page 238

    Port 8 7.9.1 Overview Port 8 is a 5-bit input/output port that is also used for CS to CS output, IRQ to IRQ input, and A/D converter ADTRG input. Figure 7.8 shows the pin configuration of port 8. In modes 1 to 5 (expanded modes), port 8 can provide CS to CS output, IRQ to IRQ...

  • Page 239

    7.9.2 Register Descriptions Table 7.13 summarizes the registers of port 8. Table 7.13 Port 8 Registers Initial Value Address * Name Abbreviation Mode 1 to 4 Mode 5 to 7 H'EE007 Port 8 data direction P8DDR H'F0 H'E0 register H'FFFD7 Port 8 data register P8DR H'E0...

  • Page 240

    P8DDR is initialized to H'F0 in modes 1 to 4, and to H'E0 in modes 5 to 7, by a reset and in hardware standby mode. In software standby mode P8DDR retains its previous setting. Therefore, if a transition is made to software standby mode while port 8 is functioning as an input/output port and a P8DDR bit is set to 1, the corresponding pin maintains its output state.

  • Page 241: Table 7.14 Port 8 Pin Functions In Modes 1 To 5

    Table 7.14 Port 8 Pin Functions in Modes 1 to 5 Pin Functions and Selection Method Bit P8 DDR selects the pin function as follows. Pin function input output /IRQ Bit P8 DDR selects the pin function as follows ADTRG Pin function input output...

  • Page 242: Table 7.15 Port 8 Pin Functions In Modes 6 And 7

    Table 7.15 Port 8 Pin Functions in Modes 6 and 7 Pin Functions and Selection Method Bit P8 DDR selects the pin function as follows. Pin function input output /IRQ /ADTRG Bit P8 DDR selects the pin function as follows. Pin function input output...

  • Page 243

    7.10 Port 9 7.10.1 Overview Port 9 is a 6-bit input/output port that is also used for input and output (TxD , TxD , RxD , RxD ) by serial communication interface channels 0 and 1 (SCI0 and SCI1), and for IRQ , SCK and IRQ input.

  • Page 244

    7.10.2 Register Descriptions Table 7.16 summarizes the registers of port 9. Table 7.16 Port 9 Registers Address * Name Abbreviation Initial Value H'EE008 Port 9 data direction register P9DDR H'C0 H'FFFD8 Port 9 data register P9DR H'C0 Note: * Lower 20 bits of the address in advanced mode Port 9 Data Direction Register (P9DDR): P9DDR is an 8-bit write-only register that can select input or output for each pin in port 9.

  • Page 245

    Port 9 Data Register (P9DR): P9DR is an 8-bit readable/writable register that stores output data for port 9. When port 9 functions as an output port, the value of this register is output. When a bit in P9DDR is set to 1, if port 9 is read the value of the corresponding P9DR bit is returned. When a bit in P9DDR is cleared to 0, if port 9 is read the corresponding pin logic level is read.

  • Page 246: Table 7.17 Port 9 Pin Functions

    Table 7.17 Port 9 Pin Functions Pin Functions and Selection Method /SCK /IRQ Bit C/A in SMR of SCI1, bits CKE0 and CKE1 in SCR, and bit P9 select the pin function as follows. CKE1 — CKE0 — — — —...

  • Page 247

    Pin Functions and Selection Method /TxD Bit TE in SCR of SCI1, bit SMIF in SCMR, and bit P9 DDR select the pin function as follows. SMIF — — — output * Pin function input output output TxD Note: * Functions as the TxD output pin, but there are two states: one in which the pin is driven, and another in which the pin is at high- impedance.

  • Page 248: Overview

    7.11 Port A 7.11.1 Overview Port A is an 8-bit input/output port that is also used for output (TP to TP ) from the programmable timing pattern controller (TPC), input and output (TIOCB , TIOCA , TIOCB , TIOCA , TIOCB TIOCA , TCLKD, TCLKC, TCLKB, TCLKA) by the 16-bit timer, clock input (TCLKD, TCLKC, TCLKB, TCLKA) to the 8-bit timer, and address output (A...

  • Page 249: Figure 7.10 Port A Pin Configuration

    Port A pins PA /TP /TIOCB /A PA /TP /TIOCA /A PA /TP /TIOCB /A PA /TP /TIOCA /A Port A PA /TP /TIOCB /TCLKD PA /TP /TIOCA /TCLKC PA /TP /TCLKB PA /TP /TCLKA Pin functions in modes 1, 2, 6 and 7 PA (input/output)/TP (output)/TIOCB (input/output) PA (input/output)/TP (output)/TIOCA (input/output) PA (input/output)/TP (output)/TIOCB (input/output)

  • Page 250

    7.11.2 Register Descriptions Table 7.18 summarizes the registers of port A. Table 7.18 Port A Registers Initial Value Address * Name Modes 1, 2, 5, 6 and 7 Modes 3, 4 H'EE009 Port A data direction PADDR H'00 H'80 register H'FFFD9 Port A data register PADR...

  • Page 251

    mode while port A is functioning as an input/output port and a PADDR bit is set to 1, the corresponding pin maintains its output state. Port A Data Register (PADR): PADR is an 8-bit readable/writable register that stores output data for port A. When port A functions as an output port, the value of this register is output. When a bit in PADDR is set to 1, if port A is read the value of the corresponding PADR bit is returned.

  • Page 252: Table 7.19 Port A Pin Functions (modes 1, 2, 6, And 7)

    Table 7.19 Port A Pin Functions (Modes 1, 2, 6, and 7) Pin Functions and Selection Method Bit PWM2 in TMDR, bits IOB2 to IOB0 in TIOR2, bit NDER7 in NDERA, and bit TIOCB PA 7 DDR select the pin function as follows. 16-bit timer channel 2 settings (1) in table below...

  • Page 253

    Pin Functions and Selection Method Bit PWM1 in TMDR, bits IOB2 to IOB0 in TIOR1, bit NDER5 in NDERA, and bit TIOCB DDR select the pin function as follows. 16-bit timer channel 1 settings (1) in table below (2) in table below —...

  • Page 254: Table 7.20 Port A Pin Functions (modes 3 To 5)

    Table 7.20 Port A Pin Functions (Modes 3 to 5) Pin Functions and Selection Method Modes 3 and 4: Always used as A output. TIOCB Pin function output Mode 5: Bit PWM2 in TMDR, bits IOB2 to IOB0 in TIOR2, bit NDER7 in NDERA, bit A20E in BRCR, and bit PA DDR select the pin function as follows.

  • Page 255

    Pin Functions and Selection Method Bit PWM2 in TMDR, bits IOA2 to IOA0 in TIOR2, bit NDER6 in NDERA, bit A21E in TIOCA BRCR, and bit PA DDR select the pin function as follows. A21E 16-bit timer channel 2 settings (1) in table below (2) in table below —...

  • Page 256

    Pin Functions and Selection Method Bit PWM1 in TMDR, bits IOA2 to IOA0 in TIOR1, bit NDER4 in NDERA, bit A23E in TIOCA BRCR, and bit PA DDR select the pin function as follows. A23E 16-bit timer channel 1 settings (1) in table below (2) in table below —...

  • Page 257: Table 7.21 Port A Pin Functions (modes 1 To 7)

    Table 7.21 Port A Pin Functions (Modes 1 to 7) Pin Functions and Selection Method Bit PWM0 in TMDR, bits IOB2 to IOB0 in TIOR0, bits TPSC2 to TPSC0 in 16TCR2 to TIOCB 16TCR0 of the 16-bit timer, bits CKS2 to CKS0 in 8TCR2 of the 8-bit timer, bit TCLKD NDER3 in NDERA, and bit PA DDR select the pin function as follows.

  • Page 258

    Pin Functions and Selection Method Bit PWM0 in TMDR, bits IOA2 to IOA0 in TIOR0, bits TPSC2 to TPSC0 in 16TCR2 to TIOCA 16TCR0 of the 16-bit timer, bits CKS2 to CKS0 in 8TCR0 of the 8-bit timer, bit TCLKC NDER2 in NDERA, and bit PA DDR select the pin function as follows.

  • Page 259

    Pin Functions and Selection Method Bit MDF in TMDR, bits TPSC2 to TPSC0 in 16TCR2 to 16TCR0 of the 16-bit timer, TCLKB bits CKS2 to CKS0 in 8TCR3 of the 8-bit timer, bit NDER1 in NDERA, and bit DDR select the pin function as follows. NDER1 —...

  • Page 260

    7.12 Port B 7.12.1 Overview Port B is an 8-bit input/output port that is also used for output (TP to TP ) from the programmable timing pattern controller (TPC), input/output (TMIO , TMO , TMIO , TMO ) by the 8-bit timer, and CS to CS output.

  • Page 261: Figure 7.11 Port B Pin Configuration

    Port B pins Port B /TMIO /TMO /TP /TMIO /TP /TMO Pin functions in modes 1 to 5 (input/output)/TP (output) (input/output)/TP (output) (input/output)/TP (output) (input/output)/TP (output) (input/output)/TP (output) /TMIO (input/output) /CS (output) (input/output)/TP (output) /TMO (output) /CS (output) (input/output)/TP (output) /TMIO (input/output) /CS (output) (input/output)/TP...

  • Page 262

    7.12.2 Register Descriptions Table 7.22 summarizes the registers of port B. Table 7.22 Port B Registers Address * Name Abbreviation Initial Value H'EE00A Port B data direction register PBDDR H'00 H'FFFDA Port B data register PBDR H'00 Note: * Lower 20 bits of the address in advanced mode. Port B Data Direction Register (PBDDR): PBDDR is an 8-bit write-only register that can select input or output for each pin in port B.

  • Page 263

    Port B Data Register (PBDR): PBDR is an 8-bit readable/writable register that stores output data for pins port B. When port B functions as an output port, the value of this register is output. When a bit in PBDDR is set to 1, if port B is read the value of the corresponding PBDR bit is returned. When a bit in PBDDR is cleared to 0, if port B is read the corresponding pin logic level is read.

  • Page 264: Table 7.23 Port B Pin Functions (modes 1 To 5)

    Table 7.23 Port B Pin Functions (Modes 1 to 5) Pin Functions and Selection Method Bit NDER15 in NDERB and bit PB DDR select the pin function as follows. NDER15 — Pin function input output output Bit NDER14 in NDERB and bit PB DDR select the pin function as follows.

  • Page 265

    Pin Functions and Selection Method Bits OIS3/2 and OS1/0 in 8TCSR2, bit CS5E in CSCR, bit NDER10 in NDERB, and bit PB DDR select the pin function as follows. OIS3/2 and All 0 Not all 0 OS1/0 CS5E — — —...

  • Page 266: Table 7.24 Port B Pin Functions (modes 6 And 7)

    Table 7.24 Port B Pin Functions (Modes 6 and 7) Pin Functions and Selection Method Bit NDER15 in NDERB and bit PB DDR select the pin function as follows. NDER15 — Pin function input output output Bit NDER14 in NDERB and bit PB DDR select the pin function as follows.

  • Page 267

    Pin Functions and Selection Method Bits OIS3/2 and OS1/0 in 8TCSR2, bit NDER10 in NDERB, and bit PB DDR select the pin function as follows. OIS3/2 and All 0 Not all 0 OS1/0 — NDER10 — — Pin function input output output output...

  • Page 269: Section 8 16-bit Timer

    Section 8 16-Bit Timer Overview The H8/3062 Series has built-in 16-bit timer module with three 16-bit counter channels. 8.1.1 Features 16-bit timer features are listed below. • Capability to process up to six pulse outputs or six pulse inputs • Six general registers (GRs, two per channel) with independently-assignable output compare or input capture functions •...

  • Page 270: Table 8.1 16-bit Timer Functions

    • Output triggering of programmable timing pattern controller (TPC) Compare match/input capture signals from channels 0 to 2 can be used as TPC output triggers. Table 8.1 summarizes the 16-bit timer functions. Table 8.1 16-bit timer Functions Item Channel 0 Channel 1 Channel 2 Internal clocks: φ, φ/2, φ/4, φ/8...

  • Page 271: Block Diagrams

    8.1.2 Block Diagrams 16-bit timer Block Diagram (Overall): Figure 8.1 is a block diagram of the 16-bit timer. IMIA0 to IMIA2 TCLKA to TCLKD Clock selector IMIB0 to IMIB2 φ, φ/2, φ/4, φ/8 OVI0 to OVI2 Control logic TIOCA to TIOCA TIOCB to TIOCB TSTR...

  • Page 272: Figure 8.2 Block Diagram Of Channels 0 And 1

    Block Diagram of Channels 0 and 1: 16-bit timer channels 0 and 1 are functionally identical. Both have the structure shown in figure 8.2. TCLKA to TCLKD TIOCA Clock selector TIOCB φ, φ/2, φ/4, φ/8 Control logic IMIA0 Comparator IMIB0 OVI0 Module data bus Legend:...

  • Page 273: Figure 8.3 Block Diagram Of Channel 2

    Block Diagram of Channel 2: Figure 8.3 is a block diagram of channel 2 TCLKA to TCLKD TIOCA Clock selector TIOCB φ, φ/2, φ/4, φ/8 Control logic IMIA2 Comparator IMIB2 OVI2 Module data bus Legend: 16TCNT2 Timer counter 2 (16 bits) GRA2, GRB2 : General registers A2 and B2 (input capture/output compare registers) (16 bits ×...

  • Page 274

    8.1.3 Pin Configuration Table 8.2 summarizes the 16-bit timer pins. Table 8.2 16-bit timer Pins Abbre- Input/ Channel Name viation Output Function Common Clock input A TCLKA Input External clock A input pin (phase-A input pin in phase counting mode) Clock input B TCLKB Input...

  • Page 275

    8.1.4 Register Configuration Table 8.3 summarizes the 16-bit timer registers. Table 8.3 16-bit timer Registers Abbre- Initial Address * Channel Name viation Value Common H'FFF60 Timer start register TSTR H'F8 H'FFF61 Timer synchro register TSNC H'F8 H'FFF62 Timer mode register TMDR H'98 H'FFF63...

  • Page 276

    Abbre- Initial Address * Channel Name viation Value H'FFF78 Timer control register 2 16TCR2 H'80 H'FFF79 Timer I/O control register 2 TIOR2 H'88 H'FFF7A Timer counter 2H 16TCNT2H R/W H'00 H'FFF7B Timer counter 2L 16TCNT2L R/W H'00 H'FFF7C General register A2H GRA2H H'FF H'FFF7D...

  • Page 277: Timer Synchro Register (tsnc)

    Bit 1—Counter Start 1 (STR1): Starts and stops timer counter 1 (16TCNT1). Bit 1 STR1 Description 16TCNT1 is halted (Initial value) 16TCNT1 is counting Bit 0—Counter Start 0 (STR0): Starts and stops timer counter 0 (16TCNT0). Bit 0 STR0 Description 16TCNT0 is halted (Initial value) 16TCNT0 is counting...

  • Page 278: Timer Mode Register (tmdr)

    Bit 1—Timer Sync 1 (SYNC1): Selects whether channel 1 operates independently or synchronously. Bit 1 SYNC1 Description Channel 1’s timer counter (16TCNT1) operates independently (Initial value) 16TCNT1 is preset and cleared independently of other channels Channel 1 operates synchronously 16TCNT1 can be synchronously preset and cleared Bit 0—Timer Sync 0 (SYNC0): Selects whether channel 0 operates independently or synchronously.

  • Page 279

    Bit 7—Reserved: This bit cannot be modified and is always read as 1. Bit 6—Phase Counting Mode Flag (MDF): Selects whether channel 2 operates normally or in phase counting mode. Bit 6 Description Channel 2 operates normally (Initial value) Channel 2 operates in phase counting mode When MDF is set to 1 to select phase counting mode, 16TCNT2 operates as an up/down-counter and pins TCLKA and TCLKB become counter clock input pins.

  • Page 280

    Bit 2—PWM Mode 2 (PWM2): Selects whether channel 2 operates normally or in PWM mode. Bit 2 PWM2 Description Channel 2 operates normally (Initial value) Channel 2 operates in PWM mode When bit PWM2 is set to 1 to select PWM mode, pin TIOCA becomes a PWM output pin.

  • Page 281: Timer Interrupt Status Register A (tisra)

    8.2.4 Timer Interrupt Status Register A (TISRA) TISRA is an 8-bit readable/writable register that indicates GRA compare match or input capture and enables or disables GRA compare match and input capture interrupt requests. — IMIEA2 IMIEA1 IMIEA0 — IMFA2 IMFA1 IMFA0 Initial value R/(W) *...

  • Page 282

    Bit 5 IMIEA1 Description IMIA1 interrupt requested by IMFA1 flag is disabled (Initial value) IMIA1 interrupt requested by IMFA1 flag is enabled Bit 4—Input Capture/Compare Match Interrupt Enable A0 (IMIEA0): Enables or disables the interrupt requested by the IMFA0 flag when IMFA0 is set to 1. Bit 4 IMIEA0 Description...

  • Page 283: Timer Interrupt Status Register B (tisrb)

    Bit 0—Input Capture/Compare Match Flag A0 (IMFA0): This status flag indicates GRA0 compare match or input capture events. Bit 0 IMFA0 Description [Clearing condition] (Initial value) Read IMFA0 flag when IMFA0 =1, then write 0 in IMFA0 flag [Setting conditions] •...

  • Page 284

    Bit 7—Reserved: This bit cannot be modified and is always read as 1. Bit 6—Input Capture/Compare Match Interrupt Enable B2 (IMIEB2): Enables or disables the interrupt requested by the IMFB2 when IMFB2 flag is set to 1. Bit 6 IMIEB2 Description IMIB2 interrupt requested by IMFB2 flag is disabled (Initial value)

  • Page 285

    Bit 1—Input Capture/Compare Match Flag B1 (IMFB1): This status flag indicates GRB1 compare match or input capture events. Bit 1 IMFB1 Description [Clearing condition] (Initial value) Read IMFB1 flag when IMFB1 =1, then write 0 in IMFB1 flag [Setting conditions] •...

  • Page 286: Timer Interrupt Status Register C (tisrc)

    8.2.6 Timer Interrupt Status Register C (TISRC) TISRC is an 8-bit readable/writable register that indicates 16TCNT overflow or underflow and enables or disables overflow interrupt requests. — OVIE2 OVIE1 OVIE0 — OVF2 OVF1 OVF0 Initial value R/(W) * R/(W) * R/(W) * Read/Write —...

  • Page 287

    Bit 4—Overflow Interrupt Enable 0 (OVIE0): Enables or disables the interrupt requested by the OVF0 when OVF0 flag is set to 1. Bit 4 OVIE0 Description OVI0 interrupt requested by OVF0 flag is disabled (Initial value) OVI0 interrupt requested by OVF0 flag is enabled Bit 3—Reserved: This bit cannot be modified and is always read as 1.

  • Page 288: Timer Counters (16tcnt)

    8.2.7 Timer Counters (16TCNT) 16TCNT is a 16-bit counter. The 16-bit timer has three 16TCNTs, one for each channel. Channel Abbreviation Function 16TCNT0 Up-counter 16TCNT1 16TCNT2 Phase counting mode: up/down-counter Other modes: up-counter Initial value Read/Write Each 16TCNT is a 16-bit readable/writable register that counts pulse inputs from a clock source. The clock source is selected by bits TPSC2 to TPSC0 in 16TCR.

  • Page 289: General Registers (gra, Grb)

    8.2.8 General Registers (GRA, GRB) The general registers are 16-bit registers. The 16-bit timer has 6 general registers, two in each channel. Channel Abbreviation Function GRA0, GRB0 Output compare/input capture register GRA1, GRB1 GRA2, GRB2 Initial value Read/Write A general register is a 16-bit readable/writable register that can function as either an output compare register or an input capture register.

  • Page 290: Timer Control Registers (16tcr)

    8.2.9 Timer Control Registers (16TCR) 16TCR is an 8-bit register. The 16-bit timer has three 16TCRs, one in each channel. Channel Abbreviation Function 16TCR0 16TCR controls the timer counter. The 16TCRs in all channels are functionally identical. When phase counting 16TCR1 mode is selected in channel 2, the settings of bits CKEG1 and CKEG0 and TPSC2 to TPSC0 in 16TCR2 are ignored.

  • Page 291

    Bits 6 and 5—Counter Clear 1 and 0 (CCLR1, CCLR0): These bits select how 16TCNT is cleared. Bit 6 Bit 5 CCLR1 CCLR0 Description 16TCNT is not cleared (Initial value) 16TCNT is cleared by GRA compare match or input capture * 16TCNT is cleared by GRB compare match or input capture * Synchronous clear: 16TCNT is cleared in synchronization with other synchronized timers *...

  • Page 292: Timer I/o Control Register (tior)

    When bit TPSC2 is cleared to 0 an internal clock source is selected, and the timer counts only falling edges. When bit TPSC2 is set to 1 an external clock source is selected, and the timer counts the edges selected by bits CKEG1 and CKEG0. When channel 2 is set to phase counting mode (MDF = 1 in TMDR), the settings of bits TPSC2 to TPSC0 in 16TCR2 are ignored.

  • Page 293

    Bits 6 to 4—I/O Control B2 to B0 (IOB2 to IOB0): These bits select the GRB function. Bit 6 Bit 5 Bit 4 IOB2 IOB1 IOB0 Function GRB is an output No output at compare match (Initial value) compare register 0 output at GRB compare match * 1 output at GRB compare match * Output toggles at GRB compare match...

  • Page 294: Timer Output Level Setting Register C (tolr)

    8.2.11 Timer Output Level Setting Register C (TOLR) TOLR is an 8-bit write-only register that selects the timer output level for channels 0 to 2. — — TOB2 TOA2 TOB1 TOA1 TOB0 TOA0 Initial value Read/Write — — Output level setting A2 to A0, B2 to B0 These bits set the levels of the timer outputs (TIOCA to TIOCA...

  • Page 295

    Bit 3—Output Level Setting B1 (TOB1): Sets the value of timer output TIOCB Bit 3 TOB1 Description TIOCB is 0 (Initial value) TIOCB is 1 Bit 2—Output Level Setting A1 (TOA1): Sets the value of timer output TIOCA Bit 2 TOA1 Description TIOCA...

  • Page 296: Cpu Interface

    CPU Interface 8.3.1 16-Bit Accessible Registers The timer counters (16TCNTs), general registers A and B (GRAs and GRBs) are 16-bit registers, and are linked to the CPU by an internal 16-bit data bus. These registers can be written or read a word at a time, or a byte at a time.

  • Page 297: Figure 8.6 Access To Timer Counter H (cpu Writes To 16tcnth, Upper Byte)

    Internal data bus Module Bus interface data bus 16TCNTH 16TCNTL Figure 8.6 Access to Timer Counter H (CPU Writes to 16TCNTH, Upper Byte) Internal data bus Module Bus interface data bus 16TCNTH 16TCNTL Figure 8.7 Access to Timer Counter L (CPU Writes to 16TCNTL, Lower Byte) Internal data bus Module Bus interface...

  • Page 298: Bit Accessible Registers

    Internal data bus Module Bus interface data bus 16TCNTH 16TCNTL Figure 8.9 Access to Timer Counter L (CPU Reads 16TCNTL, Lower Byte) 8.3.2 8-Bit Accessible Registers The registers other than the timer counters and general registers are 8-bit registers. These registers are linked to the CPU by an internal 8-bit data bus.

  • Page 299

    Operation 8.4.1 Overview A summary of operations in the various modes is given below. Normal Operation: Each channel has a timer counter (16TCNT) and general registers. The 16TCNT counts up, and can operate as a free-running counter, periodic counter, or external event counter.

  • Page 300: Figure 8.12 Counter Setup Procedure (example)

    Counter setup Select counter clock Count operation Free-running counting Periodic counting Select counter clear source Select output compare register function Set period Start counter Start counter Periodic counter Free-running counter Figure 8.12 Counter Setup Procedure (Example) 1. Set bits TPSC2 to TPSC0 in 16TCR to select the counter clock source. If an external clock source is selected, set bits CKEG1 and CKEG0 in 16TCR to select the desired edge(s) of the external clock signal.

  • Page 301: Figure 8.13 Free-running Counter Operation

    • Free-running and periodic counter operation A reset leaves the counters (16TCNTs) in 16-bit timer channels 0 to 2 all set as free-running counters. A free-running counter starts counting up when the corresponding bit in TSTR is set to 1. When the count overflows from H'FFFF to H'0000, the OVF flag is set to 1 in TISRC. After the overflow, the counter continues counting up from H'0000.

  • Page 302: Figure 8.15 Count Timing For Internal Clock Sources

    • 16TCNT count timing  Internal clock source Bits TPSC2 to TPSC0 in 16TCR select the system clock (φ) or one of three internal clock sources obtained by prescaling the system clock (φ/2, φ/4, φ/8). Figure 8.15 shows the timing. φ...

  • Page 303: Figure 8.17 Setup Procedure For Waveform Output By Compare Match (example)

    Waveform Output by Compare Match: In 16-bit timer channels 0, 1 compare match A or B can cause the output at the TIOCA or TIOCB pin to go to 0, go to 1, or toggle. In channel 2 the output can only go to 0 or go to 1.

  • Page 304: Figure 8.18 0 And 1 Output (toa = 1, Tob = 0)

    • Examples of waveform output Figure 8.18 shows examples of 0 and 1 output. 16TCNT operates as a free-running counter, 0 output is selected for compare match A, and 1 output is selected for compare match B. When the pin is already at the selected output level, the pin level does not change. 16TCNT value H'FFFF H'0000...

  • Page 305: Figure 8.20 Output Compare Output Timing

    • Output compare output timing The compare match signal is generated in the last state in which 16TCNT and the general register match (when 16TCNT changes from the matching value to the next value). When the compare match signal is generated, the output value selected in TIOR is output at the output compare pin (TIOCA or TIOCB).

  • Page 306: Figure 8.21 Setup Procedure For Input Capture (example)

    • Sample setup procedure for input capture Figure 8.21 shows a sample procedure for setting up input capture. Input selection Set TIOR to select the input capture function of a general register and the rising edge, falling edge, or both edges of the input capture signal. Clear the DDR bit to 0 before making these TIOR settings.

  • Page 307: Synchronization

    • Input capture signal timing Input capture on the rising edge, falling edge, or both edges can be selected by settings in TIOR. Figure 8.23 shows the timing when the rising edge is selected. The pulse width of the input capture signal must be at least 1.5 system clocks for single-edge capture, and 2.5 system clocks for capture of both edges.

  • Page 308: Figure 8.24 Setup Procedure For Synchronization (example)

    Setup for synchronization Select synchronization Synchronous preset Synchronous clear Clearing synchronized to this channel? Write to 16TCNT Select counter clear source Select counter clear source Start counter Start counter Synchronous preset Counter clear Synchronous clear Set the SYNC bits to 1 in TSNC for the channels to be synchronized. When a value is written in 16TCNT in one of the synchronized channels, the same value is simultaneously written in 16TCNT in the other channels.

  • Page 309: Pwm Mode

    Value of 16TCNT0 to 16TCNT2 Cleared by compare match with GRB0 GRB0 GRB1 GRA0 GRB2 GRA1 GRA2 H'0000 TIOCA TIOCA TIOCA Figure 8.25 Synchronization (Example) 8.4.4 PWM Mode In PWM mode GRA and GRB are paired and a PWM waveform is output from the TIOCA pin. GRA specifies the time at which the PWM output changes to 1.

  • Page 310: Figure 8.26 Setup Procedure For Pwm Mode (example)

    Sample Setup Procedure for PWM Mode: Figure 8.26 shows a sample procedure for setting up PWM mode. PWM mode Set bits TPSC2 to TPSC0 in 16TCR to select the counter clock source. If an external clock source is selected, set bits CKEG1 and CKEG0 in 16TCR to Select counter clock select the desired edge(s) of the...

  • Page 311: Figure 8.27 Pwm Mode (example 1)

    Examples of PWM Mode: Figure 8.27 shows examples of operation in PWM mode. In PWM mode TIOCA becomes an output pin. The output goes to 1 at compare match with GRA, and to 0 at compare match with GRB. In the examples shown, 16TCNT is cleared by compare match with GRA or GRB. Synchronized operation and free-running counting are also possible.

  • Page 312: Figure 8.28 Pwm Mode (example 2)

    Figure 8.28 shows examples of the output of PWM waveforms with duty cycles of 0% and 100%. If the counter is cleared by compare match with GRB, and GRA is set to a higher value than GRB, the duty cycle is 0%. If the counter is cleared by compare match with GRA, and GRB is set to a higher value than GRA, the duty cycle is 100%.

  • Page 313: Phase Counting Mode

    8.4.5 Phase Counting Mode In phase counting mode the phase difference between two external clock inputs (at the TCLKA and TCLKB pins) is detected, and 16TCNT2 counts up or down accordingly. In phase counting mode, the TCLKA and TCLKB pins automatically function as external clock input pins and 16TCNT2 becomes an up/down-counter, regardless of the settings of bits TPSC2 to TPSC0, CKEG1, and CKEG0 in 16TCR2.

  • Page 314: Figure 8.30 Operation In Phase Counting Mode (example)

    Example of Phase Counting Mode: Figure 8.30 shows an example of operations in phase counting mode. Table 8.5 lists the up-counting and down-counting conditions for 16TCNT2. In phase counting mode both the rising and falling edges of TCLKA and TCLKB are counted. The phase difference between TCLKA and TCLKB must be at least 1.5 states, the phase overlap must also be at least 1.5 states, and the pulse width must be at least 2.5 states.

  • Page 315: Bit Timer Output Timing

    8.4.6 16-Bit Timer Output Timing The initial value of 16-bit timer output when a timer count operation begins can be specified arbitrarily by making a setting in TOLR. Figure 8.32 shows the timing for setting the initial value with TOLR. Only write to TOLR when the corresponding bit in TSTR is cleared to 0.

  • Page 316

    Interrupts The 16-bit timer has two types of interrupts: input capture/compare match interrupts, and overflow interrupts. 8.5.1 Setting of Status Flags Timing of Setting of IMFA and IMFB at Compare Match: IMFA and IMFB are set to 1 by a compare match signal generated when 16TCNT matches a general register (GR).

  • Page 317: Figure 8.34 Timing Of Setting Of Imfa And Imfb By Input Capture

    Timing of Setting of IMFA and IMFB by Input Capture: IMFA and IMFB are set to 1 by an input capture signal. The 16TCNT contents are simultaneously transferred to the corresponding general register. Figure 8.34 shows the timing. φ Input capture signal 16TCNT Figure 8.34 Timing of Setting of IMFA and IMFB by Input Capture...

  • Page 318: Timing Of Clearing Of Status Flags

    Timing of Setting of Overflow Flag (OVF): OVF is set to 1 when 16TCNT overflows from H'FFFF to H'0000 or underflows from H'0000 to H'FFFF. Figure 8.35 shows the timing. φ 16TCNT Overflow signal Figure 8.35 Timing of Setting of OVF 8.5.2 Timing of Clearing of Status Flags If the CPU reads a status flag while it is set to 1, then writes 0 in the status flag, the status flag is...

  • Page 319

    8.5.3 Interrupt Sources Each 16-bit timer channel can generate a compare match/input capture A interrupt, a compare match/input capture B interrupt, and an overflow interrupt. In total there are nine interrupt sources of three kinds, all independently vectored. An interrupt is requested when the interrupt request flag are set to 1.

  • Page 320

    Usage Notes This section describes contention and other matters requiring special attention during 16-bit timer operations. Contention between 16TCNT Write and Clear: If a counter clear signal occurs in the T state of a 16TCNT write cycle, clearing of the counter takes priority and the write is not performed. See figure 8.37.

  • Page 321: Figure 8.38 Contention Between 16tcnt Word Write And Increment

    Contention between 16TCNT Word Write and Increment: If an increment pulse occurs in the state of a 16TCNT word write cycle, writing takes priority and 16TCNT is not incremented. Figure 8.38 shows the timing in this case. 16TCNT word write cycle φ...

  • Page 322: Figure 8.39 Contention Between 16tcnt Byte Write And Increment

    Contention between 16TCNT Byte Write and Increment: If an increment pulse occurs in the or T state of a 16TCNT byte write cycle, writing takes priority and 16TCNT is not incremented. The byte data for which a write was not performed is not incremented, and retains its pre-write value.

  • Page 323: Figure 8.40 Contention Between General Register Write And Compare Match

    Contention between General Register Write and Compare Match: If a compare match occurs in the T state of a general register write cycle, writing takes priority and the compare match signal is inhibited. See figure 8.40. General register write cycle φ...

  • Page 324: Figure 8.41 Contention Between 16tcnt Write And Overflow

    Contention between 16TCNT Write and Overflow or Underflow: If an overflow occurs in the state of a 16TCNT write cycle, writing takes priority and the counter is not incremented. OVF is set to 1. The same holds for underflow. See figure 8.41. 16TCNT write cycle φ...

  • Page 325: Figure 8.42 Contention Between General Register Read And Input Capture

    Contention between General Register Read and Input Capture: If an input capture signal occurs during the T state of a general register read cycle, the value before input capture is read. See figure 8.42. General register read cycle φ Address bus GR address Internal read signal Input capture signal...

  • Page 326

    Contention between Counter Clearing by Input Capture and Counter Increment: If an input capture signal and counter increment signal occur simultaneously, the counter is cleared according to the input capture signal. The counter is not incremented by the increment signal. The value before the counter is cleared is transferred to the general register.

  • Page 327: Figure 8.44 Contention Between General Register Write And Input Capture

    Contention between General Register Write and Input Capture: If an input capture signal occurs in the T state of a general register write cycle, input capture takes priority and the write to the general register is not performed. See figure 8.44. General register write cycle φ...

  • Page 328

    Note on Waveform Period Setting: When a counter is cleared by compare match, the counter is cleared in the last state at which the 16TCNT value matches the general register value, at the time when this value would normally be updated to the next count. The actual counter frequency is therefore given by the following formula: φ...

  • Page 329: Table 8.7 (a) 16-bit Timer Operating Modes (channel 0)

    16-bit timer Operating Modes Table 8.7 (a) 16-bit timer Operating Modes (Channel 0) Register Settings TSNC TMDR TIOR0 16TCR0 Synchro- Clear Clock Operating Mode nization FDIR PWM Select Select Synchronous preset SYNC0 = 1 — — PWM mode — — PWM0 = 1 —...

  • Page 330: Table 8.7 (b) 16-bit Timer Operating Modes (channel 1)

    Table 8.7 (b) 16-bit timer Operating Modes (Channel 1) Register Settings TSNC TMDR TIOR1 16TCR1 Synchro- Clear Clock Operating Mode nization FDIR PWM Select Select Synchronous preset SYNC1 = 1 — — PWM mode — — PWM1 = 1 — Output compare A —...

  • Page 331: Table 8.7 (c) 16-bit Timer Operating Modes (channel 2)

    Table 8.7 (c) 16-bit timer Operating Modes (Channel 2) Register Settings TSNC TMDR TIOR2 16TCR2 Synchro- Clear Clock Operating Mode nization FDIR PWM Select Select Synchronous preset SYNC2 = 1 — PWM mode — PWM2 = 1 — Output compare A —...

  • Page 333: Section 9 8-bit Timers

    Section 9 8-Bit Timers Overview The H8/3062 Series has a built-in 8-bit timer module with four channels (TMR0, TMR1, TMR2, and TMR3), based on 8-bit counters. Each channel has an 8-bit timer counter (8TCNT) and two 8-bit time constant registers (TCORA and TCORB) that are constantly compared with the 8TCNT value to detect compare match events.

  • Page 334

    • Twelve interrupt sources There are twelve interrupt sources: four compare match sources, four compare match/input capture sources, four overflow sources. Two of the compare match sources and two of the combined compare match/input capture sources each have an independent interrupt vector. The remaining compare match interrupts, combined compare match/input capture interrupts, and overflow interrupts have one interrupt vector for two sources.

  • Page 335

    9.1.2 Block Diagram The 8-bit timers are divided into two groups of two channels each: group 0 comprising channels 0 and 1, and group 1 comprising channels 2 and 3. Figure 9.1 shows a block diagram of 8-bit timer group 0. External clock Internal clock sources...

  • Page 336

    9.1.3 Pin Configuration Table 9.1 summarizes the input/output pins of the 8-bit timer module. Table 9.1 8-Bit Timer Pins Group Channel Name Abbreviation I/O Function Timer output Output Compare match output Timer clock input TCLKC Input Counter external clock input Timer input/output TMIO Compare match output/input capture input...

  • Page 337

    9.1.4 Register Configuration Table 9.2 summarizes the registers of the 8-bit timer module. Table 9.2 8-Bit Timer Registers Channel Address * Name Abbreviation R/W Initial value H'FFF80 Timer control register 0 8TCR0 H'00 R/(W) * H'FFF82 Timer control/status register 0 8TCSR0 H'00 H'FFF84...

  • Page 338

    Register Descriptions 9.2.1 Timer Counters (8TCNT) 8TCNT0 8TCNT1 Initial value Read/Write 8TCNT2 8TCNT3 Initial value Read/Write The timer counters (8TCNT) are 8-bit readable/writable up-counters that increment on pulses generated from an internal or external clock source. The clock source is selected by clock select bits 2 to 0 (CKS2 to CKS0) in the timer control register (8TCR).

  • Page 339: Time Constant Registers A (tcora)

    9.2.2 Time Constant Registers A (TCORA) TCORA0 to TCORA3 are 8-bit readable/writable registers. TCORA0 TCORA1 Initial value Read/Write TCORA2 TCORA3 Initial value Read/Write The TCORA0 and TCORA1 pair, and the TCORA2 and TCORA3 pair, can each be accessed as a 16-bit register by word access.

  • Page 340: Time Constant Registers B (tcorb)

    9.2.3 Time Constant Registers B (TCORB) TCORB0 TCORB1 Initial value Read/Write TCORB2 TCORB3 Initial value Read/Write TCORB0 to TCORB3 are 8-bit readable/writable registers. The TCORB0 and TCORB1 pair, and the TCORB2 and TCORB3 pair, can each be accessed as a 16-bit register by word access. The TCORB value is constantly compared with the 8TCNT value.

  • Page 341: Timer Control Register (8tcr)

    9.2.4 Timer Control Register (8TCR) CMIEB CMIEA OVIE CCLR1 CCLR0 CKS2 CKS1 CKS0 Initial value Read/Write 8TCR is an 8-bit readable/writable register that selects the 8TCNT input clock, gives the 8TCNT clearing specification, and enables interrupt requests. 8TCR is initialized to H'00 by a reset and in standby mode. For the timing, see section 9.4, Operation.

  • Page 342

    Bits 4 and 3—Counter Clear 1 and 0 (CCLR1, CCLR0): These bits specify the 8TCNT clearing source. Compare match A or B, or input capture B, can be selected as the clearing source. Bit 4 Bit 3 CCLR1 CCLR0 Description Clearing is disabled (Initial value) Cleared by compare match A...

  • Page 343

    Bit 2 Bit 1 Bit 0 CSK2 CSK1 CSK0 Description Clock input disabled (Initial value) Internal clock, counted on falling edge of φ/8 Internal clock, counted on falling edge of φ/64 Internal clock, counted on falling edge of φ/8192 Channel 0 (16-bit count mode): Count on 8TCNT1 overflow signal * Channel 1 (compare match count mode): Count on 8TCNT0 compare match A *...

  • Page 344: Timer Control/status Registers (8tcsr)

    9.2.5 Timer Control/Status Registers (8TCSR) 8TCSR0 CMFB CMFA OIS3 OIS2 ADTE Initial value Read/Write R/(W)* R/(W)* R/(W)* 8TCSR2 CMFB CMFA — OIS3 OIS2 Initial value Read/Write R/(W)* R/(W)* R/(W)* — 8TCSR1, 8TCSR3 CMFB CMFA OIS3 OIS2 Initial value Read/Write R/(W)* R/(W)* R/(W)* Note: * Only 0 can be written to bits 7 to 5, to clear these flags.

  • Page 345

    Bit 7—Compare Match/Input Capture Flag B (CMFB): Status flag that indicates the occurrence of a TCORB compare match or input capture. Bit 7 CMFB Description [Clearing condition] (Initial value) Read CMFB when CMFB = 1, then write 0 in CMFB [Setting conditions] •...

  • Page 346

    Bit 4—A/D Trigger Enable (ADTE) (In 8TCSR0): In combination with TRGE in the A/D control register (ADCR), enables or disables A/D converter start requests by compare match A or an external trigger. Bit 4 TRGE * ADTE Description A/D converter start requests by compare match A or external trigger pin (ADTRG) input are disabled (Initial value) A/D converter start requests by compare match A or external trigger pin...

  • Page 347: Table 9.3 Operation Of Channels 0 And 1 When Bit Ice Is Set To 1 In 8tcsr1 Register

    Table 9.3 Operation of Channels 0 and 1 when Bit ICE is Set to 1 in 8TCSR1 Register Register Timer Output Register Function Status Flag Change Capture Input Interrupt Request TCORA0 Compare match CMFA changed from 0 output CMIA0 interrupt request operation to 1 in 8TCSR0 by controllable...

  • Page 348

    Bits 3 and 2—Output/Input Capture Edge Select B3 and B2 (OIS3, OIS2): In combination with the ICE bit in 8TCSR1 (8TCSR3), these bits select the compare match B output level or the input capture input detected edge. The function of TCORB1 (TCORB3) depends on the setting of bit 4 of 8TCSR1 (8TCSR3). ICE Bit in 8TCSR1 Bit 3...

  • Page 349

    CPU Interface 9.3.1 8-Bit Registers 8TCNT, TCORA, TCORB, 8TCR, and 8TCSR are 8-bit registers. These registers are connected to the CPU by an internal 16-bit data bus and can be read and written a word at a time or a byte at a time.

  • Page 350: Figure 9.5 8tcnt1 Access Operation (cpu Writes To 8tcnt1, Lower Byte)

    Internal data bus Module data bus interface 8TCNTH0 8TCNTL1 Figure 9.5 8TCNT1 Access Operation (CPU Writes to 8TCNT1, Lower Byte) Internal data bus Module data bus interface 8TCNT0 8TCNT1 Figure 9.6 8TCNT0 Access Operation (CPU Reads 8TCNT0, Upper Byte) Internal data bus Module data bus interface 8TCNT0 8TCNT1...

  • Page 351

    Operation 9.4.1 8TCNT Count Timing 8TCNT is incremented by input clock pulses (either internal or external). Internal Clock: Three different internal clock signals (φ/8, φ/64, or φ/8192) divided from the system clock (φ) can be selected, by setting bits CKS2 to CKS0 in 8TCR. Figure 9.8 shows the count timing.

  • Page 352: Compare Match Timing

    φ External clock input 8TCNT input clock N–1 8TCNT Figure 9.9 Count Timing for External Clock Input (Both-Edge Detection) 9.4.2 Compare Match Timing Timer Output Timing: When compare match A or B occurs, the timer output is as specified by the OIS3, OIS2, OS1, and OS0 bits in 8TCSR (unchanged, 0 output, 1 output, or toggle output).

  • Page 353: Input Capture Signal Timing

    Clear by Compare Match: Depending on the setting of the CCLR1 and CCLR0 bits in 8TCR, 8TCNT can be cleared when compare match A or B occurs, Figure 9.11 shows the timing of this operation. φ Compare match signal 8TCNT H'00 Figure 9.11 Timing of Clear by Compare Match Clear by Input Capture: Depending on the setting of the CCLR1 and CCLR0 bits in 8TCR,...

  • Page 354: Timing Of Status Flag Setting

    φ Input capture input Input capture signal 8TCNT TCORB Figure 9.13 Timing of Input Capture Input Signal 9.4.4 Timing of Status Flag Setting Timing of CMFA/CMFB Flag Setting when Compare Match Occurs: The CMFA and CMFB flags in 8TCSR are set to 1 by the compare match signal output when the TCORA or TCORB and 8TCNT values match.

  • Page 355: Operation With Cascaded Connection

    φ 8TCNT TCORB Input capture signal CMFB Figure 9.15 CMFB Flag Setting Timing when Input Capture Occurs Timing of Overflow Flag (OVF) Setting: The OVF flag in 8TCSR is set to 1 by the overflow signal generated when 8TCNT overflows (from H'FF to H'00). Figure 9.16 shows the timing in this case.

  • Page 356

    16-Bit Count Mode • Channels 0 and 1: When bits CKS2 to CKS0 are set to (100) in 8TCR0, the timer functions as a single 16-bit timer with channel 0 occupying the upper 8 bits and channel 1 occupying the lower 8 bits. ...

  • Page 357

     Setting when Input Capture Occurs • The CMFB flag is set to 1 in 8TCSR2 and 8TCSR3 when the ICE bit is 1 in TCSR3 and input capture occurs. • TMIO pin input capture input signal edge detection is selected by bits OIS3 and OIS2 in 8TCSR2.

  • Page 358: Input Capture Setting

    9.4.6 Input Capture Setting The 8TCNT value can be transferred to TCORB on detection of an input edge on the input capture/output compare pin (TMIO or TMIO ). Rising edge, falling edge, or both edge detection can be selected. In 16-bit count mode, 16-bit input capture can be used. Setting Input Capture Operation in 8-Bit Timer Mode (Normal Operation) •...

  • Page 359: Interrupt

    Interrupt 9.5.1 Interrupt Sources The 8-bit timer unit can generate three types of interrupt: compare match A and B (CMIA and CMIB) and overflow (TOVI). Table 9.5 shows the interrupt sources and their priority order. Each interrupt source is enabled or disabled by the corresponding interrupt enable bit in 8TCR. A separate interrupt request signal is sent to the interrupt controller by each interrupt source.

  • Page 360: A/d Converter Activation

    9.5.2 A/D Converter Activation The A/D converter can only be activated by channel 0 compare match A. If the ADTE bit setting is 1 when the CMFA flag in 8TCSR0 is set to 1 by generation of channel 0 compare match A, an A/D conversion start request will be issued to the A/D converter. If the TRGE bit in ADCR is 1 at this time, the A/D converter will be started.

  • Page 361

    Usage Notes Note that the following kinds of contention can occur in 8-bit timer operation. 9.7.1 Contention between 8TCNT Write and Clear If a timer counter clear signal occurs in the T state of a 8TCNT write cycle, clearing of the counter takes priority and the write is not performed.

  • Page 362: Contention Between 8tcnt Write And Increment

    9.7.2 Contention between 8TCNT Write and Increment If an increment pulse occurs in the T state of a 8TCNT write cycle, writing takes priority and 8TCNT is not incremented. Figure 9.19 shows the timing in this case. 8TCNT write cycle φ...

  • Page 363: Contention Between Tcor Write And Compare Match

    9.7.3 Contention between TCOR Write and Compare Match If a compare match occurs in the T state of a TCOR write cycle, writing takes priority and the compare match signal is inhibited. Figure 9.20 shows the timing in this case. TCOR write cycle φ...

  • Page 364: Contention Between Tcor Read And Input Capture

    9.7.4 Contention between TCOR Read and Input Capture If an input capture signal occurs in the T state of a TCOR read cycle, the value before input capture is read. Figure 9.21 shows the timing in this case. TCORB read cycle φ...

  • Page 365: Contention Between Counter Clearing By Input Capture And Counter Increment

    9.7.5 Contention between Counter Clearing by Input Capture and Counter Increment If an input capture signal and counter increment signal occur simultaneously, counter clearing by the input capture signal takes priority and the counter is not incremented. The value before the counter is cleared is transferred to TCORB.

  • Page 366: Contention Between Tcor Write And Input Capture

    9.7.6 Contention between TCOR Write and Input Capture If an input capture signal occurs in the T state of a TCOR write cycle, input capture takes priority and the write to TCOR is not performed. Figure 9.23 shows the timing in this case. TCOR write cycle φ...

  • Page 367: Figure 9.24 Contention Between 8tcnt Byte Write And Increment In 16-bit Count Mode

    9.7.7 Contention between 8TCNT Byte Write and Increment in 16-Bit Count Mode (Cascaded Connection) If an increment pulse occurs in the T state of an 8TCNT byte write cycle in 16-bit count mode, the counter write takes priority and the byte data for which the write was performed is not incremented.

  • Page 368: Contention Between Compare Matches A And B

    9.7.8 Contention between Compare Matches A and B If compare matches A and B occur at the same time, the 8-bit timer operates according to the relative priority of the output states set for compare match A and compare match B, as shown in Table 9.7.

  • Page 369: Table 9.8 Internal Clock Switchover And 8tcnt Operation

    Table 9.8 Internal Clock Switchover and 8TCNT Operation CKS1 and CKS0 Write Timing 8TCNT Operation High → high switchover * Old clock source New clock source 8TCNT clock 8TCNT CKS bits rewritten High → low switchover * Old clock source New clock source 8TCNT clock...

  • Page 370

    CKS1 and CKS0 Write Timing 8TCNT Operation Low → low switchover * Old clock source New clock source 8TCNT clock 8TCNT CKS bits rewritten Notes: *1 Including switchovers from the high level to the halted state, and from the halted state to the high level.

  • Page 371: Section 10 Programmable Timing Pattern Controller (tpc)

    10.1 Overview The H8/3062 Series has a built-in programmable timing pattern controller (TPC) that provides pulse outputs by using the 16-bit timer as a time base. The TPC pulse outputs are divided into 4- bit groups (group 3 to group 0) that can operate simultaneously and independently.

  • Page 372

    10.1.2 Block Diagram Figure 10.1 shows a block diagram of the TPC. 16-bit timer compare match signals PADDR PBDDR NDERA NDERB Control logic TPMR TPCR Internal data bus Pulse output pins, group 3 PBDR NDRB Pulse output pins, group 2 Pulse output pins, group 1 PADR...

  • Page 373

    10.1.3 Pin Configuration Table 10.1 summarizes the TPC output pins. Table 10.1 TPC Pins Name Symbol Function TPC output 0 Output Group 0 pulse output TPC output 1 Output TPC output 2 Output TPC output 3 Output TPC output 4 Output Group 1 pulse output TPC output 5...

  • Page 374

    10.1.4 Register Configuration Table 10.2 summarizes the TPC registers. Table 10.2 TPC Registers Address * Name Abbreviation Initial Value H'EE009 Port A data direction register PADDR H'00 R/(W) * H'FFFD9 Port A data register PADR H'00 H'EE00A Port B data direction register PBDDR H'00 R/(W) *...

  • Page 375

    10.2 Register Descriptions 10.2.1 Port A Data Direction Register (PADDR) PADDR is an 8-bit write-only register that selects input or output for each pin in port A. PA DDR PA DDR PA DDR PA DDR PA DDR PA DDR PA DDR PA DDR Initial value Read/Write...

  • Page 376: Port B Data Direction Register (pbddr)

    10.2.3 Port B Data Direction Register (PBDDR) PBDDR is an 8-bit write-only register that selects input or output for each pin in port B. PB DDR PB DDR PB DDR PB DDR PB DDR PB DDR PB DDR PB DDR Initial value Read/Write Port B data direction 7 to 0...

  • Page 377: Next Data Register A (ndra)

    10.2.5 Next Data Register A (NDRA) NDRA is an 8-bit readable/writable register that stores the next output data for TPC output groups 1 and 0 (pins TP to TP ). During TPC output, when an 16-bit timer compare match event specified in TPCR occurs, NDRA contents are transferred to the corresponding bits in PADR.

  • Page 378

    Different Triggers for TPC Output Groups 0 and 1: If TPC output groups 0 and 1 are triggered by different compare match events, the address of the upper 4 bits of NDRA (group 1) is H'FFFA5 and the address of the lower 4 bits (group 0) is H'FFFA7. Bits 3 to 0 of address H'FFFA5 and bits 7 to 4 of address H'FFFA7 are reserved bits that cannot be modified and always read 1.

  • Page 379: Next Data Register B (ndrb)

    10.2.6 Next Data Register B (NDRB) NDRB is an 8-bit readable/writable register that stores the next output data for TPC output groups 3 and 2 (pins TP to TP ). During TPC output, when an 16-bit timer compare match event specified in TPCR occurs, NDRB contents are transferred to the corresponding bits in PBDR.

  • Page 380

    Different Triggers for TPC Output Groups 2 and 3: If TPC output groups 2 and 3 are triggered by different compare match events, the address of the upper 4 bits of NDRB (group 3) is H'FFFA4 and the address of the lower 4 bits (group 2) is H'FFFA6. Bits 3 to 0 of address H'FFFA4 and bits 7 to 4 of address H'FFFA6 are reserved bits that cannot be modified and always read 1.

  • Page 381: Next Data Enable Register A (ndera)

    10.2.7 Next Data Enable Register A (NDERA) NDERA is an 8-bit readable/writable register that enables or disables TPC output groups 1 and 0 to TP ) on a bit-by-bit basis. NDER7 NDER6 NDER5 NDER4 NDER3 NDER2 NDER1 NDER0 Initial value Read/Write Next data enable 7 to 0 These bits enable or disable...

  • Page 382: Next Data Enable Register B (nderb)

    10.2.8 Next Data Enable Register B (NDERB) NDERB is an 8-bit readable/writable register that enables or disables TPC output groups 3 and 2 to TP ) on a bit-by-bit basis. NDER15 NDER14 NDER13 NDER12 NDER11 NDER10 NDER9 NDER8 Initial value Read/Write Next data enable 15 to 8 These bits enable or disable...

  • Page 383: Tpc Output Control Register (tpcr)

    10.2.9 TPC Output Control Register (TPCR) TPCR is an 8-bit readable/writable register that selects output trigger signals for TPC outputs on a group-by-group basis. G3CMS1 G3CMS0 G2CMS1 G2CMS0 G1CMS1 G1CMS0 G0CMS1 G0CMS0 Initial value Read/Write Group 3 compare match select 1 and 0 These bits select the compare match Group 2 compare...

  • Page 384

    Bits 5 and 4—Group 2 Compare Match Select 1 and 0 (G2CMS1, G2CMS0): These bits select the compare match event that triggers TPC output group 2 (TP to TP Bit 5 Bit 4 G2CMS1 G2CMS0 Description TPC output group 2 (TP to TP ) is triggered by compare match in 16-bit timer channel 0...

  • Page 385: Tpc Output Mode Register (tpmr)

    10.2.10 TPC Output Mode Register (TPMR) TPMR is an 8-bit readable/writable register that selects normal or non-overlapping TPC output for each group. — — — — G3NOV G2NOV G1NOV G0NOV Initial value Read/Write — — — — Reserved bits Group 3 non-overlap Selects non-overlapping TPC output for group 3 (TP to TP )

  • Page 386

    Bit 3—Group 3 Non-Overlap (G3NOV): Selects normal or non-overlapping TPC output for group 3 (TP to TP Bit 3 G3NOV Description Normal TPC output in group 3 (output values change at (Initial value) compare match A in the selected 16-bit timer channel) Non-overlapping TPC output in group 3 (independent 1 and 0 output at compare match A and B in the selected 16-bit timer channel) Bit 2—Group 2 Non-Overlap (G2NOV): Selects normal or non-overlapping TPC output for...

  • Page 387

    10.3 Operation 10.3.1 Overview When corresponding bits in PADDR or PBDDR and NDERA or NDERB are set to 1, TPC output is enabled. The TPC output initially consists of the corresponding PADR or PBDR contents. When a compare-match event selected in TPCR occurs, the corresponding NDRA or NDRB bit contents are transferred to PADR or PBDR to update the output values.

  • Page 388: Output Timing

    10.3.2 Output Timing If TPC output is enabled, NDRA/NDRB contents are transferred to PADR/PBDR and output when the selected compare match event occurs. Figure 10.3 shows the timing of these operations for the case of normal output in groups 2 and 3, triggered by compare match A. φ...

  • Page 389: Normal Tpc Output

    10.3.3 Normal TPC Output Sample Setup Procedure for Normal TPC Output: Figure 10.4 shows a sample procedure for setting up normal TPC output. Normal TPC output Set TIOR to make GRA an output compare Select GR functions register (with output inhibited). Set GRA value Set the TPC output trigger period.

  • Page 390: Figure 10.5 Normal Tpc Output Example (five-phase Pulse Output)

    Example of Normal TPC Output (Example of Five-Phase Pulse Output): Figure 10.5 shows an example in which the TPC is used for cyclic five-phase pulse output. TCNT value Compare match TCNT H'0000 Time NDRB PBDR The 16-bit timer channel to be used as the output trigger channel is set up so that GRA is an output compare register and the counter will be cleared by compare match A.

  • Page 391: Non-overlapping Tpc Output

    10.3.4 Non-Overlapping TPC Output Sample Setup Procedure for Non-Overlapping TPC Output: Figure 10.6 shows a sample procedure for setting up non-overlapping TPC output. Non-overlapping TPC output Select GR functions Set TIOR to make GRA and GRB output compare registers (with output inhibited). Set GR values Set the TPC output trigger period in GRB 16-bit timer...

  • Page 392

    Example of Non-Overlapping TPC Output (Example of Four-Phase Complementary Non- Overlapping Output): Figure 10.7 shows an example of the use of TPC output for four-phase complementary non-overlapping pulse output. TCNT value TCNT H'0000 Time NDRB PBDR Non-overlap margin The 16-bit timer channel to be used as the output trigger channel is set up so that GRA and GRB are output compare registers and the counter will be cleared by compare match B.

  • Page 393: Tpc Output Triggering By Input Capture

    10.3.5 TPC Output Triggering by Input Capture TPC output can be triggered by 16-bit timer input capture as well as by compare match. If GRA functions as an input capture register in the 16-bit timer channel selected in TPCR, TPC output will be triggered by the input capture signal.

  • Page 394

    10.4 Usage Notes 10.4.1 Operation of TPC Output Pins to TP are multiplexed with 16-bit timer, address bus, and other pin functions. When 16-bit timer, or address bus output is enabled, the corresponding pins cannot be used for TPC output. The data transfer from NDR bits to DR bits takes place, however, regardless of the status of the pin.

  • Page 395: Figure 10.10 Non-overlapping Operation And Ndr Write Timing

    Therefore, 0 data can be transferred ahead of 1 data by making compare match B occur before compare match A. NDR contents should not be altered during the interval from compare match B to compare match A (the non-overlap margin). This can be accomplished by having the IMFA interrupt service routine write the next data in NDR.

  • Page 397: Section 11 Watchdog Timer

    As a watchdog timer, it generates a reset signal for the H8/3062 chip if a system crash allows the timer counter (TCNT) to overflow before being rewritten. In interval timer operation, an interval timer interrupt is requested at each TCNT overflow.

  • Page 398

    11.1.2 Block Diagram Figure 11.1 shows a block diagram of the WDT. Overflow Internal TCNT data bus Read/ Interrupt Interrupt signal write control (interval timer) control TCSR Internal clock sources φ/2 RSTCSR φ/32 φ/64 Reset Reset control Clock φ/128 (internal, external) Clock φ/256 selector...

  • Page 399

    11.1.4 Register Configuration Table 11.2 summarizes the WDT registers. Table 11.2 WDT Registers Address * Write * Read Name Abbreviation Initial Value R/(W) * H'FFF8C H'FFF8C Timer control/status register TCSR H'18 H'FFF8D Timer counter TCNT H'00 R/(W) * H'FFF8E H'FFF8F Reset control/status register RSTCSR H'3F Notes: *1 Lower 20 bits of the address in advanced mode...

  • Page 400: Timer Control/status Register (tcsr)

    11.2.2 Timer Control/Status Register (TCSR) TCSR is an 8-bit readable and writable register. Its functions include selecting the timer mode and clock source. WT/IT — — CKS2 CKS1 CKS0 Initial value R/(W) * Read/Write — — Clock select These bits select the TCNT clock source Reserved bits Timer enable...

  • Page 401

    Bit 6—Timer Mode Select (WT/IT): Selects whether to use the WDT as a watchdog timer or interval timer. If used as an interval timer, the WDT generates an interval timer interrupt request when TCNT overflows. If used as a watchdog timer, the WDT generates a reset signal when TCNT overflows.

  • Page 402: Reset Control/status Register (rstcsr)

    Bit 7—Watchdog Timer Reset (WRST): During watchdog timer operation, this bit indicates that TCNT has overflowed and generated a reset signal. This reset signal resets the entire H8/3062 chip internally. If bit RSTOE is set to 1, this reset signal is also output (low) at the RESO pin to initialize external system devices.

  • Page 403: Notes On Register Rewriting

    Bit 6—Reset Output Enable (RSTOE): Enables or disables external output at the RESO pin of the reset signal generated if TCNT overflows during watchdog timer operation. Note that there is no RESO pin in the versions with on-chip flash memory. Bit 6 RSTOE Description Reset signal is not output externally...

  • Page 404: Figure 11.3 Format Of Data Written To Rstcsr

    Writing to RSTCSR: RSTCSR must be written by a word transfer instruction. It cannot be written by byte transfer instructions. Figure 11.3 shows the format of data written to RSTCSR. To write 0 in the WRST bit, the write data must have H'A5 in the upper byte and H'00 in the lower byte.

  • Page 405

    TCNT value (normally by writing H'00) before overflow occurs. If TCNT fails to be rewritten and overflows due to a system crash etc., the H8/3062 is internally reset for a duration of 518 states. The watchdog reset signal can be externally output from the RESO pin to reset external system devices.

  • Page 406: Interval Timer Operation

    11.3.2 Interval Timer Operation Figure 11.5 illustrates interval timer operation. To use the WDT as an interval timer, clear bit WT/IT to 0 and set bit TME to 1 in TCSR. An interval timer interrupt request is generated at each TCNT overflow.

  • Page 407: Timing Of Setting Of Watchdog Timer Reset Bit (wrst)

    1 when TCNT overflows and OVF is set to 1. At the same time an internal reset signal is generated for the entire H8/3062 chip. This internal reset signal clears OVF to 0, but the WRST bit remains set to 1. The reset routine must therefore clear the WRST bit.

  • Page 408

    11.4 Interrupts During interval timer operation, an overflow generates an interval timer interrupt (WOVI). The interval timer interrupt is requested whenever the OVF flag is set to 1 in TCSR. 11.5 Usage Notes Contention between TCNT Write and Increment: If a timer counter clock pulse is generated during the T state of a write cycle to TCNT, the write takes priority and the timer count is not incremented.

  • Page 409: Section 12 Serial Communication Interface

    12.1 Overview The H8/3062 Series has a serial communication interface (SCI) with two independent channels. The two channels have identical functions. The SCI can communicate in both asynchronous and synchronous mode. It also has a multiprocessor communication function for serial communication among two or more processors.

  • Page 410

    • Full-duplex communication The transmitting and receiving sections are independent, so the SCI can transmit and receive simultaneously. The transmitting and receiving sections are both double-buffered, so serial data can be transmitted and received continuously. • The following settings can be made for the serial data to be transferred: ...

  • Page 411

    12.1.2 Block Diagram Figure 12.1 shows a block diagram of the SCI. Module data bus Internal data bus φ Baud rate φ/ 4 SCMR generator φ/16 Transmit/receive φ/64 control Parity generate Clock Parity check External clock T E I T X I R X I E R I Legend:...

  • Page 412

    12.1.3 Pin Configuration The SCI has serial pins for each channel as listed in table 12.1. Table 12.1 SCI Pins Channel Name Abbreviation Function Serial clock pin Input/output clock input/output Receive data pin Input receive data input Transmit data pin Output transmit data output Serial clock pin...

  • Page 413

    12.1.4 Register Configuration The SCI has internal registers as listed in table 12.2. These registers select asynchronous or synchronous mode, specify the data format and bit rate, control the transmitter and receiver sections, and specify switching between the serial communication interface and smart card interface.

  • Page 414

    12.2 Register Descriptions 12.2.1 Receive Shift Register (RSR) RSR is the register that receives serial data. — — — — — — — — Read/Write The SCI loads serial data input at the RxD pin into RSR in the order received, LSB (bit 0) first, thereby converting the data to parallel data.

  • Page 415: Transmit Shift Register (tsr)

    12.2.3 Transmit Shift Register (TSR) TSR is the register that transmits serial data. — — — — — Read/Write — — — The SCI loads transmit data from TDR to TSR, then transmits the data serially from the TxD pin, LSB (bit 0) first.

  • Page 416: Serial Mode Register (smr)

    12.2.5 Serial Mode Register (SMR) SMR is an 8-bit register that specifies the SCI's serial communication format and selects the clock source for the baud rate generator. STOP CKS1 CKS0 Initial value Read/Write Clock select 1/0 These bits select the baud rate generator's clock source Multiprocessor mode...

  • Page 417

    Bit 7 Description Asynchronous mode (Initial value) Synchronous mode For Smart Card Interface (SMIF Bit in SCMR Set to 1): Selects GSM mode for the smart card interface. Bit 7 Description The TEND flag is set 12.5 etu after the start bit (Initial value) The TEND flag is set 11.0 etu after the start bit Note: etu: Elementary time unit (time required to transmit one bit)

  • Page 418

    Bit 4 Description Even parity * (Initial value) Odd parity * Notes: *1 When even parity is selected, the parity bit added to transmit data makes an even number of 1s in the transmitted character and parity bit combined. Receive data must have an even number of 1s in the received character and parity bit combined.

  • Page 419: Serial Control Register (scr)

    For the relationship between the clock source, bit rate register setting, and baud rate, see section 12.2.8, Bit Rate Register (BRR). Bit 1 Bit 0 CKS1 CKS0 Description φ (Initial value) φ/4 φ/16 φ/64 12.2.6 Serial Control Register (SCR) SCR register enables or disables the SCI transmitter and receiver, enables or disables serial clock output in asynchronous mode, enables or disables interrupts, and selects the transmit/receive clock source.

  • Page 420

    The CPU can always read and write SCR. SCR is initialized to H'00 by a reset and in standby mode. Bit 7—Transmit Interrupt Enable (TIE): Enables or disables the transmit-data-empty interrupt (TXI) requested when the TDRE flag in SSR is set to 1 due to transfer of serial transmit data from TDR to TSR.

  • Page 421

    Bit 4 Description Receiving disabled * (Initial value) Receiving enabled * Notes: *1 Clearing the RE bit to 0 does not affect the RDRF, FER, PER, and ORER flags. These flags retain their previous values. *2 In the enabled state, serial receiving starts when a start bit is detected in asynchronous mode, or serial clock input is detected in synchronous mode.

  • Page 422

    For serial communication interface (SMIF bit in SCMR cleared to 0): These bits select the SCI clock source and enable or disable clock output from the SCK pin. Depending on the settings of CKE1 and CKE0, the SCK pin can be used for generic input/output, serial clock output, or serial clock input.

  • Page 423: Serial Status Register (ssr)

    12.2.7 Serial Status Register (SSR) SSR is an 8-bit register containing multiprocessor bit values, and status flags that indicate the operating status of the SCI. TEND MPBT TDRE RDRF ORER FER/ERS Initial value R/(W) R/(W) R/(W) Read/Write R/(W) R/(W) Multiprocessor bit transfer Value of multiprocessor bit to be transmitted Multiprocessor bit...

  • Page 424

    Bit 7—Transmit Data Register Empty (TDRE): Indicates that the SCI has loaded transmit data from TDR into TSR and the next serial data can be written in TDR. Bit 7 TDRE Description TDR contains valid transmit data [Clearing condition] Read TDRE when TDRE = 1, then write 0 in TDRE TDR does not contain valid transmit data (Initial value) [Setting conditions]...

  • Page 425

    Bit 5—Overrun Error (ORER): Indicates that data reception ended abnormally due to an overrun error. Bit 5 ORER Description Receiving is in progress or has ended normally * (Initial value) [Clearing conditions] • The chip is reset or enters standby mode •...

  • Page 426

    For Smart Card Interface (SMIF Bit in SCMR Set to 1): Indicates the status of the error signal sent back from the receiving side during transmission. Framing errors are not detected in smart card interface mode. Bit 4 Description Normal reception, no error signal * (Initial value) [Clearing conditions] •...

  • Page 427

    Bit 2 TEND Description Transmission is in progress [Clearing condition] Read TDRE when TDRE = 1, then write 0 in TDRE End of transmission (Initial value) [Setting conditions] • The chip is reset or enters standby mode • The TE bit in SCR is cleared to 0 •...

  • Page 428: Bit Rate Register (brr)

    Bit 0—Multiprocessor Bit Transfer (MPBT): Stores the value of the multiprocessor bit added to transmit data when a multiprocessor format in selected for transmitting in asynchronous mode. The MPBT bit setting is ignored in synchronous mode, when a multiprocessor format is not selected, or when the SCI cannot transmit.

  • Page 429: Table 12.3 Examples Of Bit Rates And Brr Settings In Asynchronous Mode

    Table 12.3 Examples of Bit Rates and BRR Settings in Asynchronous Mode φ φ φ φ (MHz) 2.097152 2.4576 Bit Rate (bit/s) Error (%) n Error (%) n Error (%) n Error (%) 141 0.03 148 -0.04 174 -0.26 212 0.03 103 0.16 108 0.21 127 0.00...

  • Page 430

    φ φ φ φ (MHz) 6.144 7.3728 Bit Rate (bit/s) Error (%) n Error (%) n Error (%) n Error (%) 106 -0.44 108 0.08 130 -0.07 141 0.03 0.16 0.00 0.00 103 0.16 155 0.16 159 0.00 191 0.00 207 0.16 0.16 0.00...

  • Page 431

    φ φ φ φ (MHz) 14.7456 Bit Rate (bit/s) Error (%) n Error (%) n Error (%) n Error (%) 230 -0.08 248 -0.17 0.70 0.03 168 0.16 181 0.16 191 0.00 207 0.16 -0.43 0.16 0.00 103 0.16 168 0.16 181 0.16 191 0.00 207 0.16...

  • Page 432: Table 12.4 Examples Of Bit Rates And Brr Settings In Synchronous Mode

    Table 12.4 Examples of Bit Rates and BRR Settings in Synchronous Mode φ φ φ φ (MHz) Rate (bit/s) n — — — — — — — — — — — — — — — — 124 2 249 3 124 —...

  • Page 433

    The BRR setting is calculated as follows: Asynchronous mode: φ × 10 – 1 64 × 2 × B 2n–1 Synchronous mode: φ × 10 – 1 8 × 2 × B 2n–1 B: Bit rate (bit/s) N: BRR setting for baud rate generator (0 ≤ N ≤ 255) φ: System clock frequency (MHz) n: Baud rate generator input clock (n = 0, 1, 2, 3) (For the clock sources and values of n, see the following table.)

  • Page 434: Table 12.5 Maximum Bit Rates For Various Frequencies (asynchronous Mode)

    Table 12.5 shows the maximum bit rates in asynchronous mode for various system clock frequencies. Tables 12.6 and 12.7 show the maximum bit rates with external clock input. Table 12.5 Maximum Bit Rates for Various Frequencies (Asynchronous Mode) Settings φ φ φ φ (MHz) Maximum Bit Rate (bit/s) 62500 2.097152...

  • Page 435: Table 12.6 Maximum Bit Rates With External Clock Input (asynchronous Mode)

    Table 12.6 Maximum Bit Rates with External Clock Input (Asynchronous Mode) φ φ φ φ (MHz) External Input Clock (MHz) Maximum Bit Rate (bit/s) 0.5000 31250 2.097152 0.5243 32768 2.4576 0.6144 38400 0.7500 46875 3.6864 0.9216 57600 1.0000 62500 4.9152 1.2288 76800 1.2500...

  • Page 436

    Table 12.7 Maximum Bit Rates with External Clock Input (Synchronous Mode) φ φ φ φ (MHz) External Input Clock (MHz) Maximum Bit Rate (bit/s) 0.3333 333333.3 0.6667 666666.7 1.0000 1000000.0 1.3333 1333333.3 1.6667 1666666.7 2.0000 2000000.0 2.3333 2333333.3 2.6667 2666666.7 3.0000 3000000.0 3.3333...

  • Page 437

    Asynchronous Mode • Data length is selectable: 7 or 8 bits • Parity and multiprocessor bits are selectable, and so is the stop bit length (1 or 2 bits). These selections determine the communication format and character length. • In receiving, it is possible to detect framing errors, parity errors, overrun errors, and the break state.

  • Page 438: Table 12.8 Smr Settings And Serial Communication Formats

    Table 12.8 SMR Settings and Serial Communication Formats SMR Settings SCI Communication Format Multi- pro- Bit 7 Bit 6 Bit 2 Bit 5 Bit 3 Data cessor Parity Stop Bit STOP Mode Length Length Asyn- 8-bit data Absent Absent 1 bit chronous 2 bits mode...

  • Page 439: Operation In Asynchronous Mode

    12.3.2 Operation in Asynchronous Mode In asynchronous mode, each transmitted or received character begins with a start bit and ends with one or two stop bits. Serial communication is synchronized one character at a time. The transmitting and receiving sections of the SCI are independent, so full-duplex communication is possible.

  • Page 440: Table 12.10 Serial Communication Formats (asynchronous Mode)

    Table 12.10 Serial Communication Formats (Asynchronous Mode) SMR Settings Serial Communication Format and Frame Length STOP 8-bit data STOP 8-bit data STOP STOP 8-bit data STOP 8-bit data STOP STOP 7-bit data STOP 7-bit data STOP STOP 7-bit data STOP 7-bit data STOP STOP...

  • Page 441

    Clock: An internal clock generated by the on-chip baud rate generator or an external clock input from the SCK pin can be selected as the SCI transmit/receive clock. The clock source is selected by the C/A bit in SMR and bits CKE1 and CKE0 in SCR. For details of SCI clock source selection, see table 12.9.

  • Page 442: Figure 12.4 Sample Flowchart For Sci Initialization

    Figure 12.4 shows a sample flowchart for initializing the SCI. Start of initialization Set the clock source in SCR. Clear the Clear TE and RE bits RIE, TIE, TEIE, MPIE, TE, and RE bits to to 0 in SCR 0 * . If clock output is selected in asynchronous mode, clock output starts Set CKE1 and CKE0 bits in SCR immediately after the setting is made in...

  • Page 443: Figure 12.5 Sample Flowchart For Transmitting Serial Data

    • Transmitting Serial Data (Asynchronous Mode): Figure 12.5 shows a sample flowchart for transmitting serial data and indicates the procedure to follow. SCI initialization: Initialize the transmit data output function of the TxD pin is selected automatically. Start transmitting After the TE bit is set to 1, one frame of 1s is output, then transmission is possible.

  • Page 444

    In transmitting serial data, the SCI operates as follows: • The SCI monitors the TDRE flag in SSR. When the TDRE flag is cleared to 0, the SCI recognizes that TDR contains new data, and loads this data from TDR into TSR. •...

  • Page 445: Figure 12.7 Sample Flowchart For Receiving Serial Data

    • Receiving Serial Data (Asynchronous Mode): Figure 12.7 shows a sample flowchart for receiving serial data and indicates the procedure to follow. SCI initialization: Initialize the receive data input function of the RxD pin is selected automatically. Start receiving (2)(3) Receive error handling and break detection: if a receive error occurs, read the ORER, Read ORER, PER, and FER...

  • Page 446

    Error handling ORER= 1 Overrun error handling FER= 1 Break? Framing error handling Clear RE bit to 0 in SCR PER= 1 Parity error handling Clear ORER, PER, and FER flags to 0 in SSR <End> Figure 12.7 Sample Flowchart for Receiving Serial Data (cont)

  • Page 447: Table 12.11 Receive Error Conditions

    In receiving, the SCI operates as follows: • The SCI monitors the communication line. When it detects a start bit (0 bit), the SCI synchronizes internally and starts receiving. • Receive data is stored in RSR in order from LSB to MSB. •...

  • Page 448: Multiprocessor Communication

    Figure 12.8 shows an example of SCI receive operation in asynchronous mode. Start Parity Stop Start Parity Stop Data Data Idle (mark) state RDRF RXI interrupt RXI interrupt handler request Framing error, reads data in RDR and ERI interrupt clears RDRF flag to 0 1 frame request Figure 12.8 Example of SCI Receive Operation...

  • Page 449

    Communication Formats: Four formats are available. Parity bit settings are ignored when a multiprocessor format is selected. For details see table 12.10. Clock: See the description of asynchronous mode. Transmitting processor Serial communication line Receiving Receiving Receiving Receiving processor A processor B processor C processor D...

  • Page 450: Figure 12.10 Sample Flowchart For Transmitting Multiprocessor Serial Data

    Initialize SCI initialization: the transmit data output function of the TxD pin is selected automatically. Start transmitting SCI status check and transmit data write: Read TDRE flag in SSR read SSR, check that the TDRE flag is 1, then write transmit data in TDR. Also set the MPBT flag to 0 or 1 in SSR.

  • Page 451

    In transmitting serial data, the SCI operates as follows: • The SCI monitors the TDRE flag in SSR. When the TDRE flag is cleared to 0, the SCI recognizes that TDR contains new data, and loads this data from TDR into TSR. •...

  • Page 452: Figure 12.12 Sample Flowchart For Receiving Multiprocessor Serial Data

    SCI initialization: Initialize the receive data input function of the RxD pin is selected automatically. Start receiving ID receive cycle: set the MPIE bit to 1 in SCR. Set MPIE bit to 1 in SCR SCI status check and ID check: Read ORER and FER flags read SSR, check that the RDRF flag in SSR...

  • Page 453

    Error handling ORER= 1 Overrun error handling FER= 1 Break? Clear RE bit to 0 in SCR Framing error handling Clear ORER, PER, and FER flags to 0 in SSR <End> Figure 12.12 Sample Flowchart for Receiving Multiprocessor Serial Data (cont)

  • Page 454

    Figure 12.13 shows an example of SCI receive operation using a multiprocessor format. Start Stop Start Stop Data (ID1) Data (data1) Idle (mark) state MPIE RDRF RDR value RXI interrupt request RXI interrupt handler reads Not own ID, so MPIE No RXI interrupt MPB detection (multiprocessor interrupt)

  • Page 455: Synchronous Operation

    12.3.4 Synchronous Operation In synchronous mode, the SCI transmits and receives data in synchronization with clock pulses. This mode is suitable for high-speed serial communication. The SCI transmitter and receiver share the same clock but are otherwise independent, so full- duplex communication is possible.

  • Page 456: Figure 12.15 Sample Flowchart For Sci Initialization

    Transmitting and Receiving Data: • SCI Initialization (Synchronous Mode): Before transmitting or receiving data, clear the TE and RE bits to 0 in SCR, then initialize the SCI as follows. When changing the communication mode or format, always clear the TE and RE bits to 0 before following the procedure given below.

  • Page 457: Figure 12.16 Sample Flowchart For Serial Transmitting

    • Transmitting Serial Data (Synchronous Mode): Figure 12.16 shows a sample flowchart for transmitting serial data and indicates the procedure to follow. SCI initialization: the transmit data Initialize output function of the TxD pin is selected automatically. Start transmitting SCI status check and transmit data write: read SSR, check that the TDRE Read TDRE flag in SSR flag is 1, then write transmit data in...

  • Page 458: Figure 12.17 Example Of Sci Transmit Operation

    In transmitting serial data, the SCI operates as follows. • The SCI monitors the TDRE flag in SSR. When the TDRE flag is cleared to 0, the SCI recognizes that TDR contains new data, and loads this data from TDR into TSR. •...

  • Page 459: Figure 12.18 Sample Flowchart For Serial Receiving

    Initialize SCI initialization: the receive data input function of the RxD pin is selected automatically. Start receiving Receive error handling: if a receive (2)(3) error occurs, read the ORER flag in Read ORER flag in SSR SSR, then after executing the necessary error handling, clear the ORER flag to 0.

  • Page 460

    Error handling Overrun error handling Clear ORER flag to 0 in SSR <End> Figure 12.18 Sample Flowchart for Serial Receiving (cont) In receiving, the SCI operates as follows: • The SCI synchronizes with serial clock input or output and synchronizes internally. •...

  • Page 461: Figure 12.19 Example Of Sci Receive Operation

    Figure 12.19 shows an example of SCI receive operation. Serial clock Serial data Bit 7 Bit 0 Bit 7 Bit 0 Bit 1 Bit 6 Bit 7 RDRF ORER RXI interrupt RXI interrupt handler RXI interrupt Overrun error, request reads data in RDR and request ERI interrupt clears RDRF flag to 0...

  • Page 462: Figure 12.20 Sample Flowchart For Simultaneous Serial Transmitting And Receiving

    • Transmitting and Receiving Data Simultaneously (Synchronous Mode): Figure 12.20 shows a sample flowchart for transmitting and receiving serial data simultaneously and indicates the procedure to follow. Initialize SCI initialization: the transmit data output function of the TxD pin and the read data input function of the TxD pin are selected, enabling simultaneous Start of transmitting and receiving transmitting and receiving.

  • Page 463: Sci Interrupts

    12.4 SCI Interrupts The SCI has four interrupt request sources: transmit-end interrupt (TEI), receive-error (ERI), receive-data-full (RXI), and transmit-data-empty interrupt (TXI). Table 12.12 lists the interrupt sources and indicates their priority. These interrupts can be enabled or disabled by the TIE, RIE, and TEIE bits in SCR.

  • Page 464

    12.5 Usage Notes 12.5.1 Notes on Use of SCI Note the following points when using the SCI. TDR Write and TDRE Flag: The TDRE flag in SSR is a status flag indicating the loading of transmit data from TDR to TSR. The SCI sets the TDRE flag to 1 when it transfers data from TDR to TSR.

  • Page 465: Figure 12.21 Receive Data Sampling Timing In Asynchronous Mode

    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 the FER flag is set and the parity error flag (PER) may also be set. In the break state the SCI receiver continues to operate, so if the FER flag is cleared to 0 it will be set to 1 again.

  • Page 466: Figure 12.22 Example Of Synchronous Transmission

    The receive margin in asynchronous mode can therefore be expressed as shown in equation (1). D – 0.5 (1 + F) × 100% M = (0.5 – ) – (L – 0.5) F – ..(1) Receive margin (%) Ratio of clock frequency to bit rate (N = 16) Clock duty cycle (D = 0 to 1.0)

  • Page 467: Figure 12.23 Operation When Switching From Sck Pin Function To Port Pin Function

    Switching from SCK Pin Function to Port Pin Function: • Problem in Operation: When switching the SCK pin function to the output port function (high- level output) by making the following settings while DDR = 1, DR = 1, C/A = 1, CKE1 = 0, CKE0 = 0, and TE = 1 (synchronous mode), low-level output occurs for one half-cycle.

  • Page 468

    • Sample Procedure for Avoiding Low-Level Output: As this sample procedure temporarily places the SCK pin in the input state, the SCK/port pin should be pulled up beforehand with an external circuit. With DDR = 1, DR = 1, C/A = 1, CKE1 = 0, CKE0 = 0, and TE = 1, make the following settings in the order shown.

  • Page 469: Section 13 Smart Card Interface

    Switchover between the normal serial communication interface and the smart card interface is controlled by a register setting. 13.1.1 Features Features of the smart card interface supported by the H8/3062 Series are listed below. • Asynchronous communication  Data length: 8 bits  Parity bit generation and checking ...

  • Page 470

    13.1.2 Block Diagram Figure 13.1 shows a block diagram of the smart card interface. Internal Module data bus data bus SCMR φ φ/4 Baud rate generator φ/16 Transmission/ φ/64 reception control Parity generation Clock Parity check External clock Legend SCMR : Smart card mode register : Receive shift register : Receive data register : Transmit shift register...

  • Page 471

    13.1.4 Register Configuration The smart card interface has the internal registers listed in table 13.2. The BRR, TDR, and RDR registers have their normal serial communication interface functions, as described in section 12, Serial Communication Interface. Table 13.2 Smart Card Interface Registers Address * Channel Name...

  • Page 472

    13.2 Register Descriptions This section describes the new or modified registers and bit functions in the smart card interface. 13.2.1 Smart Card Mode Register (SCMR) SCMR is an 8-bit readable/writable register that selects smart card interface functions. — — — —...

  • Page 473

    Bit 2—Smart Card Data Invert (SINV): Specifies inversion of the data logic level. This function is used in combination with the SDIR bit to communicate with inverse-convention cards * . The SINV bit does not affect the logic level of the parity bit. For parity settings, see section 13.3.4, Register Settings.

  • Page 474

    13.2.2 Serial Status Register (SSR) The function of SSR bit 4 is modified in smart card interface mode. This change also causes a modification to the setting conditions for bit 2 (TEND). TDRE RDRF ORER TEND MPBT Initial value R/(W) * R/(W) * R/(W) * R/(W) *...

  • Page 475

    Bits 3 to 0: These bits operate as in normal serial communication. For details see section 12.2.7, Serial Status Register (SSR). The setting conditions for transmit end (TEND), however, are modified as follows. Bit 2 TEND Description Transmission is in progress [Clearing condition] Software reads TDRE while it is set to 1, then writes 0 in the TDRE flag.

  • Page 476

    Bit 7 Description Normal smart card interface mode operation • The TEND flag is set 12.5 etu after the beginning of the start bit. • Clock output on/off control only. (Initial value) GSM mode smart card interface mode operation • The TEND flag is set 11.0 etu after the beginning of the start bit.

  • Page 477

    CLK pin of the smart card. If the smart card uses an internal clock, this connection is unnecessary. The reset signal should be output from one of the H8/3062 Series’ generic ports. In addition to these pin connections. power and ground connections will normally also be...

  • Page 478: Data Format

    Data line Clock line H8/3062 Series Px (port) chip Reset line Smart card Card-processing device Figure 13.2 Smart Card Interface Connection Diagram Note: Setting both TE and RE to 1 without connecting a smart card enables closed transmission/reception, allowing self-diagnosis to be carried out.

  • Page 479: Figure 13.3 Smart Card Interface Data Format

    No parity error Output from transmitting device Parity error Output from transmitting device Output from receiving Legend: device : Start bit D0 to D7 : Data bits : Parity bit : Error signal Figure 13.3 Smart Card Interface Data Format The operating sequence is as follows.

  • Page 480: Register Settings

    13.3.4 Register Settings Table 13.3 shows a bit map of the registers used in the smart card interface. Bits indicated as 0 or 1 must be set to the value shown. The setting of other bits is described in this section. Table 13.3 Smart Card Interface Register Settings Register Address * Bit 7...

  • Page 481

    In the H8/3062 Series, inversion specified by the SINV bit applies only to the data bits, D7 to D0. For parity bit inversion, the O/E bit in SMR must be set to odd parity mode. This applies...

  • Page 482: Clock

    13.3.5 Clock Only an internal clock generated by the on-chip baud rate generator can be used as the transmit/receive clock for the smart card interface. The bit rate is set with the bit rate register (BRR) and the CKS1 and CKS0 bits in the serial mode register (SMR). The equation for calculating the bit rate is shown below.

  • Page 483: Table 13.6 Brr Settings For Typical Bit Rates (bits/s) (when N = 0)

    The following equation calculates the bit rate register (BRR) setting from the operating frequency and bit rate. N is an integer from 0 to 255, specifying the value with the smaller error. φ × 10 – 1 1488 × 2 ×...

  • Page 484: Transmitting And Receiving Data

    13.3.6 Transmitting and Receiving Data Initialization: Before transmitting or receiving data, the smart card interface must be initialized as described below. Initialization is also necessary when switching from transmit mode to receive mode, or vice versa. 1. Clear the TE and RE bits to 0 in the serial control register (SCR). 2.

  • Page 485: Figure 13.4 Timing Of Tend Flag Setting

    For details, see Interrupt Operations in this section. Serial data Guard time (1) GM = 0 TEND 12.5 etu (2) GM = 1 TEND 11.0 etu Figure 13.4 Timing of TEND Flag Setting...

  • Page 486: Figure 13.5 Sample Transmission Processing Flowchart

    Start Initialization Start transmitting FER/ERS = 0? Error handling TEND = 1? Write transmit data in TDR, and clear TDRE flag to 0 in SSR All data transmitted? FER/ERS = 0? Error handling TEND = 1? Clear TE bit to 0 Figure 13.5 Sample Transmission Processing Flowchart...

  • Page 487: Figure 13.6 Relation Between Transmit Operation And Internal Registers

    (shift register) 1. Data write Data 1 2. Transfer from TDR to TSR Data 1 Data 1 Data remains in TDR. Data 1 I/O signal 3. Serial data output Data 1 output In case of normal transmission : TEND flag is set. In case of transmit error : ERS flag is set.

  • Page 488: Figure 13.8 Sample Reception Processing Flowchart

    Start Initialization Start receiving ORER = 0 and PER = 0? Error handling RDRF = 1? Read RDR and clear RDRF flag to 0 in SSR All data received? Clear RE bit to 0 Figure 13.8 Sample Reception Processing Flowchart The above procedure may include interrupt handling.

  • Page 489: Figure 13.9 Timing For Fixing Cock Output

    When switching from transmit mode to receive mode, first confirm that the transmit operation has been completed, then start from initialization, clearing TE to 0 and setting RE to 1. The TEND flag can be used to check that the transmit operation has been completed. Fixing Clock Output: When the GM bit is set to 1 in SMR, clock output can be fixed by means of the CKE1 and CKE0 bits in SCR.

  • Page 490: Figure 13.10 Procedure For Stopping And Restarting The Clock

    Examples of Operation in GSM Mode: When switching between smart card interface mode and software standby mode, use the following procedures to maintain the clock duty cycle. • Switching from smart card interface mode to software standby mode 1. Set the P9 data register (DR) and data direction register (DDR) to the values for the fixed output state in software standby mode.

  • Page 491

    13.4 Usage Notes The following points should be noted when using the SCI as a smart card interface. Receive Data Sampling Timing and Receive Margin in Smart Card Interface Mode: In smart card interface mode, the SCI operates on a base clock with a frequency of 372 times the transfer rate.

  • Page 492

    The receive margin can therefore be expressed as follows. Receive margin in smart card interface mode: D – 0.5 (1 + F) × 100% M = (0.5 – ) – (L – 0.5) F – M: Receive margin (%) N: Ratio of clock frequency to bit rate (N = 372) D: Clock duty cycle (L = 0 to 1.0) L: Frame length (L =10) F: Absolute deviation of clock frequency...

  • Page 493: Figure 13.12 Retransmission In Sci Receive Mode

    TEND Figure 13.13 Retransmission in SCI Transmit Mode The smart card interface installed in the H8/3062 Series supports an IC card (smart card) interface with provision for ISO/IEC7816-3 T=0 (character transmission). Therefore, block transfer operations are not supported (error signal transmission, detection, and automatic data...

  • Page 495: Section 14 A/d Converter

    Section 14 A/D Converter 14.1 Overview The H8/3062 Series includes a 10-bit successive-approximations A/D converter with a selection of up to eight analog input channels. When the A/D converter is not used, it can be halted independently to conserve power. For details see section 21.6, Module Standby Function.

  • Page 496

    14.1.2 Block Diagram Figure 14.1 shows a block diagram of the A/D converter. Internal Module data bus data bus 10-bit D/A – ø/4 Comparator Analog Control circuit multi- plexer Sample-and- ø/8 hold circuit ADTRG interrupt signal Compare match A0 ADTE 8-bit timer 8TCSR0 Legend:...

  • Page 497

    14.1.3 Pin Configuration Table 14.1 summarizes the A/D converter’s input pins. The eight analog input pins are divided into two groups: group 0 (AN to AN ), and group 1 (AN to AN ). AV and AV are the power supply for the analog circuits in the A/D converter.

  • Page 498

    14.1.4 Register Configuration Table 14.2 summarizes the A/D converter’s registers. Table 14.2 A/D Converter Registers Address * Name Abbreviation Initial Value H'FFFE0 A/D data register A H ADDRAH H'00 H'FFFE1 A/D data register A L ADDRAL H'00 H'FFFE2 A/D data register B H ADDRBH H'00 H'FFFE3...

  • Page 499: A/d Control/status Register (adcsr)

    data register are reserved bits that are always read as 0. Table 14.3 indicates the pairings of analog input channels and A/D data registers. The CPU can always read and write the A/D data registers. The upper byte can be read directly, but the lower byte is read through a temporary register (TEMP).

  • Page 500

    ADCSR is an 8-bit readable/writable register that selects the mode and controls the A/D converter. ADCSR is initialized to H'00 by a reset and in standby mode. Bit 7—A/D End Flag (ADF): Indicates the end of A/D conversion. Bit 7 Description [Clearing condition] (Initial value)

  • Page 501: A/d Control Register (adcr)

    Bit 3—Clock Select (CKS): Selects the A/D conversion time. Clear the ADST bit to 0 before switching the conversion time. Bit 3 Description Conversion time = 134 states (maximum) (Initial value) Conversion time = 70 states (maximum) Bits 2 to 0—Channel Select 2 to 0 (CH2 to CH0): These bits and the SCAN bit select the analog input channels.

  • Page 502

    Bit 7—Trigger Enable (TRGE): Enables or disables starting of A/D conversion by an external trigger or 8-bit timer compare match. Bit 7 TRGE Description Starting of A/D conversion by an external trigger or 8-bit timer (Initial value) compare match is disabled A/D conversion is started at the falling edge of the external trigger signal (ADTRG) or by an 8-bit timer compare match External trigger pin and 8-bit timer selection is performed by the 8-bit timer.

  • Page 503: Figure 14.2 A/d Data Register Access Operation (reading H'aa40)

    Upper-byte read Module data bus Bus interface (H'AA) TEMP (H'40) ADDRnH ADDRnL (H'AA) (H'40) (n = A to D) Lower-byte read Module data bus Bus interface (H'40) TEMP (H'40) ADDRnH ADDRnL (H'AA) (H'40) (n = A to D) Figure 14.2 A/D Data Register Access Operation (Reading H'AA40)

  • Page 504

    14.4 Operation The A/D converter operates by successive approximations with 10-bit resolution. It has two operating modes: single mode and scan mode. 14.4.1 Single Mode (SCAN = 0) Single mode should be selected when only one A/D conversion on one channel is required. A/D conversion starts when the ADST bit is set to 1 by software, or by external trigger input.

  • Page 505: Figure 14.3 Example Of A/d Converter Operation (single Mode, Channel 1 Selected)

    Figure 14.3 Example of A/D Converter Operation (Single Mode, Channel 1 Selected)

  • Page 506: Scan Mode (scan = 1)

    14.4.2 Scan Mode (SCAN = 1) Scan mode is useful for monitoring analog inputs in a group of one or more channels. When the ADST bit is set to 1 by software or external trigger input, A/D conversion starts on the first channel in the group (AN when CH2 = 0, AN when CH2 = 1).

  • Page 507

    Figure 14.4 Example of A/D Converter Operation (Scan Mode, Channels AN to AN Selected)

  • Page 508: Input Sampling And A/d Conversion Time

    14.4.3 Input Sampling and A/D Conversion Time The A/D converter has a built-in sample-and-hold circuit. The A/D converter samples the analog input at a time t after the ADST bit is set to 1, then starts conversion. Figure 14.5 shows the A/D conversion timing.

  • Page 509: External Trigger Input Timing

    Table 14.4 A/D Conversion Time (Single Mode) CKS = 0 CKS = 1 Symbol Synchronization delay — — Input sampling time — — — — A/D conversion time — — CONV Note: Values in the table are numbers of states. 14.4.4 External Trigger Input Timing A/D conversion can be externally triggered When the TRGE bit is set to 1 in ADCR and the 8-bit...

  • Page 510

    14.5 Interrupts The A/D converter generates an interrupt (ADI) at the end of A/D conversion. The ADI interrupt request can be enabled or disabled by the ADIE bit in ADCSR. 14.6 Usage Notes When using the A/D converter, note the following points: 1.

  • Page 511: Figure 14.7 Example Of Analog Input Protection Circuit

    100 Ω to AN 0.1 µF Notes: *1 10 µF 0.01 µF *2 Rin: input impedance Figure 14.7 Example of Analog Input Protection Circuit Table 14.5 Analog Input Pin Ratings Item Unit Analog input capacitance — 10 * Allowable signal-source impedance —...