当前位置:网站首页>DMA Porter
DMA Porter
2022-07-02 04:39:00 【Clear glass, brilliant orange】
DMA- hamal
1.
DMA(Direct Memory Access) Direct memory access , You can transfer data from one place to another , It won't occupy us cpu.
CPU Execute instructions according to the content of the code ,
Among these numerous instructions , Some are used for calculation 、 Some are used to control programs 、 Some are used to transfer data . Among them, the instruction to transfer data , especially
Is to transfer a large amount of data , Will take up a lot of CPU. If it is a peripheral A The data of , Pass it to the peripheral B, In fact, this situation does not need CPU Always participate
And , Just in A、B Create a channel between , Let them transmit by themselves . This is it. DMA Purpose of design , Reduce a large number of data transfer instructions .
DMA The main implementation will A The data at is directly transported to B It's about , there A、B It could be memory ( Inside / external SRAM etc. ), It can also be outside
set up (UART、I2C、SPI、ADC etc. ), So all the scenarios are as follows :
Memory to peripherals
Peripheral to memory
Memory to memory
DMA1 Yes 7 Channels ,DMA2 Yes 5 individual passageway , A total of 12 Channels .
You can put DMA Divided into three parts .
after ,DMA The controller processes the requests in turn according to the channel priority , When it's the peripheral's turn , Return the reply signal to the peripheral , The peripheral receives
Answer signal , Release the request , Conduct DMA The data transfer , until DMA End of transmission ;
②DMA passageway : Different peripherals , To different DMA Send requests through different channels , Pictured 20.1.2 Sum graph 20.1.3 Shown . such as ADC1
Want to use DMA, Should turn to DMA1 The passage of 1 Send a request .DMA1 The passage of 1, It can receive requests from multiple peripherals (ADC1、TIM2_CH3、
TIM4_CH1), But only one can be received at a time ;
③DMA priority : When more than one DMA passageway , When a request is sent at the same time , Get software configuration DMA_CCRx Priority of register setting ,
Respond in turn . When the software configuration priorities are the same , Hardware with high priority ( Small channel number ) Priority response . Yes DMA2 In the products of ,DMA1 Has a higher priority than DMA2.

All channels from memory to memory can be used .

Multiple DMA Simultaneous request :
1. Software phase :DMA_CCRx DMA Channel configuration register PL-> Set channel priority
2. Hardware phase : Small channel number has higher priority ,DMA1 Priority is greater than DMA2
Related registers 




void DCMI_DMA_Init(void)
{
DMA_InitTypeDef DMA_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2,ENABLE);//DMA2 Clock enable
DMA_DeInit(DMA2_Stream1);
while (DMA_GetCmdStatus(DMA2_Stream1) != DISABLE){
}// wait for DMA2_Stream1 Configurable
DMA_InitStructure.DMA_Channel = DMA_Channel_1; // passageway 1 DCMI passageway
DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)&DCMI->DR;// The peripheral address is :DCMI->DR camera
DMA_InitStructure.DMA_Memory0BaseAddr = (u32)&LCD->LCD_RAM;//DMA Memory 0 Address lcd
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;// Peripheral to memory mode Handling data : camera ->lcd
DMA_InitStructure.DMA_BufferSize = 10;// Data transmission volume
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;// Peripheral non incremental mode
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable;// Memory incremental mode close
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word;// Peripheral data length :32 position
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord ;// Memory data length 16bit
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;// Use circular mode
DMA_InitStructure.DMA_Priority = DMA_Priority_High;// High priority
DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Enable; //FIFO Pattern
DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full;// Use all FIFO
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;// Peripheral burst single transmission
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;// Memory burst single transmission
DMA_Init(DMA2_Stream1, &DMA_InitStructure);// initialization DMA Stream
DMA_ITConfig(DMA2_Stream1,DMA_IT_TC,ENABLE);
NVIC_InitStructure.NVIC_IRQChannel= DMA2_Stream1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority=0;
NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;
NVIC_Init(&NVIC_InitStructure); // Initialize... According to the specified parameters VIC register 、
}
//DCMI, Start transmission
void DCMI_Start(void)
{
LCD_Scan_Dir(U2D_L2R); //U2D_L2R // Scan from top to bottom , From left to right , General pattern
LCD_Set_Window(0,0,320,240); //LCD Set the display window , If you change the resolution , There needs to be a change
LCD_SetCursor(0,0); // Set the cursor
LCD_WriteRAM_Prepare(); // Start writing GRAM
DMA_Cmd(DMA2_Stream1, ENABLE);// Turn on DMA2,Stream1
DCMI_CaptureCmd(ENABLE);//DCMI Capture enable
}
//DCMI, Turn off transmission
void DCMI_Stop(void)
{
DCMI_CaptureCmd(DISABLE);//DCMI Capture to close
while(DCMI->CR&0X01); // Wait for the end of the transmission
DMA_Cmd(DMA2_Stream1,DISABLE);// close DMA2,Stream1
}
//DCMI Interrupt service function
void DCMI_IRQHandler(void)
{
if(DCMI_GetITStatus(DCMI_IT_LINE)==SET)// Capture row
{
DCMI_ClearITPendingBit(DCMI_IT_LINE);// Clear interrupt
ov_frame++;
}
}
边栏推荐
- Keil compilation code of CY7C68013A
- DC-1靶场搭建及渗透实战详细过程(DC靶场系列)
- Thinkphp内核工单系统源码商业开源版 多用户+多客服+短信+邮件通知
- Promise all()
- 【提高课】ST表解决区间最值问题【2】
- Common locks in MySQL
- The core idea of performance optimization, dry goods sharing
- Research on the security of ognl and El expressions and memory horse
- I sorted out some basic questions about opencv AI kit.
- One click generation and conversion of markdown directory to word format
猜你喜欢

Ognl和EL表达式以及内存马的安全研究

Spring moves are coming. Watch the gods fight

Keil compilation code of CY7C68013A

Idea autoguide package and autodelete package Settings

Mysql表insert中文变?号的问题解决办法

正大留4的主账户信息汇总

Leetcode- insert and sort the linked list

The solution to the complexity brought by lambda expression

Typescript practice for SAP ui5
![Introduction to Luogu 3 [circular structure] problem list solution](/img/fd/c0c5687c7e6e74bd5c911b27c3e19c.png)
Introduction to Luogu 3 [circular structure] problem list solution
随机推荐
Shutdown procedure after 60
Typescript practice for SAP ui5
深圳打造全球“鸿蒙欧拉之城”将加快培育生态,优秀项目最高资助 1000 万元
Playing with concurrency: what are the ways of communication between threads?
面试会问的 Promise.all()
BGP experiment the next day
Federal learning: dividing non IID samples according to Dirichlet distribution
powershell_ View PowerShell function source code (environment variable / alias) / take function as parameter
Read "the way to clean code" - function names should express their behavior
Let genuine SMS pressure measurement open source code
Arbre binaire pour résoudre le problème (2)
Vmware安装win10报错:operating system not found
Binary tree problem solving (2)
[source code analysis] NVIDIA hugectr, GPU version parameter server - (1)
二叉樹解題(二)
What are the rules and trading hours of agricultural futures contracts? How much is the handling fee deposit?
Markdown edit syntax
Spring moves are coming. Watch the gods fight
Introduction to Luogu 3 [circular structure] problem list solution
C language guessing numbers game