Texas Instruments TMS320C3x User Manual

Page 454

Advertising
background image

DMA Controller

12-75

Peripherals

Example 12–8. Array Initialization With DMA

* TITLE: ARRAY INITIALIZATION WITH DMA
*
.GLOBAL START
.DATA
DMA .WORD 808000H

; DMA GLOBAL-CONTROL REG ADDRESS

RESET .WORD 0C40H

; DMA GLOBAL-CONTROL REG RESET VALUE

CONTROL .WORD 0C43H

; DMA GLOBAL-CONTROL REG INITIALIZATION

SOURCE .WORD ZERO

; DATA SOURCE ADDRESS

DESTIN .WORD _ARRAY

; DATA DESTINATION ADDRESS

COUNT .WORD 128

; NUMBER OF WORDS TO TRANSFER

ZERO .FLOAT 0.0

; ARRAY INITIALIZATION VALUE 0.0 = 0x80000000

.BSS _ARRAY,128

; DATA ARRAY LOCATED IN .BSS SECTION

.TEXT

START LDP DMA

; LOAD DATA PAGE POINTER

LDI @DMA,AR0

; POINT TO DMA GLOBAL CONTROL REGISTER

LDI @RESET,R0

; RESET DMA

STI R0,*AR0
LDI @SOURCE,R0

; INITIALIZE DMA SOURCE-ADDRESS REGISTER

STI R0,*+AR0(4)
LDI @DESTIN,R0

; INITIALIZE DMA DESTINATION-ADDRESS REGISTER

STI R0,*+AR0(6)
LDI @COUNT,R0

; INITIALIZE DMA TRANSFER COUNTER REGISTER

STI R0,*+AR0(8)
OR 400H,IE

; ENABLE INTERRUPT FROM DMA TO CPU

OR 2000H,ST

; ENABLE CPU INTERRUPTS GLOBALLY

LDI @CONTROL,R0

; INITIALIZE DMA GLOBAL CONTROL REGISTER

STI R0,*AR0

; START DMA TRANSFER

BU $
.END

Example 12–9 sets up the DMA to transfer data (128 words) from the serial
port 0 input register to an array buffer with serial port receive interrupt (RINT0).
The DMA sends an interrupt to the CPU when the data transfer completes.

Serial port 0 is initialized to receive 32-bit data words with an internally generated
receive-bit clock and a bit-transfer rate of 8H1 cycles/bit.

This program assumes previous initialization of the CPU interrupt vector table
(specifically the DMA-to-CPU interrupt). The serial port interrupt directly affects
only the DMA; no CPU serial-port interrupt-vector setting is required.

Advertising