cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_DMA_XferCpltCallback not triggered after DMA transfer complete

xtxftzld
Associate

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:

 

 

13 REPLIES 13

Hi please see the attachment

Hello @xtxftzld 

Where did you call HAL_DMA_RegisterCallback() ? This function should be called before HAL_TIM_IC_Start_DMA().

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om

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.

If you feel a post has answered your question, please click "Accept as Solution".

I have already noticed this, and changed the oder. But it still doesn’t help

regards