DMA service mode: single service & whole service. In the former mode, a DMA request completes an atomic operation, and the value of the transfer count decreases by 1. In the latter mode, a DMA request completes a batch of atomic operations until the transfer count equals 0, indicating that the whole service is completed. Specifically corresponds to DCON[27].
DMA DREQ/DACK PROTOCOL: There are two protocols for DMA request and response, Demond mode and Handshake mode. The timing definitions of Request and Ack are different between the two:
In Demond mode, if Request is still valid after DMA completes a request, DMA considers it as the next DMA request and starts the next transfer immediately.
In Handshake mode, after DMA completes a request, it waits for the Request signal to be invalid. If the Request is invalid, DMA will invalidate ACK for two clock cycles and then wait for the next Request.
/****************************************************** **********************
Function: Use DMA to realize serial port transmission,pass string data to UTXH0 through DMA0 channel, and then
display it on the terminal. After the data is transmitted, DMA0 generates an interrupt and LED1 lights up.
************************************************************************
Mini2440 Debug Pass
2012-08-05
*****************************************************************/
#include "2440addr.h"
#define MDIV 92
#define SDIV 1
#define PDIV 1
#define HDIVN 2
#define PDIVN 1
#define PCLK_ 50000000
#define Led1_on() {rGPBDAT&=(~(1<<5)); }
char *SendBuffer = "Hello world!" ; //source data
/*****************LED Initialization************************************/
void Led_init()
{ rGPBCON &
=~((3<<10) | (3<<12) | (3<<14) | (3<<16)|(3<<0));
|=((1<<10) | (1<<12) | (1<<14) | (1<<16)|(1<<0));
rGPBUP &=~((1<<5) | (1<<6) | (1<<7) | (1<<8)|(1<<0));
rGPBDAT =0xfffe;
}
/*******************UART0 io port initialization******************************/
void Uart0_ io_init() //uart io port
{
rGPHCON =0xa0; //gph2,gph3 used for txd0,rxd0.
rGPHUP=0x0; //enable the pull up function
}
/******************************UART0 configuration****************************/
void Uart0_init(int bandrate)
{
rULCON0 |=0x3; //8-bit data ,1bit stop
rUCON0 |=((1<<0) | (1<<3) | (2<<10) ); //used pclk as the clock, transmit use DMA mode , receive use polling mode
rUBRDIV0=(int)(PCLK_/(bandrate*16))-1 ; //bandrate is 115200
}
/******************************Clock configuration******************************************/
void Clk_init( )
{
rCLKCON |=(1<<10 ); //enable uart0 used pclk
rLOCKTIME=0xffff; //locktime
rCLKCON |=(1<<13); //gpio enable pclk
rCLKDIVN =((PDIVN<<0) | (HDIVN<<1)); //1:4:8
rMPLLCON |=((MDIV<<12) | (PDIV<<4) | (SDIV<<0)); f_out=400MHZ
//__asm{
// mrc p15, 0, r1, c1, c0, 0
// orr r1, r1, #0xc0000000
//mcr p15, 0, r1, c1, c0, 0
// }
}
/****************************DMA initialization****************************************/
void Dma_init()
{
rGPBCON |=((1<<19)| (1<<21)); //GPB9,10 used for nXDACK0,nXDREQ0
rDISRC0=(U32)SendBuffer; //source data address
rDISRCC0 |=((0<<1)|(0<<0)); //address increment , the source is in the AHB
rDIDST0=(U32)UTXH0; //destination is UTXH0
rDIDSTC0 |=((0<< 2)|(1<<1)|(1<<0)); //address not change , APB , enable interrupt
rDCON0 |=(1<<31)|(0<<30)|(1<<29 )|(0<<28)|(0<<27)|(1<<24)|(1<<23)|(1<<22)|(0<<20)|(12);
// Handshake mode, PCLK synchronization ,enable dma interrupt , unit transfer , single service ,
//UART0 is the request source, H/W request mode ,disable auto reload , Byte transmit ,12 Byte data
rDMASKTRIG0=(0<<2)|(1<<1)|(0<<0); //start dma transmit
}
/******************** **DMA interrupt initialization******************************************/
void Dma_eint()
{
rINTMSK &=~(1<<17); //open the dma0 interrupt
}
/************************DMA interrupt service function*** ******************************/
void __irq Dma_isr()
{
rSRCPND|=(1<<17); //clear the srcpnd
rINTPND |=(1<<17); //clear the int pnd
Led1_on();
}
int Main()
{
Clk_init();
Led_init();
Uart0_io_init();
Uart0_init(115200);
Dma_eint();
pISR_DMA0 =(U32) Dma_isr;
Dma_init();
while(1)
{
;
}
return 0;
}
Previous article:Summary of reading NAND Flash from S3C2440
Next article:2440 Initialization Memory Principle (Continued from the previous article)
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- SWD cannot be downloaded, what is the reason? ?
- Waveform selection output
- Has anyone done any work on sparse matrix decomposition on FPGA?
- A rather strange op amp, take a look
- Undergraduate entrance examination
- Bill of Materials Problem
- Direct Memory Access (DMA) Controller - TMS320VC5509A
- A must-read for beginners! Experts explain the PCB return path for high-speed circuits
- Two major power outages in five days! The Taiwan authorities have asked TSMC to relocate or suspend some production lines
- PADS PCB 3D component library