S3C6410-DMA裸机编程



DMA编程--DMAC

1.  通道数-- s3c6410有四个DMAC控制器,每个控制器有8个通道,
 每个DMA Controller又提供16 个外设DMA Request Lines,能让16个外设进行DMA请求.

2.请求源--source
系统中支持64个 DMA Sources,每个DMA Controller支持16个DMA Sources,
让这16个DMA Sources进行DMA Request,但由于只有8个DMA Transfer Channel,
所以只能同时有8个DMA Sources进行DMA Transfer。

3.工作模式--Demand/Handshake
/*
The DMA controller supports four types of transfer:
memory-to-peripheral
peripheral-to-memory
memory-to-memory
peripheral-to-peripheral.
Each transfer type can have either
*/

4.编程步骤:
4.1--Decide whether use secure DMAC(SDMAC) or general DMAC(DMAC). In order to use general DMAC,
disable secure DMA control register(SDMA_SEL) of system controller. (Reset value is SDMAC).

4.2--Select a free DMA channel with the priority needed. Where DMA channel 0 has the highest priority and DMA
channel 7 the lowest priority.

4.3--Clear any pending interrupts on the channel to be used by writing to the DMACIntTCClr and DMACIntErrClr
registers. The previous channel operation might have left interrupts active.

4.4--Write the source address into the DMACCxSrcAddr register.

4.5--Write the destination address into the DMACCxDestAddr register.

4.6--Write the address of the next LLI into the DMACCxLLI register.
If the transfer comprises of a single packet of data then must be written into this register.

Offset      Contents
Next LLI address   Source Address for next transfer
Next LLI address + 0x04 Destination Address for next transfer
Next LLI address + 0x08 Next LLI address for next transfer
Next LLI address + 0x0C DMACCxControl0 data for next transfer
Next LLI address + 0x10 DMACCxControl1 data for next transfer

4.7--Write the control information into the DMACCxControl register.

4.8--Write the channel configuration information into the DMACCxConfiguration register.
If the Enable bit is set then the DMA channel is automatically enabled.

//串口dma-->DMA0 0 DMA_UART0[0] UART0 DMA source 0--DMA0/通道0

#define SDMA_SEL     *((volatile unsigned long*)0x7E00F110)
#define DMACC0Control0    *((volatile unsigned long*)0x7500010c)
#define DMACC0Control1       *((volatile unsigned long *)0x7DB00110)
#define DMACConfiguration       *((volatile unsigned long *)0x7DB00030)
#define DMACC0Configuration  *((volatile unsigned long*)0x75000114)
#define DMACC0LLI      *((volatile unsigned long*)0x75000108)
#define DMACC0SrcAddr    *((volatile unsigned long*)0x75000100)
#define DMACC0DestAddr    *((volatile unsigned long*)0x75000104)


#define UTXH0        (volatile unsigned long *)0x7F005020

char src[100] = "\n\rHello World->";

void dma_init()
{
 //DMA控制器的选择(SDMAC0)
 SDMA_SEL = 0;
 
 /* 如果外设的工作时钟与DMA控制器的时钟不相同, 要使能"同步逻辑" */
 DMACSync = 0;
 
 //DMA控制器使能
 DMACConfiguration = 1;
 
 //初始化源地址
 DMACC0SrcAddr = (unsigned int)src;
 
 //初始化目的地址
 DMACC0DestAddr = (unsigned int)UTXH0;
 
 //对控制寄存器进行配置
 /*
 源地址自增
 目的地址固定、
 目标主机选择AHB主机2
 源主机选择AHB主机1
 */
 DMACC0Control0 =(1<<25) | (1 << 26)| (1<<31);  
 DMACC0Control1 = 0x64;     //传输的大小
 
 //DMACC0Control0 |= (0x3<<12)|(0x3<<15)|(0x2<<18)|(0x2<<21)|(0x0<<24)|(0x7<<25);
 //开启channel0 DMA
 /*
 流控制和传输类型:Memory to peripheral 为 001
 目标外设:DMA_UART0_1,源外设:DMA_MEM
 */
 
 DMACC0Configuration = (1<<6) | (1<<11) | (1<<14) | (1<<15);
 
 DMACC0Configuration = 1;  /*1 -->channel enabled.*/
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章