2015-08-25 06:59 AM
Hi,
Please i have to capture an input signal and read it's frequency value with a DMA request but i can't find any ressources.I know the other solution with interreupt but i insist on this method with DMA, i need it.i did the configuration required but the buffer of destination shows always value=0 !here is my code:uint32_t TIM1CapturedValue_u32[2];void CaptureDMA(void){ DMA_DeInit(DMA1_Channel2); // Time1_ch1<-->DMA1_ch2 DMA_InitStructure.DMA_PeripheralBaseAddr = TIM_DMABase_CCR1; // Time1-->CCR1 DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)TIM1CapturedValue_u32[0]; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; DMA_InitStructure.DMA_BufferSize =2; 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_Circular; DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; DMA_Init(DMA1_Channel2, &DMA_InitStructure); //Enable DMA1 channel2 DMA_Cmd(DMA1_Channel2, ENABLE); TIM_TimeBaseStructure.TIM_Prescaler = 0; // Counter Clk = 72M TIM_TimeBaseStructure.TIM_Period = 0XFFFF; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure); TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising; TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI; TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1; TIM_ICInitStructure.TIM_ICFilter = 0x00; TIM_ICInitStructure.TIM_Channel = TIM_Channel_1; TIM_ICInit(TIM1, &TIM_ICInitStructure); /* Enable the TIMER CAPTURE DMA requests */ TIM_SelectCCDMA(TIM1, ENABLE); TIM_DMACmd(TIM1, TIM_DMA_CC1, ENABLE); // TIM1 enable counter TIM_Cmd(TIM1,ENABLE); }2015-08-25 07:33 AM
You're using what processor?
u32 is NOT a HalfWord You want the Address of the Array, not the content2015-08-25 11:07 AM
Hi Clive,
i'm using Timer 16 bits. Here is what i have understood: when the capture occurs, the DMA will be requested to transfer the value of the CCR1 and store it into the buffer so i need the content of the buffer i think . I can't find where is the mistake or if there is code missing2015-08-25 11:08 AM
ok i'll change it to u16. i'm using STM32F103
2015-08-25 11:24 AM
// Loading the DMA Address with random content, perhaps zero.
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)TIM1CapturedValue_u32[0];// Loading the DMA Address with the address of the first array elementDMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&TIM1CapturedValue_u16[0];2015-08-27 05:49 AM
Thank you very much Clive 1 it works now.