17.dma-2440
First, in the previous instance, add the Dma.c file under the Dev folder and add it to the directory's makefile:
So the framework is good, then open the DMA.C to achieve:
First open the 2440 chip manual:
We want to operate the serial port 0, corresponding to the channel 0:
The corresponding source registers:
The corresponding control registers:
The register has only two bits:
You can see that the [1] bit of the DMA control register is absolute AHB or an APB bus. This is from the first chapter of the schematic diagram:
You can see that the memory is using the AHB bus.
So the source register for the source address should be set to:
Destination Address:
Control register for the destination address:
The control register for the destination register has three bits:
[2] bit is the time to control the interruption, the choice is the default, is set to 0, when the count to 0 is interrupted.
[1] bit is the choice is AHB or APB to store location, here is the serial port, is apb:[1]=1.
[0] bits are controlled in the process of data transmission, whether the destination address needs to change. This is a serial port to receive data, so the address does not change, so [0]=1.
Above is the DMA send and accept register settings, there is also a DMA control register settings:
Here is the DCON0 register [26:24]:
is to set the DMA source, which is used by UART0, so [26:24]=001.
[23] bit is to indicate whether the DMA source is software or hardware, this is the serial port, is the hardware, so is the 1:
[22] Bit control is, when you send the data after the re-send, there is no need to send a duplicate, so set 1:
TC[19:0] bit is used to tell the DMA to send the data size, the DMA will know when the end. The length of the above Hello Forfish is 13, so:
In the end:
Here, the settings for the control register for DMA are over.
The last function:
The function is set up the DMA controller, the next step is to set the open DMA, when the DMA is open, you can transfer data.
To turn on DMA here, you only need to set the [1] bit of the DMASKTRIG0 register to 1:
List of registers involved:
Note: The last UTXH0 is the address of the register, not the value of the register. Be aware of when defining.
To invoke the DMA operation function in MAIN.C:
After you've modified make:
Burn write to Development Board, Nandflash boot:
Can see, the General DMA way, the string passed to the serial port, the implementation of DMA mechanism.
17.dma-2440