[INTEL NAVIGATION HEADER]

Setup DMA: Perform Memory -> I/O Space Xfer

Setup DMA: Perform Memory -> I/O Space Xfer

$MOD186
NAME	DMA_EXAMPLE_1
; This example sets up the DMA Unit
; to perform a memory to I/O space
; transfer every 22uS. The data is
; sent to an A/D converter.
; It is assumed that the constants for PCB register
; addresses are defined elsewhere with EQUates.
; (Works for 80C186EA and EC family of Microcontrollers)
CODE_SEG SEGMENT 
 ASSUME CS:CODE_SEG
 
START: MOV AX, DATA_SEG ; DATA SEGMENT POINTER
 MOV DS, AX
 ASSUME DS:DATA_SEG
 
; First, setup the pointers. The source is in memory.
 MOV AX, SEG WAVEFORM_DATA
 ROL AX, 4	 	; GET HIGH 4 BITS
		MOV	BX, AX		; SAVE ROTATED VALUE
		AND	AX, 0FFF0H	; GET SHIFTED LOW 4
					; NIBBLES
		ADD	AX, OFFSET WAVEFORM_DATA
		; NOW LOW BYTES OF
		; POINTER ARE IN AX
		ADC	BX, 0		; ADD IN THE CARRY
					; TO THE HIGH NIBBLE
		AND	BX, 000FH	; GET JUST THE HIGH 
					; NIBBLE
		MOV	DX, D0SRCL
		OUT	DX, AX		; AX=LOW 4 BYTES
		MOV	DX, D0SRCH
		MOV	AX, BX		; GET HIGH NIBBLE
		OUT	DX, AX
 MOV AX, DA_CNVTR; I/O ADDRESS OF D/A
		MOV	DX, D0DSTL
		OUT	DX, AX		;
		MOV	DX, D0DSTH
		XOR AX, AX		; CLEAR HIGH NIBBLE
		OUT	DX, AX
		; THE POINTER ADDRESSES HAVE BEEN SET UP. NOW
		; WE SET UP THE TRANSFER COUNT.
		MOV	AX, 255		; 8-BIT D/A SO
					; WE SEND 256 BYTES
		MOV	DX, D0TC	; TO GET A FULL SCALE
		OUT	DX, AX
		; NOW WE NEED TO SET THE PARAMETERS FOR
		; THE CHANNEL AS FOLLOWS:
		;
		;	DESTINATION	SOURCE
		;	-----------	------
		;	I/O SPACE	MEMORY SPACE
		;	CONSTANT PTR	INCREMENT PTR
		;	
		; TERMINATE ON TC, INTERRUPT, SOURCE SYNCHRONIZE,
 ; INTERNAL REQUESTS,
		; LOW PRIORITY RELATIVE TO CHANNEL 1, BYTE XFERS.
		MOV	AX, 0001011101010110B
		MOV	DX, D0CON
		OUT	DX, AX
 ; NOW WE ASSUME THAT TIMER 2 HAS BEEN PROPERLY 
 ; PROGRAMMED FOR A 22US DELAY.
 ; WHEN THE TIMER IS STARTED, A DMA
 ; TRANSFER WILL OCCUR EVERY 22US.
CODE_SEG ENDS
DATA_SEG SEGMENT
WAVEFORM_DATA DB 0,1,2,3,4,5,6,7,8,9,10,11,12,13
 DB 14,15,16,17,18,19,20,21,22,23,24
 
 ; ETC. UP TO 255
DATA_SEG ENDS
 END START
Free Web Hosting



Legal Stuff © 1997 Intel Corporation