cancel
Showing results for 
Search instead for 
Did you mean: 

DMA triggering not running for an input capture timer channel

stst9184
Associate II
Posted on October 31, 2012 at 16:38

I want to capture a systick time by occurence of an edge. I see the value is captured but the DMA is not done. Why? (STM32F4)

TIM_ICInitTypeDef TIM_ICInitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA1, ENABLE);
DMA_InitTypeDef DMA_InitStructure;
DMA_DeInit(DMA1_Stream0);
DMA_InitStructure.DMA_Channel = DMA_Channel_2; 
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&SysTick->VAL ;
DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)×tampOfEncoderEdge;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
DMA_InitStructure.DMA_BufferSize = 1;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word;
DMA_InitStructure.DMA_MemoryDataSize = DMA_PeripheralDataSize_Word;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
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(DMA1_Stream0, &DMA_InitStructure);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);
TIM_DeInit(TIM4);
TIM_ICInitStructure.TIM_Channel = TIM_Channel_1; 
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 = 0x0; 
TIM_ICInit(TIM4, &TIM_ICInitStructure);
TIM_Cmd(TIM4, ENABLE);
DMA_Cmd(DMA1_Stream0, ENABLE);
TIM_DMACmd(TIM4, TIM_DMA_CC1, ENABLE);

4 REPLIES 4
stst9184
Associate II
Posted on October 31, 2012 at 16:53

I get in a DMA1->LISR.TEIF0 = 1 - Stream 0 transfer error?

Posted on October 31, 2012 at 16:58

SYSTICK is buried in the core, will it even entertain an in-bound peripheral (APBx) read?

Why not free run a 32-bit TIM timebase, and sample the CNT register?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
stst9184
Associate II
Posted on October 31, 2012 at 17:18

Ok, so I've changed a line:

DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&SysTick->VAL ;

with :

DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&TIM4->CNT;

But still not working properly. I see always a value 3 in a sw buffer:(

stst9184
Associate II
Posted on October 31, 2012 at 17:22

Everythink is OK, I've add a line:

TIM_SelectCCDMA(TIM4, ENABLE);

After I've removed it again, it runs as I expect.

Thank you

joee