SPRUI30H November 2015 – May 2024 DRA745 , DRA746 , DRA750 , DRA756
To program a software-triggered DMA transfer:
The following example performs a DMA transfer on channel 10 of a 240*160 picture from RAM to RAM (0x80C00000 to 0x80F00000):
UWORD32 RegVal = 0;
DMA4_t *DMA4;
DMA4 = (DMA4_t
*)malloc(sizeof(DMA4_t));
/* Init. parameters
*/
DMA4->DataType = 0x2; //
DMA4_CSDPi[1:0]
DMA4->ReadPortAccessType = 0; //
DMA4_CSDPi[8:7]
DMA4->WritePortAccessType = 0; //
DMA4_CSDPi[15:14]
DMA4->SourceEndiansim = 0; //
DMA4_CSDPi[21]
DMA4->DestinationEndianism = 0; //
DMA4_CSDPi[19]
DMA4->WriteMode = 0; //
DMA4_CSDPi[17:16]
DMA4->SourcePacked = 0; //
DMA4_CSDPi[6]
DMA4->DestinationPacked = 0; //
DMA4_CSDPi[13]
DMA4->NumberOfElementPerFrame = 240; //
DMA4_CENi
DMA4->NumberOfFramePerTransferBlock = 160; //
DMA4_CFNi
DMA4->SourceStartAddress = 0x80C00000; //
DMA4_CSSAi
DMA4->DestinationStartAddress = 0x80F00000; //
DMA4_CDSAi
DMA4->SourceElementIndex = 1; //
DMA4_CSEIi
DMA4->SourceFrameIndex = 1; //
DMA4_CSFIi
DMA4->DestinationElementIndex = 1; //
DMA4_CDEIi
DMA4->DestinationFrameIndex = 1; //
DMA4_CDFIi
DMA4->ReadPortAccessMode = 1; //
DMA4_CCRi[13:12]
DMA4->WritePortAccessMode = 1; //
DMA4_CCRi[15:14]
DMA4->ReadPriority = 0; //
DMA4_CCRi[6]
DMA4->WritePriority = 0; //
DMA4_CCRi[23]
DMA4->ReadRequestNumber = 0; //
DMA4_CCRi[4:0]
DMA4->WriteRequestNumber = 0; //
DMA4_CCRi[20:19]
/* 1) Configure the transfer
parameters in the logical DMA registers
*/
/*-------------------------------------------------------------------*/
/*
a) Set the data type CSDP[1:0], the Read/Write Port access type
CSDP[8:7]/[15:14], the Source/dest endianism CSDP[21]/CSDP[19], write
mode CSDP[17:16], source/dest packed or non-packed
CSDP[6]/CSDP[13]*/
// Read CSDP
RegVal =
DMA4_CSDP_CH10;
// Build reg
RegVal = ((RegVal &~ 0x3)
| DMA4->DataType );
RegVal = ((RegVal &~(0x3 << 7)) |
(DMA4->ReadPortAccessType << 7));
RegVal = ((RegVal &~(0x3 << 14)) |
(DMA4->WritePortAccessType << 14));
RegVal = ((RegVal &~(0x1 << 21)) |
(DMA4->SourceEndiansim << 21));
RegVal = ((RegVal &~(0x1 << 19)) |
(DMA4->DestinationEndianism << 19));
RegVal = ((RegVal &~(0x3 << 16)) |
(DMA4->WriteMode << 16));
RegVal = ((RegVal &~(0x1 << 6)) |
(DMA4->SourcePacked << 6));
RegVal = ((RegVal &~(0x1 << 13)) |
(DMA4->DestinationPacked << 13));
// Write CSDP
DMA4_CSDP_CH10 = RegVal;
/* b) Set the number of
element per frame CEN[23:0]*/
DMA4_CEN_CH10 =
DMA4->NumberOfElementPerFrame;
/* c) Set the number of frame
per block CFN[15:0]*/
DMA4_CFN_CH10 =
DMA4->NumberOfFramePerTransferBlock;
/* d) Set the
Source/dest start address index CSSA[31:0]/CDSA[31:0]*/
DMA4_CSSA_CH10 = DMA4->SourceStartAddress; // address start
DMA4_CDSA_CH10 = DMA4->DestinationStartAddress; // address dest
/* e) Set the Read Port addressing mode CCR[13:12], the
Write Port addressing mode CCR[15:14], read/write priority
CCR[6]/CCR[26], the current LCH CCR[20:19]=00 and CCR[4:0]=00000*/
// Read CCR
RegVal = DMA4_CCR_CH10;
//
Build reg
RegVal = ((RegVal &~(0x3 << 12)) | (DMA4->ReadPortAccessMode << 12));
RegVal = ((RegVal &~(0x3 << 14)) | (DMA4->WritePortAccessMode
<< 14));
RegVal = ((RegVal &~(0x1 << 6)) | (DMA4->ReadPriority << 6));
RegVal = ((RegVal &~(0x1 << 26)) | (DMA4->WritePriority << 26));
RegVal &= 0xFFCFFFE0 ;
// Write CCR
DMA4_CCR_CH10
= RegVal;
/* f)- Set the source element index CSEI[15:0]*/
DMA4_CSEI_CH10 = DMA4->SourceElementIndex;
/* g)-
Set the source frame index CSFI[15:0]*/
DMA4_CSFI_CH10 =
DMA4->SourceFrameIndex ;
/* h)- Set the destination element
index CDEI[15:0]*/
DMA4_CDEI_CH10 =
DMA4->DestinationElementIndex;
/* i)- Set the destination
frame index CDFI[31:0]*/
DMA4_CDFI_CH10 =
DMA4->DestinationFrameIndex;
/* 2) Start the DMA transfer by
Setting the enable bit CCR[7]=1 */
/*--------------------------------------------------------------*/
//write enable bit
DMA4_CCR_CH10 |= 1 << 7; /* start */