Lecture-14 (DMA)
Lecture-14 (DMA)
3
Lecture 14
4
Lecture 14
5
Lecture 14
8237 DMA Controller PIN out
6
Lecture 14
8237 DMA Controller PIN out
7
Lecture 14
8237 Internal Registers &
Programming DMA Controller
CAR: The current address register holds a 16-bit memory address used
for the DMA transfer; each channel has its own current address register
for this purpose
CWCR: The current word count register programs, a channel for the
number of bytes (up to 64K) transferred during a DMA action. The
number loaded into this register is one less than the number of bytes
transferred.
BA and BWC : The base address (BA) and base word count (BWC)
registers are used when auto-initialization is selected for a channel. In
auto-initialization mode, these registers are used to reload the CAR and
CWCR after the DMA action is completed.
CR: The command register programs the operation of the 8237 DMA
controller.
8
Lecture 14 The Command register (CR)
The CR programs the operation of the 8237 DMA controller.
10
Lecture 14 The mode register (MR)
The mode register programs the mode of operation for a channel.
• Demand mode: until an external EOP is input or DREQ input becomes inactive.
• Single mode: release Hold after each byte of data transferred.
• Block mode: automatically transfers the number of bytes indicated by the count
register
• Cascade mode: is used when more than one DMA is present in the system.
11
Lecture 14
The bus request register
The bus request register is used to request a DMA transfer via software.
12
Lecture 14 The MSR (Model-Specific Register) request register
The MSR register clears or sets all of the masks with one command
instead of individual channels, as with the MRSR
The TC bits indicate if the channel has reached its terminal count (transferred all its bytes). 13
Lecture 14
More than one 8237 Connected to Microprocessor
14
Lecture 14
8237 System Interface
Latch B
A16-A31
17
Programming the Address and Count Registers
The table below shows I/O port locations for programming the
count and address registers for each channel.
18
Lecture 14
Four steps are required to program the 8237
Example:
Interfacing DMA 8237 Controller to 80386 Microprocessor at I/O
ports 0700H- 07F0H for DMA controller and I/O ports 0100H-
01F0H for latch B.
19
Lecture 14 I/O ports 0700H- 07F0H
A11 A10 A9 A8 A7 A6 A5 A4
790
7B0
780
7E0
7F0
7C0
100
700
720
730
20
Lecture 14
Sample Memory-to-Memory DMA Transfer
Suppose contents of memory locations 10000H–13FFFH are to be
transferred to locations 14000H–17FFFH. (Real Mode).
Shows the software required to initialize the 8237 and program
latch B in the block diagram indicated above for this DMA
transfer
; Calling parameter
; SI = Source address;
; DI = destination address;
; Cx = Count
; ES = Segment of source and destination
21
Lecture 14
22
Lecture 14
; Program Latch
MOV AX, ES
MOV AL, AH
SHR AL, 4
OUT LatchB, AL
; Clear F/L;
OUT Clear_F, AL
23
Lecture 14
; Program Destination Address
MOV AX, ES
SHL AX, 4
ADD AX, DI
OUT Ch 1_A, AL
MOV AL, AH
OUT Ch 1_A, AL
; Program Count
MOV AX, CX
DEC AX
OUT Ch 1_C, AL
MOV AL, AH
OUT Ch 1_C, AL
24
Lecture 14
; Program Mode
MOV AX, 88H
OUT MODE, AL
MOV AL, 85H
OUT MODE, AL
; Unmask Channel 0
MOV AX, 0EH
OUT MASKS, AL
25
Lecture 14
26