AnsweredAssumed Answered

Circular DMA data looks like rubbish

Question asked by cicerom on Aug 11, 2015
Latest reply on Aug 11, 2015 by Clive One
Hi,

I'm using DMA with Timer2 input capture to sample the (ch2)rising and (ch1)falling edges of a 250kbps signal.  So a bit is 4us long.

When running the DMA in normal mode, the values make sense and are synced nicely.  It obviously fills up the buffer of DELTA_SAMPLES samples then stops.  However, I need to run it continuously, but as soon as I change to circular mode, the values are completely whack.

void DMA_ConfigurationRx(void)
{
  DMA_InitTypeDef DMA_InitStructure;
  // TIM2_CH1 & 2 DMA1
  DMA_DeInit(DMA1_Channel5);
  DMA_DeInit(DMA1_Channel7);
  
  DMA_StructInit(&DMA_InitStructure); 
 
  DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)(&TIM2->CCR1);
  DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&DeltaBufferFalling[0];
  DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
  DMA_InitStructure.DMA_BufferSize = DELTA_SAMPLES;
  DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
  DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
  DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; // 32-bit
  DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Word;
  DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
  //DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
  DMA_InitStructure.DMA_Priority = DMA_Priority_High;
  DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
  DMA_Init(DMA1_Channel5, &DMA_InitStructure);
   
  DMA_StructInit(&DMA_InitStructure);   
  DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)(&TIM2->CCR2);
  DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&DeltaBufferRising[0];
  DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
  DMA_InitStructure.DMA_BufferSize = DELTA_SAMPLES;
  DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
  DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
  DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; // 32-bit
  DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Word;
  DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
  //DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
  DMA_InitStructure.DMA_Priority = DMA_Priority_High;
  DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
  DMA_Init(DMA1_Channel7, &DMA_InitStructure);
}

Device: STM32F334R8T6 (on the nucleo)
Frequency: 64MHz, 2 flash wait states
IDE+compiler: SW4STM32 (free eclipse based)
Std Library: V1.1.1 (4 April 2014) STM32F30x Standard Peripherals Library Drivers

Outcomes