AnsweredAssumed Answered

DMA timer capture

Question asked by giso on Jul 16, 2013
Latest reply on Jul 17, 2013 by Clive One
Hi,

I need to do some timming analyses on signal. I use the capture mode of a timer.
When I use the interrupt to capture event, it works but when the signal is fatser I get into overrun issue, I cannot run my CPU faster as I will draw too much current.
I was thinking to use the DMA to save the timer capture events allowing to run the CPU slower but it does not work. I have the following code
  /* DMA clock enable */
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2 , ENABLE);

  DMA_DeInit(DMA2_Stream6);
  DMA_StructInit(&DMA_InitStructure);
  DMA_InitStructure.DMA_Channel = DMA_Channel_6;  
  DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)(&TIM1->CCR3) ;
  DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)delta_buf;
  DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
  DMA_InitStructure.DMA_BufferSize = 256;
  DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
  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_Normal;
  DMA_InitStructure.DMA_Priority = DMA_Priority_High;
  DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;
  DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full;
  DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
  DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
  DMA_Init(DMA2_Stream6, &DMA_InitStructure);

  TIM_DeInit(TIM1);
  TIM_ICInitStructure.TIM_Channel = TIM_Channel_3;
  TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_BothEdge;
  TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
  TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
  TIM_ICInitStructure.TIM_ICFilter = 0x00;      
  
  TIM_ICInit(TIM1, &TIM_ICInitStructure);
  
  /* Enable the TIMER CAPTURE DMA requests */
  TIM_SelectCCDMA(TIM1, ENABLE);
  TIM_DMACmd(TIM1, TIM_DMA_CC3, ENABLE);

  /* TIM enable counter */
  TIM_Cmd(TIM1, ENABLE);

Any idea?

Outcomes