cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with TIM3 Input capture with DMA

VSchu.1
Associate II

Hello everybody,

I am trying to use the TIM3 those input capture mode with DMA transfer. After buffer is full the DMA call the callback function IT. Then i execute the stop DMA function. But after this sequence, the DMA no reinitialize. I am using the Cube MX for initialize the code.

What could I be doing wrong?

I am using the STM32C011F6P6

 

 

The code:

uint16_t period_buffer[52];

HAL_TIM_IC_Start_DMA(&htim3, TIM_CHANNEL_1, (uint32_t*) period_buffer, 52);

 

 

void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)
{
       HAL_TIM_IC_Stop_DMA(&htim3, TIM_CHANNEL_1);
}

1 ACCEPTED SOLUTION

Accepted Solutions

I'm operating in normal mode, I had to include one more command to solve the problem:

void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)
{
       if(htim->Channel == HAL_TIM_ACTIVE_CHANNEL_1)
      {
              HAL_TIM_IC_Stop_DMA(&htim3, TIM_CHANNEL_1);
 
              HAL_DMA_Abort(&hdma_tim3_ch1); //this solves the problem
     }
}

View solution in original post

4 REPLIES 4
Sarra.S
ST Employee

Hello @VSchu.1

Please share your DMA configuration

I suppose you're configuring DMA in circular mode, if you're using normal mode you need to reinitialize the DMA transfer manually in the callback function. 

 

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.

nouirakh
ST Employee

Hello @VSchu.1 

In order to reproduce the possible issue, could you please provide more details on your setting project if possible, attach your .ioc file/configuration.

> But after this sequence, the DMA no reinitialize.

What does this mean?

What are the symptoms, and how are they different from the expected behaviour?

JW

I'm operating in normal mode, I had to include one more command to solve the problem:

void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)
{
       if(htim->Channel == HAL_TIM_ACTIVE_CHANNEL_1)
      {
              HAL_TIM_IC_Stop_DMA(&htim3, TIM_CHANNEL_1);
 
              HAL_DMA_Abort(&hdma_tim3_ch1); //this solves the problem
     }
}