Skip to main content
Tank2005
Associate
May 15, 2019
Solved

Input Cupture values sometime skipped on DMA Circular mode

  • May 15, 2019
  • 2 replies
  • 1900 views

My environment is Nucleo-F446RE(STM32F446) with TrueSTUDIO / CubeMX on Windows 10.

I tried to get a 6MHz frequency signal by Input Capture module. However, modules often skip timer values.

0690X000008vvhoQAA.png0690X000008vvhtQAA.png0690X000008vvhyQAA.png

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
uint16_t captures[240];
void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim) {
 if (htim->Channel == HAL_TIM_ACTIVE_CHANNEL_3) {
 }
}
 
void HAL_TIM_IC_CaptureHalfCpltCallback(TIM_HandleTypeDef *htim)
{
 if (htim->Channel == HAL_TIM_ACTIVE_CHANNEL_3) {
 }
}
/* USER CODE END 0 */
 
int main(void)
{
 /* USER CODE BEGIN 2 */
 HAL_TIM_IC_Start_DMA(&htim2, TIM_CHANNEL_3, captures, 120);
 /* USER CODE END 2 */
}
 

This is an example of an aquired buffer(captures[240]) on my environment. 

[825, 840, 856, 864, 2653, 2668, 2684, 2700, 4465, 4481, 4497...]

Interval between signals are should always from 10 to 20, but it has more than 2000.

This problem doesn't occur when I change DMA mode from "Circular" to "Normal". But I'm concerned about processor efficiency because a frequency of this signal is very high, 

Can I avoid this trouble about Input Capture with DMA Circular mode by modifying the program?

This topic has been closed for replies.
Best answer by waclawek.jan

How do you observe the captured data? I guess, in the debugger, and you don't stop the input signal. In that case, until the debugger reads the data, the DMA runs over the same array several times, so the debugger shows you 4 data from the first pass, 4 data from second, several more from the third...

JW

2 replies

waclawek.jan
waclawek.janBest answer
Super User
May 15, 2019

How do you observe the captured data? I guess, in the debugger, and you don't stop the input signal. In that case, until the debugger reads the data, the DMA runs over the same array several times, so the debugger shows you 4 data from the first pass, 4 data from second, several more from the third...

JW

Tank2005
Tank2005Author
Associate
May 17, 2019

I got an accurate value by buffering those data with RTOS. Thank you for your advice.