cancel
Showing results for 
Search instead for 
Did you mean: 

dma controlled by timer

mtraman
Associate II
Posted on July 21, 2008 at 09:57

dma controlled by timer

2 REPLIES 2
mtraman
Associate II
Posted on May 17, 2011 at 09:40

Hi all,

I need to send data to codec every 20.8usec. i can't use dma because it would send all the data in go, without regard to the sampling rate.

Is there a way to send the data using dma whenever a timer expires?

bye

vikram

agcicek
Associate
Posted on May 17, 2011 at 09:40

hi.

i have same problem like you m2m dma application implementation. I cannot solve how can i use dma over memory usage on cortex M3. i wantto use timer2 to use dma channel for copying. but it doesnt work.. please look the code to solve my problem.

note: i use dmachannel1 to take values from adg to memory.. i want to dma channel 2 to solve problem with timer 2. but it doesnot working.

/* Enable DMA channel2 */

DMA_Cmd(DMA_Channel1, ENABLE);

/* DMA channel2 configuration ----------------------------------------------*/

DMA_DeInit(DMA_Channel2);

DMA_InitStructure_DMA.DMA_PeripheralBaseAddr = (u16)ADC_ConvertedValue1;

DMA_InitStructure_DMA.DMA_MemoryBaseAddr = (u16)ADC_ConvertedValue; DMA_InitStructure_DMA.DMA_DIR = DMA_DIR_PeripheralSRC;

DMA_InitStructure_DMA.DMA_BufferSize = 14; //

DMA_InitStructure_DMA.DMA_PeripheralInc = DMA_PeripheralInc_Enable;

DMA_InitStructure_DMA.DMA_MemoryInc = DMA_MemoryInc_Enable;//Disable;//

DMA_InitStructure_DMA.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;

DMA_InitStructure_DMA.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;

DMA_InitStructure_DMA.DMA_Mode = DMA_Mode_Normal;

DMA_InitStructure_DMA.DMA_Priority = DMA_Priority_Low;

DMA_InitStructure_DMA.DMA_M2M = DMA_M2M_Enable;

DMA_Init(DMA_Channel2, &DMA_InitStructure_DMA);

/* Enable DMA channel2 */

DMA_Cmd(DMA_Channel2, ENABLE);

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA, ENABLE);

/* Time base configuration */

TIM_TimeBaseStructure.TIM_Period = 0xFFFF;//0xFFFF;//CCR1_Val;//0xFFFF;

TIM_TimeBaseStructure.TIM_Prescaler = 0x000;//0x7CF;//72-1; 0x4e1f;//

TIM_TimeBaseStructure.TIM_ClockDivision =TIM_CKD_DIV1;

// gerçek ortamdada etkilemedi :)

TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;

TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);

/* Output Compare Toggle Mode configuration: Channel1 */

TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_Timing;

TIM_OCInitStructure.TIM_Channel = TIM_Channel_1;

TIM_OCInitStructure.TIM_Pulse = 0xF5B;

TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low;

TIM_OCInit(TIM2, &TIM_OCInitStructure);

TIM_OC1PreloadConfig(TIM2, TIM_OCPreload_Disable);

/* TIM enable counter */

TIM_Cmd(TIM2, ENABLE);

/* TIM IT enable */

TIM_ITConfig(TIM2, TIM_IT_CC1, ENABLE);

TIM_DMAConfig(TIM2,TIM_DMABase_CCR1,TIM_DMABurstLength_1Byte);

TIM_DMACmd(TIM2,TIM_DMA_CC1,ENABLE);

RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);