当前位置:网站首页>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++;
}
}
边栏推荐
- There is no prompt for SQL in idea XML, and the dialect setting is useless.
- Homework of the 16th week
- Pytoch --- use pytoch for image positioning
- Vmware安装win10报错:operating system not found
- Recyclerview add header
- 二叉树解题(二)
- Detailed process of DC-1 range construction and penetration practice (DC range Series)
- Starting from the classification of database, I understand the map database
- 洛谷入门3【循环结构】题单题解
- geotrust ov多域名ssl證書一年兩千一百元包含幾個域名?
猜你喜欢
深圳打造全球“鸿蒙欧拉之城”将加快培育生态,优秀项目最高资助 1000 万元
洛谷入门3【循环结构】题单题解
CorelDRAW Graphics Suite2022免费图形设计软件
Embedded-c language-9-makefile/ structure / Consortium
社交媒体搜索引擎优化及其重要性
Markdown编辑语法
正大留4的主账户信息汇总
Thinkphp Kernel wo system source Commercial Open source multi - user + multi - Customer Service + SMS + email notification
CY7C68013A之keil编译代码
LeetCode-对链表进行插入排序
随机推荐
Let正版短信测压开源源码
第十六周作业
unable to execute xxx. SH: operation not permitted
Leetcode- insert and sort the linked list
powershell_ View PowerShell function source code (environment variable / alias) / take function as parameter
Playing with concurrency: what are the ways of communication between threads?
Beginner crawler - biqu Pavilion crawler
Learn what definitelytyped is through the typescript development environment of SAP ui5
C语言猜数字游戏
云服务器的安全设置常识
60后关机程序
geotrust ov多域名ssl证书一年两千一百元包含几个域名?
Dare to go out for an interview without learning some distributed technology?
AcrelEMS高速公路微电网能效管理平台与智能照明解决方案智慧点亮隧道
缓存一致性解决方案——改数据时如何保证缓存和数据库中数据的一致性
LeetCode-归并排序链表
Alibaba cloud polkit pkexec local rights lifting vulnerability
Today's plan: February 15, 2022
Mapping location after kotlin confusion
二叉树解题(一)