forked from numberformat/helppc_reference_library_html
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHARDWARE.TXT
3329 lines (2858 loc) · 125 KB
/
HARDWARE.TXT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
996
997
998
999
1000
@Hardware Data and Specifications
:6845:CRTC
^6845 - Motorola CRT Controller
3B0-3BB Monochrome Monitor Adapter
3D0-3DC Color Graphics Adapter (mapped similarly)
3B0/3D0 port address decodes to 3B4/3D4
3B1/3D1 port address decodes to 3B5/3D5
3B2/3D2 port address decodes to 3B4/3D4
3B3/3D3 port address decodes to 3B5/3D5
3B4/3D4 6845 index register, selects which register [0-11h]
is to be accessed through port 3B5/3D5
3B5/3D5 6845 data register [0-11h] selected by port 3B4/3D4,
registers 0C-0F may be read. If a read occurs
without the adapter installed, FFh is returned.
3B6/3D6 port address decodes to 3B4/3D4
3B7/3D7 port address decodes to 3B5/3D5
3B8/3D8 6845 mode control register
3B9/3D9 color select register on color adapter
3BA/3DA status register (read only)
3BB/3DB light pen strobe reset
3DC preset light pen latch
3DF CRT/CPU page register (PCjr only)
% Registers: Accessed through ports 3B5 & 3D5 VALID VALUES
% MONO CO40 CO80 GRPH
00 - Horiz. total characters 61 38 71 38
01 - Horiz. displayed characters per line 50 28 50 28
02 - Horiz. synch position 52 2D 5A 2D
03 - Horiz. synch width in characters 0F 0A 0A 0A
04 - Vert. total lines 19 1F 1F 7F
05 - Vert. total adjust (scan lines) 06 06 06 06
06 - Vert. displayed rows 19 19 19 64
07 - Vert. synch position (character rows) 19 1C 1C 70
08 - Interlace mode 02 02 02 02
09 - Maximum scan line address 0D 07 07 01
0A - Cursor start (scan line) 0B 06 06 06
0B - Cursor end (scan line) 0C 07 07 07
0C - Start address (MSB) 00 00 00 00
0D - Start address (LSB) 00 00 00 00
0E - Cursor address (MSB) (read/write) 00 -- -- --
0F - Cursor address (LSB) (read/write) 00 -- -- --
10 - Light pen (MSB) (read only) -- -- -- --
11 - Light pen (LSB) (read only) -- -- -- --
- Registers 00-0D are write only, registers 0E-0F are read/write and
registers 10-11 are read only
- Cursor address is calculated with using the following (row*80)+col
^6845 - Port 3B8 (Monochrome)
³7³6³5³4³3³2³1³0³ 3B8 CRT Control Port
³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄ 1 = 80x25 text
³ ³ ³ ³ ³ ÀÄÁÄÄÄÄÄ unused
³ ³ ³ ³ ÀÄÄÄÄÄÄÄÄ 1 = enable video signal
³ ³ ³ ÀÄÄÄÄÄÄÄÄÄ unused
³ ³ ÀÄÄÄÄÄÄÄÄÄÄ 1 = blinking on
ÀÄÁÄÄÄÄÄÄÄÄÄÄÄ unused
^6845 - Port 3D8 (Color)
³7³6³5³4³3³2³1³0³ 3D8 Mode Select Register
³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄ 1 = 80x25 text, 0 = 40x25 text
³ ³ ³ ³ ³ ³ ÀÄÄÄÄÄ 1 = 320x200 graphics, 0 = text
³ ³ ³ ³ ³ ÀÄÄÄÄÄÄ 1 = B/W, 0 = color
³ ³ ³ ³ ÀÄÄÄÄÄÄÄ 1 = enable video signal
³ ³ ³ ÀÄÄÄÄÄÄÄÄ 1 = 640x200 B/W graphics
³ ³ ÀÄÄÄÄÄÄÄÄÄ 1 = blink, 0 = no blink
ÀÄÁÄÄÄÄÄÄÄÄÄÄ unused
^6845 - Port 3D9 Color Text Modes
³7³6³5³4³3³2³1³0³ 3D9 Color Select Register (3B9 not used)
³ ³ ³ ³ ³ ÀÄÁÄÁÄÄÄÄ screen/border RGB
³ ³ ³ ³ ÀÄÄÄÄÄÄÄÄÄ select intensity setting
³ ³ ³ ÀÄÄÄÄÄÄÄÄÄÄ background intensity
ÀÄÁÄÁÄÄÄÄÄÄÄÄÄÄÄ unused
^6845 - Port 3D9 Color Graphics Modes
³7³6³5³4³3³2³1³0³ 3D9 Color Select Register (3B9 not used)
³ ³ ³ ³ ³ ÀÄÁÄÁÄÄÄÄ RGB for background
³ ³ ³ ³ ÀÄÄÄÄÄÄÄÄÄ intensity
³ ³ ³ ÀÄÄÄÄÄÄÄÄÄÄ unused
³ ³ ÀÄÄÄÄÄÄÄÄÄÄÄ 1 = palette 1, 0=palette 0 (see below)
ÀÄÁÄÄÄÄÄÄÄÄÄÄÄÄ unused
Palette 0 = green, red, brown
Palette 1 = cyan, magenta, white
^6845 - Port 3DA Status Register
³7³6³5³4³3³2³1³0³ 3DA Status Register
³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄ 1 = display enable, RAM access is OK
³ ³ ³ ³ ³ ³ ÀÄÄÄÄÄ 1 = light pen trigger set
³ ³ ³ ³ ³ ÀÄÄÄÄÄÄ 0 = light pen on, 1 = light pen off
³ ³ ³ ³ ÀÄÄÄÄÄÄÄ 1 = vertical retrace, RAM access OK for next 1.25ms
ÀÄÁÄÁÄÁÄÄÄÄÄÄÄÄ unused
:765:FDC:NEC 765:8272:floppy controller
^NEC æPD765 - Floppy Disk Controller - 8272A
% PS/2 FDC Diskette Status Register A at 3F0h
³7³6³5³4³3³2³1³0³ 3F0h PS/2 Disk Status Register A (read-only)
³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄ direction
³ ³ ³ ³ ³ ³ ÀÄÄÄÄÄ write protect
³ ³ ³ ³ ³ ÀÄÄÄÄÄÄ index
³ ³ ³ ³ ÀÄÄÄÄÄÄÄ head 1 select
³ ³ ³ ÀÄÄÄÄÄÄÄÄ track 0
³ ³ ÀÄÄÄÄÄÄÄÄÄ step
³ ÀÄÄÄÄÄÄÄÄÄÄ second drive installed
ÀÄÄÄÄÄÄÄÄÄÄÄ interrupt pending
% PS/2 FDC Diskette Status Register B at 3F1h
³7³6³5³4³3³2³1³0³ 3F1h PS/2 Disk Status Register B (read-only)
³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄ motor enable 0
³ ³ ³ ³ ³ ³ ÀÄÄÄÄ motor enable 1
³ ³ ³ ³ ³ ÀÄÄÄÄ write enable
³ ³ ³ ³ ÀÄÄÄÄ read data (toggles w/positive transition in -RD DATA)
³ ³ ³ ÀÄÄÄÄ write data (toggles w/positive transition in WR DATA)
³ ³ ÀÄÄÄÄ drive select
ÀÄÁÄÄÄÄ reserved
% FDC Digital Output Register at 3F2h (all systems)
³7³6³5³4³3³2³1³0³ port 3F2h (write only)
³ ³ ³ ³ ³ ³ ÀÄÁÄÄÄÄ floppy drive select (0=A, 1=B, 2=floppy C, ...)
³ ³ ³ ³ ³ ÀÄÄÄÄÄÄÄ 1 = FDC enable, 0 = hold FDC at reset
³ ³ ³ ³ ÀÄÄÄÄÄÄÄÄ 1 = DMA & I/O interface enabled (reserved PS/2)
³ ³ ³ ÀÄÄÄÄÄÄÄÄÄ 1 = turn floppy drive A motor on
³ ³ ÀÄÄÄÄÄÄÄÄÄÄ 1 = turn floppy drive B motor on
³ ÀÄÄÄÄÄÄÄÄÄÄÄ 1 = turn floppy drive C motor on; (reserved PS/2)
ÀÄÄÄÄÄÄÄÄÄÄÄÄ 1 = turn floppy drive D motor on; (reserved PS/2)
- used to control drive motors, drive selection, and feature enable
- PS/2 only uses bit 0 for floppy drive select; bit 1 is reserved
- PS/2 only uses bits 5 & 4 for motor enable; bits 7&6 are reserved
- all DOR bits are cleared during controller reset
% FDC Main Status Register at 3F4h (all systems)
³7³6³5³4³3³2³1³0³ port 3F4h (read only)
³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄ floppy drive 0 in seek mode/busy
³ ³ ³ ³ ³ ³ ÀÄÄÄÄÄ floppy drive 1 in seek mode/busy
³ ³ ³ ³ ³ ÀÄÄÄÄÄÄ floppy drive 2 in seek mode/busy (reserved PS/2)
³ ³ ³ ³ ÀÄÄÄÄÄÄÄ floppy drive 3 in seek mode/busy (reserved PS/2)
³ ³ ³ ÀÄÄÄÄÄÄÄÄ FDC read or write command in progress
³ ³ ÀÄÄÄÄÄÄÄÄÄ FDC is in non-DMA mode
³ ÀÄÄÄÄÄÄÄÄÄÄ I/O direction; 1 = FDC to CPU; 0 = CPU to FDC
ÀÄÄÄÄÄÄÄÄÄÄÄ data reg ready for I/O to/from CPU (request for master)
% FDC Command Status Register 0 at 3F5h (all systems)
³7³6³5³4³3³2³1³0³ Command Status Register 0 at port 3F5h
³ ³ ³ ³ ³ ³ ÀÄÁÄÄÄÄ unit selected at interrupt (0=A, 1=B, 2=...)
³ ³ ³ ³ ³ ÀÄÄÄÄÄÄÄ head number at interrupt (head 0 or 1)
³ ³ ³ ³ ÀÄÄÄÄÄÄÄÄ not ready on read/write or SS access to head 1
³ ³ ³ ÀÄÄÄÄÄÄÄÄÄ equipment check (see note)
³ ³ ÀÄÄÄÄÄÄÄÄÄÄ set to 1 when FDD completes a seek command
ÀÄÁÄÄÄÄÄÄÄÄÄÄÄ last command status (see below)
% Bits
% 76 Last Command Status
00 command terminated successfully
01 command execution started but terminated abnormally
10 invalid command issued
11 command terminated abnormally due to a change in state of
the Ready Signal from the FDC (reserved on PS/2)
- equipment check can occur if FDD signals a fault or track zero is
not found after 77 steps on a recalibrate command
- PS/2 only uses bits 1-0 for drive (values are 01b and 10b)
% FDC Command Status Register 1 at 3F5h (all systems)
³7³6³5³4³3³2³1³0³ Command Status Register 1 at port 3F5h
³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄ FDC cannot find ID address mark (see reg 2)
³ ³ ³ ³ ³ ³ ÀÄÄÄÄÄ write protect detected during write
³ ³ ³ ³ ³ ÀÄÄÄÄÄÄ FDC cannot find sector ID
³ ³ ³ ³ ÀÄÄÄÄÄÄÄ unused (always zero)
³ ³ ³ ÀÄÄÄÄÄÄÄÄ over-run; FDC not serviced in reasonable time
³ ³ ÀÄÄÄÄÄÄÄÄÄ data error (CRC) in ID field or data field
³ ÀÄÄÄÄÄÄÄÄÄÄ unused (always zero)
ÀÄÄÄÄÄÄÄÄÄÄÄ end of cylinder; sector# greater than sectors/track
- bit 0 of Status Register 1 and bit 4 of Status Register 2 are
related and mimic each other
% FDC Command Status Register 2 at 3F5h (all systems)
³7³6³5³4³3³2³1³0³ Command Status Register 2 at port 3F5h
³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄ missing address mark in data field
³ ³ ³ ³ ³ ³ ÀÄÄÄÄÄ bad cylinder, ID not found and Cyl Id=FFh
³ ³ ³ ³ ³ ÀÄÄÄÄÄÄ scan command failed, sector not found in cylinder
³ ³ ³ ³ ÀÄÄÄÄÄÄÄ scan command equal condition satisfied
³ ³ ³ ÀÄÄÄÄÄÄÄÄ wrong cylinder detected
³ ³ ÀÄÄÄÄÄÄÄÄÄ CRC error detected in sector data
³ ÀÄÄÄÄÄÄÄÄÄÄ sector with deleted data address mark detected
ÀÄÄÄÄÄÄÄÄÄÄÄ unused (always zero)
- bit 0 of Status Register 1 and bit 4 of Status Register 2 are
related and mimic each other
% FDC Command Status Register 3 at 3F5h (FDD status, all systems)
³7³6³5³4³3³2³1³0³ Floppy Disk Drive Status at port 3F5h
³ ³ ³ ³ ³ ³ ÀÄÁÄÄÄÄ FDD unit selected status (0=A, 1=B, 2=...)
³ ³ ³ ³ ³ ÀÄÄÄÄÄÄÄ FDD side head select status (0=head 0, 1=head 1)
³ ³ ³ ³ ÀÄÄÄÄÄÄÄÄ FDD two sided status signal
³ ³ ³ ÀÄÄÄÄÄÄÄÄÄ FDD track zero status signal
³ ³ ÀÄÄÄÄÄÄÄÄÄÄ FDD ready status signal
³ ÀÄÄÄÄÄÄÄÄÄÄÄ FDD write protect status signal
ÀÄÄÄÄÄÄÄÄÄÄÄÄ FDD fault status signal
% PS/2 FDC Digital Input Register at 3F7h
³7³6³5³4³3³2³1³0³ 3F7h PS/2 Digital Input Register (read only)
³ ³ ³ ³ ³ ³ ³ ÀÄÄÄ high density select
³ ÀÄÁÄÁÄÁÄÁÄÁÄÄÄÄ reserved
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ diskette change
% PS/2 FDC Configuration Control Register at 3F7h
³7³6³5³4³3³2³1³0³ 3F7h PS/2 Config. Control Register (write only)
³ ³ ³ ³ ³ ³ ÀÄÁÄÄ DRC1, DRC0 (see below)
ÀÄÁÄÁÄÁÄÁÄÁÄÄÄÄÄ reserved
DRC1 DRC0
0 0 500000 bit per second mode
0 1 reserved
1 0 250000 bit per second mode
1 1 reserved
- Digital Input Register is used to sense the state of the
(-diskette change) and the (-high density select) signals
- Configuration Control Register is used to set the transfer rate
^FDC Programming Considerations
% Three phases of command execution:
1. Command phase; commands are sent from the CPU to the FDC via
port 3F5h; bit 6 of the Status Register at 3F4h must be zero
2. Execution phase; FDC executes instruction & generates INT 6
3. Result phase; status and other information is available to CPU;
INT 6 sets bit 7 of BIOS Data Area location 40:3E which can
be polled for completion status
% Example of a read operation:
1. turn disk motor on and set delay time for drive spin up
2. perform seek operation; wait for disk interrupt
3. prepare DMA chip to move data to memory
4. send read command and wait for transfer complete interrupt
5. read status information
6. turn disk motor off
^Floppy Diskette Controller Operations (15 commands)
% Read Data D7 D6 D5 D4 D3 D2 D1 D0
command byte 0: MT MF SK 0 0 1 1 0
command byte 1: ? ? ? ? ? HD US1 US0
command byte 2: cylinder number
command byte 3: head number
command byte 4: sector number
command byte 5: bytes per sector
command byte 6: end of track (last sector in track)
command byte 7: gap 3 length
command byte 8: data length (if cmd byte 5==0)
result byte 0: status register 0
result byte 1: status register 1
result byte 2: status register 2
result byte 3: cylinder number
result byte 4: head number
result byte 5: sector number
result byte 6: bytes per sector
% Read Deleted Data D7 D6 D5 D4 D3 D2 D1 D0
command byte 0: MT MF SK 0 1 1 0 0
command byte 1: ? ? ? ? ? HD US1 US0
command byte 2: cylinder number
command byte 3: head number
command byte 4: sector number
command byte 5: bytes per sector
command byte 6: end of track (last sector in track)
command byte 7: gap 3 length
command byte 8: data length (if cmd byte 5==0)
result byte 0: status register 0
result byte 1: status register 1
result byte 2: status register 2
result byte 3: cylinder number
result byte 4: head number
result byte 5: sector number
result byte 6: bytes per sector
% Write Data D7 D6 D5 D4 D3 D2 D1 D0
command byte 0: MT MF 0 0 0 1 0 1
command byte 1: ? ? ? ? ? HD US1 US0
command byte 2: cylinder number
command byte 3: head number
command byte 4: sector number
command byte 5: bytes per sector
command byte 6: end of track (last sector in track)
command byte 7: gap 3 length
command byte 8: data length (if cmd byte 5==0)
result byte 0: status register 0
result byte 1: status register 1
result byte 2: status register 2
result byte 3: cylinder number
result byte 4: head number
result byte 5: sector number
result byte 6: bytes per sector
% Write Deleted Data D7 D6 D5 D4 D3 D2 D1 D0
command byte 0: MT MF 0 0 1 0 0 1
command byte 1: ? ? ? ? ? HD US1 US0
command byte 2: cylinder number
command byte 3: head number
command byte 4: sector number
command byte 5: bytes per sector
command byte 6: end of track (last sector in track)
command byte 7: gap 3 length
command byte 8: data length (if cmd byte 5==0)
result byte 0: status register 0
result byte 1: status register 1
result byte 2: status register 2
result byte 3: cylinder number
result byte 4: head number
result byte 5: sector number
result byte 6: bytes per sector
% Read a Track D7 D6 D5 D4 D3 D2 D1 D0
% (Diagnostic)
command byte 0: 0 MF SK 0 0 0 1 0
command byte 1: ? ? ? ? ? HD US1 US0
command byte 2: cylinder number
command byte 3: head number
command byte 4: sector number
command byte 5: bytes per sector
command byte 6: end of track (last sector in track)
command byte 7: gap 3 length
command byte 8: data length (if cmd byte 5==0)
result byte 0: status register 0
result byte 1: status register 1
result byte 2: status register 2
result byte 3: cylinder number
result byte 4: head number
result byte 5: sector number
result byte 6: bytes per sector
% Read ID D7 D6 D5 D4 D3 D2 D1 D0
command byte 0: 0 MF 0 0 1 0 1 0
command byte 1: ? ? ? ? ? HD US1 US0
result byte 0: status register 0
result byte 1: status register 1
result byte 2: status register 2
result byte 3: cylinder number
result byte 4: head number
result byte 5: sector number
result byte 6: bytes per sector
% Format a Track D7 D6 D5 D4 D3 D2 D1 D0
% (Write Sector IDs)
command byte 0: 0 MF 0 0 1 1 0 1
command byte 1: ? ? ? ? ? HD US1 US0
command byte 2: bytes per sector
command byte 3: sectors per track
command byte 4: gap 3 length
command byte 5: filler pattern to write in each byte
result byte 0: status register 0
result byte 1: status register 1
result byte 2: status register 2
result byte 3: cylinder number
result byte 4: head number
result byte 5: sector number
result byte 6: bytes per sector
% Scan Equal D7 D6 D5 D4 D3 D2 D1 D0
command byte 0: MT MF SK 1 0 0 0 1
command byte 1: ? ? ? ? ? HD US1 US0
command byte 2: cylinder number
command byte 3: head number
command byte 4: sector number
command byte 5: bytes per sector
command byte 6: end of track (last sector in track)
command byte 7: gap 3 length
command byte 8: scan test (1=scan contiguous, 2=scan alternate)
result byte 0: status register 0
result byte 1: status register 1
result byte 2: status register 2
result byte 3: cylinder number
result byte 4: head number
result byte 5: sector number
result byte 6: bytes per sector
% Scan Low or Equal D7 D6 D5 D4 D3 D2 D1 D0
command byte 0: MT MF SK 1 1 0 0 1
command byte 1: ? ? ? ? ? HD US1 US0
command byte 2: cylinder number
command byte 3: head number
command byte 4: sector number
command byte 5: bytes per sector
command byte 6: end of track (last sector in track)
command byte 7: gap 3 length
command byte 8: scan test (1=scan contiguous, 2=scan alternate)
result byte 0: status register 0
result byte 1: status register 1
result byte 2: status register 2
result byte 3: cylinder number
result byte 4: head number
result byte 5: sector number
result byte 6: bytes per sector
% Scan High or Equal D7 D6 D5 D4 D3 D2 D1 D0
command byte 0: MT MF SK 1 1 1 0 1
command byte 1: ? ? ? ? ? HD US1 US0
command byte 2: cylinder number
command byte 3: head number
command byte 4: sector number
command byte 5: bytes per sector
command byte 6: end of track (last sector in track)
command byte 7: gap 3 length
command byte 8: scan test (1=scan contiguous, 2=scan alternate)
result byte 0: status register 0
result byte 1: status register 1
result byte 2: status register 2
result byte 3: cylinder number
result byte 4: head number
result byte 5: sector number
result byte 6: bytes per sector
% Recalibrate D7 D6 D5 D4 D3 D2 D1 D0
command byte 0: 0 0 0 0 0 1 1 1
command byte 1: ? ? ? ? ? 0 US1 US0
returns nothing
% Sense Interrupt D7 D6 D5 D4 D3 D2 D1 D0
% Status
command byte 0: 0 0 0 0 1 0 0 0
result byte 0: status register 0
result byte 1: present cylinder number
% Specify Step & D7 D6 D5 D4 D3 D2 D1 D0
% Head Load
command byte 0: 0 0 0 0 0 0 1 1
command byte 1: step rate time ³ head unload time
command byte 2: ÄÄÄÄÄÄhead load timeÄÄÄÄÄÄ ND
returns nothing
% Sense Drive D7 D6 D5 D4 D3 D2 D1 D0
% Status
command byte 0: 0 0 0 0 0 1 0 0
command byte 1: ? ? ? ? ? HD US1 US0
result byte 0: status register 3
% Seek D7 D6 D5 D4 D3 D2 D1 D0
command byte 0: 0 0 0 0 1 1 1 1
command byte 1: ? ? ? ? ? HD US1 US0
command byte 2: new cylinder number
returns nothing
% æPD765 Version D7 D6 D5 D4 D3 D2 D1 D0
command byte 0: ? ? ? 1 0 0 0 0
result byte 0: status register 0
90h = æPD765B; 80h = æPD765A or æPD765A-2
% Invalid Command
result byte 0: status register 0 (value of 80h)
% Key to Abbreviations
HD = Head Number Selected SK = SKip Deleted-data address mark
MT = Multi-Track US0 = drive select bit 0
MF = MFM mode US1 = drive select bit 1
ND = Non-DMA mode
Head Load Time = 2 to 254ms in 2ms increments
Head Unload Time = 16 to 240ms in 16ms increments
Step Rate Time = 1 to 16ms in 1ms increments
- PS/2 systems use the 8272A diskette controller which is software
and port compatible with the NEC æPD765
- accessed through ports 3F0h-3F7h; NEC æPD765 is accessed through
ports 3F2h, 3F4h and 3F5h; the 8272A uses ports 3F0h, 3F1h,
3F2h, 3F4h, 3F5h and 3F7h
- data, command and status registers are all accessed through
port 3F5h a register stack with one address presented to the bus
- bit 7 of BIOS Data Area byte 40:3E can be polled to determine
if a disk operation has completed; this bit is set by the
interrupt handler when the operation has completed; it should
be reset before continuing on with the next FDC operation
- see ~BIOS Data Area~ ~INT TABLE~ ~INT 13~
:8042:keyboard controller
^8042 - Keyboard Controller (AT,PS/2)
% 8042 Status Register (port 64h read)
³7³6³5³4³3³2³1³0³ 8042 Status Register
³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄ output register (60h) has data for system
³ ³ ³ ³ ³ ³ ÀÄÄÄÄÄ input register (60h/64h) has data for 8042
³ ³ ³ ³ ³ ÀÄÄÄÄÄÄ system flag (set to 0 after power on reset)
³ ³ ³ ³ ÀÄÄÄÄÄÄÄ data in input register is command (1) or data (0)
³ ³ ³ ÀÄÄÄÄÄÄÄÄ 1=keyboard enabled, 0=keyboard disabled (via switch)
³ ³ ÀÄÄÄÄÄÄÄÄÄ 1=transmit timeout (data transmit not complete)
³ ÀÄÄÄÄÄÄÄÄÄÄ 1=receive timeout (data transmit not complete)
ÀÄÄÄÄÄÄÄÄÄÄÄ 1=even parity rec'd, 0=odd parity rec'd (should be odd)
% Port Mode Description
64h read 8042 status register. Can be read at any time. See
table above for more information.
64h write 8042 command register. Writing this port sets Bit 3
of the status register to 1 and the byte is treated
as a controller command. Devices attached to the
8042 should be disabled before issuing commands that
return data since data in the output register will
be overwritten.
60h read 8042 output register (should only be read if Bit 0 of
status port is set to 1)
60h write 8042 data register. Data should only be written if
Bit 1 of the status register is zero (register is empty).
When this port is written Bit 3 of the status register
is set to zero and the byte is treated as a data. The
8042 uses this byte if it's expecting data for a previous
command, otherwise the data is written directly to the
keyboard. See ~KEYBOARD COMMANDS~ for information on
programming the actual keyboard hardware.
^8042 Commands Related to PC Systems (Port 64h)
% Command Description
20 Read 8042 Command Byte: current 8042 command byte is placed
in port 60h.
60 Write 8042 Command Byte: next data byte written to port 60h is
placed in 8042 command register. Format:
³7³6³5³4³3³2³1³0³ 8042 Command Byte
³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄ 1=enable output register full interrupt
³ ³ ³ ³ ³ ³ ÀÄÄÄÄÄ should be 0
³ ³ ³ ³ ³ ÀÄÄÄÄÄÄ 1=set status register system, 0=clear
³ ³ ³ ³ ÀÄÄÄÄÄÄÄ 1=override keyboard inhibit, 0=allow inhibit
³ ³ ³ ÀÄÄÄÄÄÄÄÄ disable keyboard I/O by driving clock line low
³ ³ ÀÄÄÄÄÄÄÄÄÄ disable auxiliary device, drives clock line low
³ ÀÄÄÄÄÄÄÄÄÄÄ IBM scancode translation 0=AT, 1=PC/XT
ÀÄÄÄÄÄÄÄÄÄÄÄ reserved, should be 0
A4 Password Installed Test: returned data can be read
from port 60h; FA=password installed, F1=no password
A5 Load Security: bytes written to port 60h will be read
until a null (0) is found.
A6 Enable Security: works only if a password is already loaded
A7 Disable Auxiliary Interface: sets Bit 5 of command register
stopping auxiliary I/O by driving the clock line low
A8 Enable Auxiliary Interface: clears Bit 5 of command register
A9 Auxiliary Interface Test: clock and data lines are tested;
results placed at port 60h are listed below:
00 no error
01 keyboard clock line is stuck low
02 keyboard clock line is stuck high
03 keyboard data line is stuck low
04 keyboard data line is stuck high
AA Self Test: diagnostic result placed at port 60h, 55h=OK
AB Keyboard Interface Test: clock and data lines are tested;
results placed at port 60h are listed above with command A9
AC Diagnostic Dump: sends 16 bytes of 8042's RAM, current input
port state, current output port state and 8042 program status
word to port 60h in scan-code format.
AD Disable Keyboard Interface: sets Bit 4 of command register
stopping keyboard I/O by driving the clock line low
AE Enable Keyboard Interface: clears Bit 4 of command register
enabling keyboard interface.
C0 Read Input Port: data is read from its input port (which is
inaccessible to the data bus) and written to output register
at port 60h; output register should be empty before call.
³7³6³5³4³3-0³ 8042 Input Port
³ ³ ³ ³ ÀÄÄÄÄ undefined
³ ³ ³ ÀÄÄÄÄÄ 1=enable 2nd 256K of motherboard RAM, 0=disable
³ ³ ÀÄÄÄÄÄÄ 1=manufacturing jumper not installed, 0=installed
³ ÀÄÄÄÄÄÄÄ 1=primary display is MDA, 0=primary display is CGA
ÀÄÄÄÄÄÄÄÄ 1=keyboard not inhibited, 0=keyboard inhibited
C1 Poll Input Port Low Bits: Bits 0-3 of port 1 placed in
status Bits 4-7
C2 Poll Input Port High Bits: Bits 4-7 of port 1 placed in
status Bits 4-7
D0 Read Output Port: data is read from 8042 output port (which is
inaccessible to the data bus) and placed in output register;
the output register should be empty. (see command D1 below)
D1 Write Output Port: next byte written to port 60h is placed in
the 8042 output port (which is inaccessible to the data bus)
³7³6³5³4³3³2³1³0³ 8042 Output Port
³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄ system reset line
³ ³ ³ ³ ³ ³ ÀÄÄÄÄÄ gate A20
³ ³ ³ ³ ÀÄÁÄÄÄÄÄÄ undefined
³ ³ ³ ÀÄÄÄÄÄÄÄÄÄ output buffer full
³ ³ ÀÄÄÄÄÄÄÄÄÄÄ input buffer empty
³ ÀÄÄÄÄÄÄÄÄÄÄÄ keyboard clock (output)
ÀÄÄÄÄÄÄÄÄÄÄÄÄ keyboard data (output)
D2 Write Keyboard Output Register: on PS/2 systems the next data
byte written to port 60h input register is written to port 60h
output register as if initiated by a device; invokes interrupt
if enabled
D3 Write Auxiliary Output Register: on PS/2 systems the next data
byte written to port 60h input register is written to port 60h
output register as if initiated by a device; invokes interrupt
if enabled
D4 Write Auxiliary Device: on PS/2 systems the next data byte
written to input register a port at 60h is sent to the
auxiliary device
E0 Read Test Inputs: 8042 reads its T0 and T1 inputs; data is
placed in output register; Bit 0 is T0, Bit 1 is T1:
³1³0³ Test Input Port Bits
³ ÀÄÄÄÄ keyboard clock
ÀÄÄÄÄÄ keyboard data
Fx Pulse Output Port: Bits 0-3 of the 8042 output port can be
pulsed low for 6 æs; Bits 0-3 of command indicate which
Bits should be pulsed; 0=pulse, 1=don't pulse; pulsing
Bit 0 results in CPU reset since it is connected to system
reset line.
- PC systems previous to the AT use the 8255 PPI as a keyboard
controller and use the keyboard's internal 8048.
- the keyboard's internal controller buffers up to 16 bytes of
make/break code information. This is common among all PC systems
and shouldn't be confused with the (32 byte) keyboard buffer
maintained by the BIOS.
- see ~KEYBOARD COMMANDS~ for information on programming the
keyboards internal microprocessor
:8250:16450:16550:UART
^UART - Universal Asynchronous Receiver/Transmitter
% Port Description
3F8/2F8 Transmit/Receive Buffer (read/write)
Baud Rate Divisor LSB if bit 7 of LCR is set (read/write)
3F9/2F9 IER - Interrupt Enable Register (read/write)
Baud Rate Divisor MSB if bit 7 of LCR is set (read/write)
3FA/2FA IIR - Interrupt Identification Register (read only)
FCR - 16550 FIFO Control Register (write only)
3FB/2FB LCR - Line Control Register (read/write)
3FC/2FC MCR - Modem Control Register (read/write)
3FD/2FD LSR - Line Status Register (read only)
3FE/2FE MSR - Modem Status Register (read only)
3FF/2FF Scratch Pad Register (read/write)
^Detailed UART Description
% Port 3F8 - Transmit/Receive Buffer (read/write)
% Baud Rate Divisor LSB if bit 7 of LCR is set (read/write)
% Port 3F9 - Interrupt Enable Register - IER (read/write)
% Baud Rate Divisor MSB if bit 7 of LCR is set (read/write)
³7³6³5³4³3³2³1³0³ 2F9, 3F9: Interrupt Enable Register
³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄ 1 = enable data available int (and 16550 Timeout)
³ ³ ³ ³ ³ ³ ÀÄÄÄÄÄ 1 = enable THRE interrupt
³ ³ ³ ³ ³ ÀÄÄÄÄÄÄ 1 = enable lines status interrupt
³ ³ ³ ³ ÀÄÄÄÄÄÄÄ 1 = enable modem-status-change interrupt
ÀÄÁÄÁÄÁÄÄÄÄÄÄÄÄ reserved (zero)
- 16550 will interrupt if data exists in the FIFO and isn't read
within the time it takes to receive four bytes or if no data is
received within the time it takes to receive four bytes.
^Baud Rate Divisor Table
% Baud Rate Baud Rate
% Baud Rate Divisor Baud Rate Divisor
50 900h 2400 30h
110 417h 3600 20h
150 300h 4800 18h
300 180h 7200 10h
600 C0h 9600 0Ch
1200 60h 19200 06h
1800 40h 38400 03h
2000 3Ah 115200 01h
- Baud rate divisors can be calculated by taking the oscillating
frequency (1,843,200) and dividing by the quantity of the desired
baud rate times the UART clocking factor (16). Use the following
formula:
^divisor = 1843200 / (BaudRate * 16);
^Port 3FA - Interrupt Identification Register - IIR (read only)
³7³6³5³4³3³2³1³0³ 2FA, 3FA Interrupt ID Register
³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄ 1 = no int. pending, 0=int. pending
³ ³ ³ ³ ³ ÀÄÁÄÄÄÄÄ Interrupt Id bits (see below)
³ ³ ³ ³ ÀÄÄÄÄÄÄÄÄ 16550 1 = timeout int. pending, 0 for 8250/16450
³ ³ ÀÄÁÄÄÄÄÄÄÄÄÄ reserved (zero)
ÀÄÁÄÄÄÄÄÄÄÄÄÄÄÄ 16550 set to 1 if FIFO queues are enabled
% Bits
% 21 Meaning Priority To reset
00 modem-status-change lowest read MSR
01 transmit-register-empty low read IIR / write THR
10 data-available high read rec buffer reg
11 line-status highest read LSR
- interrupt pending flag uses reverse logic, 0 = pending, 1 = none
- interrupt will occur if any of the line status bits are set
- THRE bit is set when THRE register is emptied into the TSR
^Port 3FA - 16550 FIFO Control Register - FCR (write only)
³7³6³5³4³3³2³1³0³ 2FA, 3FA FIFO Control Register
³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄ 1 = enable clear XMIT and RCVR FIFO queues
³ ³ ³ ³ ³ ³ ÀÄÄÄÄÄ 1 = clear RCVR FIFO
³ ³ ³ ³ ³ ÀÄÄÄÄÄÄ 1 = clear XMIT FIFO
³ ³ ³ ³ ÀÄÄÄÄÄÄÄ 1 = change RXRDY & TXRDY pins from mode 0 to mode 1
³ ³ ÀÄÁÄÄÄÄÄÄÄÄ reserved (zero)
ÀÄÁÄÄÄÄÄÄÄÄÄÄÄ trigger level for RCVR FIFO interrupt
% Bits RCVR FIFO
% 76 Trigger Level
00 1 byte
01 4 bytes
10 8 bytes
11 14 bytes
- Bit 0 must be set in order to write to other FCR bits
- Bit 1 when set to 1 the RCVR FIFO is cleared and this bit is reset.
The receiver shift register is not cleared.
- Bit 2 when set to 1 the XMIT FIFO is cleared and this bit is reset.
The transmit shift register is not cleared.
^Port 3FB - Line Control Register - LCR (read/write)
³7³6³5³4³3³2³1³0³ 2FB, 3FB Line Control Register
³ ³ ³ ³ ³ ³ ÀÄÁÄÄÄÄ word length select bits (see below)
³ ³ ³ ³ ³ ÀÄÄÄÄÄÄÄ 0 = 1 stop bit, 1 = 1.5 or 2 (see note)
³ ³ ³ ³ ÀÄÄÄÄÄÄÄÄ 0 = no parity, 1 = parity (PEN)
³ ³ ³ ÀÄÄÄÄÄÄÄÄÄ 0 = odd parity, 1 = even (EPS)
³ ³ ÀÄÄÄÄÄÄÄÄÄÄ 0 = parity disabled, 1 = enabled
³ ÀÄÄÄÄÄÄÄÄÄÄÄ 0 = turn break off, 1 = force spacing break state
ÀÄÄÄÄÄÄÄÄÄÄÄÄ 1 = baud rate divisor (DLAB); 0 = RBR, THR or IER
% Bits
% 10 Word length bits
00 = 5 bits per character
01 = 6 bits per character
10 = 7 bits per character
11 = 8 bits per character
- stop bits = 1.5 for 5 bit words or 2 for 6, 7 or 8 bit words
- bit 7 changes the mode of registers 3F8 and 3F9. If set these
registers become the LSB and MSB of the baud rate divisor.
Otherwise 3F8 is the Transmit/Receive Buffer Register and 3F9 is
the Interrupt Enable Register.
^Port 3FC - Modem Control Register - MCR (read/write)
³7³6³5³4³3³2³1³0³ 2FC, 3FC Modem Control Register
³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄ 1 = activate DTR
³ ³ ³ ³ ³ ³ ÀÄÄÄÄÄ 1 = activate RTS
³ ³ ³ ³ ³ ÀÄÄÄÄÄÄ OUT1
³ ³ ³ ³ ÀÄÄÄÄÄÄÄ OUT2
³ ³ ³ ÀÄÄÄÄÄÄÄÄ 0 = normal, 1 = loop back test
ÀÄÁÄÁÄÄÄÄÄÄÄÄÄ reserved (zero)
- If bit 4 is set, data from the Transmit Shift Register is received
in the Receiver Shift Register. The SOUT line is set to logic
high, the SIN line and control lines are disconnected. CTS, DSR,
RI and CD inputs are disconnected. DTR, RTS, OUT1 and OUT2 are
then connected internally.
^Port 3FD - Line Status Register - LSR (read only)
³7³6³5³4³3³2³1³0³ 2FD, 3FD Line Status Register
³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄ 1 = data ready
³ ³ ³ ³ ³ ³ ÀÄÄÄÄÄ 1 = overrun error (OE)
³ ³ ³ ³ ³ ÀÄÄÄÄÄÄ 1 = parity error (PE)
³ ³ ³ ³ ÀÄÄÄÄÄÄÄ 1 = framing error (FE)
³ ³ ³ ÀÄÄÄÄÄÄÄÄ 1 = break interrupt (BI)
³ ³ ÀÄÄÄÄÄÄÄÄÄ 1 = transmitter holding register empty (THRE)
³ ÀÄÄÄÄÄÄÄÄÄÄ 1 = transmitter shift register empty (TSRE)
ÀÄÄÄÄÄÄÄÄÄÄÄ 1 = 16550 PE/FE/Break in FIFO queue, 0 for 8250 & 16450
- Bit 0 is set when a byte is placed in the Receiver Buffer Register
and cleared when the byte is read by the CPU (or when the CPU
clears the FIFO for the 16550). Results in Receive Data Available
Interrupts if enabled.
- Bits 1-4 indicate errors and result in Line Status Interrupts
if enabled.
- Bit 1 is set when a second byte is received before the byte
in the Receiver Buffer Register is read by the CPU (the 16550 in
FIFO mode sets this bit when the queue is full and the byte in the
Receiver Shift Register hasn't been moved into the queue). This
bit is reset when the CPU reads the LSR
- Bit 2 is set whenever a byte is received that doesn't match the
requested parity. Reset upon reading the LSR. (The 16550 maintains
parity information with each byte and sets bit 2 only when the byte
is at the top of the FIFO queue.)
- Bit 3 is set when a character is received without proper stop
bits. Upon detecting a framing error the UART attempts to
resynchronize. Reset by reading the LSR. (The 16550 maintains
this information with each byte and sets bit 3 only when the byte
is at the top of the FIFO queue.)
- Bit 4 is set when a break condition is sensed (when space is
detected for longer than 1 fullword). A zero byte is placed in
the Receiver Buffer Register (or 16550 FIFO). Reset by reading
the LSR. (The 16550 maintains this information with each byte and
sets bit 4 only when the byte is at the top of the FIFO queue.)
- Bit 5 is set when the Transmit Holding Register shifts a byte
into the Transmit Shift Register (or XMIT FIFO queue is empty for
16550) and is cleared when a byte is written to the THR (or the
XMIT FIFO). Results in Transmit Holding Register Empty interrupts
if enabled.
- Bit 6 is set when both the Transmitter Holding Register and the
Transmitter Shift Register are empty. On the 16550, when the XMIT
FIFO and Transmitter Shift Register are empty.
- Bit 7 is 16550 specific and indicates there is a byte in the FIFO
queue that was received with a Parity, Framing or Break error.
^Port 3FE - Modem Status Register - MSR (read only)
³7³6³5³4³3³2³1³0³ 2FE, 3FE Modem Status Register
³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄ 1 = DCTS Delta CTS (CTS changed)
³ ³ ³ ³ ³ ³ ÀÄÄÄÄÄ 1 = DDSR Delta DSR (DSR changed)
³ ³ ³ ³ ³ ÀÄÄÄÄÄÄ 1 = RI ring indicator changed
³ ³ ³ ³ ÀÄÄÄÄÄÄÄ 1 = DDCD Delta Data Carrier Detect (DCD changed)
³ ³ ³ ÀÄÄÄÄÄÄÄÄ 1 = CTS
³ ³ ÀÄÄÄÄÄÄÄÄÄ 1 = DSR
³ ÀÄÄÄÄÄÄÄÄÄÄ 1 = ring indicator (RI)
ÀÄÄÄÄÄÄÄÄÄÄÄ 1 = receive line signal detect
- Bits 0-3 are reset when the CPU reads the MSR
- Bit 4 is the Modem Control Register RTS during loopback test
- Bit 5 is the Modem Control Register DTR during loopback test
- Bit 6 is the Modem Control Register OUT1 during loopback test
- Bit 7 is the Modem Control Register OUT2 during loopback test
^Port 3FF/2FF - Scratch Pad Register (read/write)
% Programming considerations:
- 8250's, 16450's are essentially identical to program
- 16550's is pin and software compatible with the 16450 but has an
internal FIFO queue that may be enabled/disabled by software
- PCs are capable of 38.4Kb, while AT's are capable of 115.2Kb
- receiver checks only the first stop bit of each character regardless
of the number of stop bits specified
- Older 8250 and 16450 UARTs may lose THRE interrupt if the THRE and
Receive Data (RD) or the Line Status (LS) interrupts occur
simultaneously during a full duplex transmission. RD and LS have
higher priority than THRE which causes the lower priority interrupt
to be lost. The following are 3 methods used to avoid this problem:
1. Disable/re-enable THRE interrupt via the IER after processing
Receive Data & Line Status interrupts.
2. While inside the RD and LS interrupt routines check the LSR
THRE bit and set a flag that a THRE interrupt was waiting.
3. Poll the LSR THRE bit instead of using the IRR.
- data loss can occur without overrun or framing errors if the
interrupts are serviced too slowly
- reserved bits are usually set to zero. Code should NOT rely on
this being the case since future enhancement may use these bits
- see ~INT TABLE~ or ~IRQ~ for interrupt assignments
- see ~PORTS~ for COMx port assignment (3F8,2F8,3E8,2E8,3220...)
:8253:8254:PIT:timer
^8253/8254 PIT - Programmable Interval Timer
Port 40h, 8253 Counter 0 Time of Day Clock (normally mode 3)
Port 41h, 8253 Counter 1 RAM Refresh Counter (normally mode 2)
Port 42h, 8253 Counter 2 Cassette and Speaker Functions
Port 43h, 8253 Mode Control Register, data format:
³7³6³5³4³3³2³1³0³ Mode Control Register
³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄ 0=16 binary counter, 1=4 decade BCD counter
³ ³ ³ ³ ÀÄÁÄÁÄÄÄÄÄ counter mode bits
³ ³ ÀÄÁÄÄÄÄÄÄÄÄÄÄ read/write/latch format bits
ÀÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄ counter select bits (also 8254 read back command)
% Bits
% 76 Counter Select Bits
00 select counter 0
01 select counter 1
10 select counter 2
11 read back command (8254 only, illegal on 8253, see below)
% Bits
% 54 Read/Write/Latch Format Bits
00 latch present counter value
01 read/write of MSB only
10 read/write of LSB only
11 read/write LSB, followed by write of MSB
% Bits
% 321 Counter Mode Bits
000 mode 0, interrupt on terminal count; countdown, interrupt,
then wait for a new mode or count; loading a new count in the
middle of a count stops the countdown
001 mode 1, programmable one-shot; countdown with optional
restart; reloading the counter will not affect the countdown
until after the following trigger
010 mode 2, rate generator; generate one pulse after 'count' CLK
cycles; output remains high until after the new countdown has
begun; reloading the count mid-period does not take affect
until after the period
011 mode 3, square wave rate generator; generate one pulse after
'count' CLK cycles; output remains high until 1/2 of the next
countdown; it does this by decrementing by 2 until zero, at
which time it lowers the output signal, reloads the counter
and counts down again until interrupting at 0; reloading the
count mid-period does not take affect until after the period
100 mode 4, software triggered strobe; countdown with output high
until counter zero; at zero output goes low for one CLK
period; countdown is triggered by loading counter; reloading
counter takes effect on next CLK pulse
101 mode 5, hardware triggered strobe; countdown after triggering
with output high until counter zero; at zero output goes low
for one CLK period
% Read Back Command Format (8254 only)
³7³6³5³4³3³2³1³0³ Read Back Command (written to Mode Control Reg)
³ ³ ³ ³ ³ ³ ³ ÀÄÄÄ must be zero
³ ³ ³ ³ ³ ³ ÀÄÄÄÄ select counter 0
³ ³ ³ ³ ³ ÀÄÄÄÄÄ select counter 1
³ ³ ³ ³ ÀÄÄÄÄÄÄ select counter 2
³ ³ ³ ÀÄÄÄÄÄÄÄ 0 = latch status of selected counters
³ ³ ÀÄÄÄÄÄÄÄÄ 0 = latch count of selected counters
ÀÄÁÄÄÄÄÄÄÄÄÄ 11 = read back command
% Read Back Command Status (8254 only, read from counter register)
³7³6³5³4³3³2³1³0³ Read Back Command Status
³ ³ ³ ³ ³ ³ ³ ÀÄÄÄ 0=16 binary counter, 1=4 decade BCD counter
³ ³ ³ ³ ÀÄÁÄÁÄÄÄÄ counter mode bits (see Mode Control Reg above)
³ ³ ÀÄÁÄÄÄÄÄÄÄÄÄ read/write/latch format (see Mode Control Reg)
³ ÀÄÄÄÄÄÄÄÄÄÄÄÄ 1=null count (no count set), 0=count available
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄ state of OUT pin (1=high, 0=low)
- the 8253 is used on the PC & XT, while the 8254 is used on the AT+
- all counters are decrementing and fully independent
- the PIT is tied to 3 clock lines all generating 1.19318 MHz.
- the value of 1.19318MHz is derived from (4.77/4 MHz) and has it's
roots based on NTSC frequencies
- counters are 16 bit quantities which are decremented and then
tested against zero. Valid range is (0-65535). To get a value
of 65536 clocks you must specify 0 as the default count since
65536 is a 17 bit value.
- reading by latching the count doesn't disturb the countdown but
reading the port directly does; except when using the 8254 Read
Back Command
- counter 0 is the time of day interrupt and is generated
approximately 18.2 times per sec. The value 18.2 is derived from
the frequency 1.10318/65536 (the normal default count).
- counter 1 is normally set to 18 (dec.) and signals the 8237 to do
a RAM refresh approximately every 15æs
- counter 2 is normally used to generate tones from the speaker
but can be used as a regular counter when used in conjunction
with the 8255
- newly loaded counters don't take effect until after a an output
pulse or input CLK cycle depending on the mode
- the 8253 has a max input clock rate of 2.6MHz, the 8254 has max
input clock rate of 10MHz
% Programming considerations: