2025-11-20 3:43 AM - last edited on 2025-11-20 3:55 AM by Andrew Neil
Post edited by ST moderator to be inline with the community rules for the code sharing. In next time please use </> button to paste your code. Please read this post: How to insert source code.
Hallo,
I am trying to measure the frequency of rectangular signals. the borad I am using is stm32f411-disco
I used the timer 2 channel 1 for input capture. at every capture the timer value will be sent to memery by uing DMA. The DMA seems working, because I printed the captured value periodically. the DMA-Buffer is two, and it is working in a circular mode.
I try to do some calculation in the interruption-function: "void HAL_DMA_XferCpltCallback(DMA_HandleTypeDef *hdma)" like this:
void HAL_DMA_XferCpltCallback(DMA_HandleTypeDef *hdma)
{
if (hdma->Instance == DMA1_Stream5) // MCU-abhängig!
{
uint32_t first = IC_Values[0];
uint32_t second = IC_Values[1];
if (second >= first)
diff = second - first;
else
diff = (0xFFFFFFFF - first + second);
/* Timer läuft mit 1 MHz → 1 µs pro Tick */
Frequency = 1e6f / diff;
}
}
But this interruption is not triggered.
so my question is, shouldn't this function be triggered after the DMA transfer complete?
complete script please see the attachment:
Solved! Go to Solution.
2025-11-21 2:26 AM
2025-11-21 5:30 AM
Hello @xtxftzld
Where did you call HAL_DMA_RegisterCallback() ? This function should be called before HAL_TIM_IC_Start_DMA().
2025-11-21 6:21 AM
HAL only calls HAL_TIM_IC_CaptureCallback, not HAL_DMA_XferCpltCallback, at the end of this transfer. That is the intended behavior.
You can hijack the DMA1_Stream5_IRQHandler handler if you want to process the TC flag.
2025-11-21 7:11 AM
I have already noticed this, and changed the oder. But it still doesn’t help
regards