DMA : Timer Trigger Memory-to-memory mode,
The DMA channels can also work without being triggered by a request from a peripheral.
This mode is called Memory to Memory mode.
If the MEM2MEM bit in the DMA_CCRx register is set, then the channel initiates transfers
as soon as it is enabled by software by setting the Enable bit (EN) in the DMA_CCRx register."
// STM32 TIM2 DMA Mem-to-Mem pacing VLDiscovery - sourcer32@gmail.com #include "STM32vldiscovery.h" #define OUTLENGTH 5 volatile u16 InBuffer[OUTLENGTH], OutBuffer[OUTLENGTH]; /**************************************************************************************/ void RCC_Configuration(void)
{
// clock for DMA
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); // clock for TIM2
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
} /**************************************************************************************/ void NVIC_Configuration(void)
{
NVIC_InitTypeDef NVIC_InitStructure; NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = ;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = ;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
} /******************************************************************************/ void DMA1_Channel2_IRQHandler(void) // Called at 10 Hz
{
if (DMA_GetITStatus(DMA1_IT_TC2))
{
DMA_ClearITPendingBit(DMA1_IT_TC2); STM32vldiscovery_LEDToggle(LED3); // Toggle 5 Hz
STM32vldiscovery_LEDToggle(LED4); // Do something
}
} /**************************************************************************************/ void DMA_Configuration(void)
{
DMA_InitTypeDef DMA_InitStructure; DMA_DeInit(DMA1_Channel2); DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)&InBuffer[]; // Source
DMA_InitStructure.DMA_MemoryBaseAddr = (u32)&OutBuffer[]; // Destination
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
DMA_InitStructure.DMA_BufferSize = OUTLENGTH;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Enable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; // Repetitive, for my convenience
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; // So we can pace via trigger
DMA_Init(DMA1_Channel2, &DMA_InitStructure); /* Enable DMA1 Channel2 Transfer Complete interrupt */
DMA_ITConfig(DMA1_Channel2, DMA_IT_TC, ENABLE); // turning DMA on (DMA1 Channel2 -> TIM2_UP)
DMA_Cmd(DMA1_Channel2, ENABLE);
} /**************************************************************************************/ void TIM2_Configuration(void)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; TIM_TimeBaseStructure.TIM_Prescaler = (SystemCoreClock / ) - ; // 1 MHz
TIM_TimeBaseStructure.TIM_Period = -; // 1MHz/20000 = 50 Hz
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseStructure.TIM_RepetitionCounter = ;
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure); // "connecting" DMA and TIM2
TIM_DMACmd(TIM2, TIM_DMA_Update, ENABLE); // turning on TIM2
TIM_Cmd(TIM2, ENABLE);
} /**************************************************************************************/ int main(void)
{
/* Initialise LEDs LD3 & LD4 */
STM32vldiscovery_LEDInit(LED3);
STM32vldiscovery_LEDInit(LED4); STM32vldiscovery_LEDOn(LED3);
STM32vldiscovery_LEDOff(LED4); RCC_Configuration(); NVIC_Configuration(); DMA_Configuration(); TIM2_Configuration(); while();
}
DMA : Timer Trigger Memory-to-memory mode,的更多相关文章
- Java (JVM) Memory Model – Memory Management in Java
原文地址:http://www.journaldev.com/2856/java-jvm-memory-model-memory-management-in-java Understanding JV ...
- System memory,AGP memory和video memory【转】
system memory就是电脑的内存条上的,一般都很大.显卡不能访问 . video memory就是显示卡上的显存,一般是32,64,128M这样,速度最快,显卡可直接访问 .用来描述电脑上一 ...
- stm32 DMA+timer+DAC
是有延迟的:
- Operating System Memory Management、Page Fault Exception、Cache Replacement Strategy Learning、LRU Algorithm
目录 . 引言 . 页表 . 结构化内存管理 . 物理内存的管理 . SLAB分配器 . 处理器高速缓存和TLB控制 . 内存管理的概念 . 内存覆盖与内存交换 . 内存连续分配管理方式 . 内存非连 ...
- STM32F4 Timer Internal Trigger Connection
The Timers can be cascaded to make more complex timing relationships, or longer periods. Internally ...
- PatentTips - Method to manage memory in a platform with virtual machines
BACKGROUND INFORMATION Various mechanisms exist for managing memory in a virtual machine environment ...
- Understanding Virtual Memory
Understanding Virtual Memory by Norm Murray and Neil Horman Introduction Definitions The Life of a P ...
- OpenCL memory object 之 Global memory (2)
转载自:http://www.cnblogs.com/mikewolf2002/archive/2011/12/18/2291584.html 当我们用clCreateBuffer, clCreate ...
- DTrace to Troubleshoot Java Native Memory Problems
How to Use DTrace to Troubleshoot Java Native Memory Problems on Oracle Solaris 11 Hands-On Labs of ...
随机推荐
- codeforces 235 div2 A. Vanya and Cards
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer ...
- 第6月第6天 opengles 三角形
1. http://blog.csdn.net/u010963658/article/details/52691578 2.多张图 https://www.oschina.net/question/2 ...
- MySQL常见的两种存储引擎:MyISAM与InnoDB的爱恨情仇
Java面试通关手册(Java学习指南,欢迎Star,会一直完善下去,欢迎建议和指导):https://github.com/Snailclimb/Java_Guide 一 MyISAM 1.1 My ...
- flask基础之Response响应对象(九)
前言 Response对象负责对客户端的响应,每一个请求都会有一个Response对象,那么它在一个请求的声明周期内是怎么发挥作用的呢? Response对象 响应发生的位置 先回顾一下http请求的 ...
- phantomhs获取网页的高度
function heheda() { window.setTimeout(function () { console.log("---------------------Capture O ...
- Winform/WPF Clipboard之剪切复制粘贴
Winform // <summary> /// 复制或剪切文件至剪贴板(方法) /// </summary> /// <param name="files&q ...
- oracle中使用sql语句生成10w条测试数据
sql语句 create table AAAATest as select rownum as cardNo, 'test' creator, to_char(sysdate + rownum//, ...
- 启动tomcat时报错Several ports (8005, 8080, 8009) required by Tomcat v5.5 Server at localhost are already in use.
[报错] Several ports (8005, 8080, 8009) required by Tomcat v5.5 Server at localhost are already in use ...
- 如何动态修改windows下的host文件
事件背景:为了测试数据提交后,需要在另一个环境的多个测试节点下去验证测试数据是否添加成功,找了一大堆放法,用了比较笨的方法实现了.不多废话思路如下: 为了万无一失,先备份hosts文件内容: 1.读取 ...
- DEEP COMPRESSION小记
2016ICLR最佳论文 Deep Compression: Compression Deep Neural Networks With Pruning, Trained Quantization A ...