Time-based input capture
Hi all,
I have an application where I'm trying to use input capture to capture pulse intervals in a specific period of time. At maximum, the pulses will happen frequently enough that I can't use the straight interrupt capture with HAL_TIM_IC_Start_IT, as it will starve out other tasks. My thought is to use a DMA engine with HAL_TIM_IC_Start_DMA. At the moment, the DMA interrupt triggers when the data buffer is full. However, since I need to record over a specific period, this isn't sufficient - in that period there may be no events, or less than one buffer's worth of data. What I'm thinking is something like this (please pardon the pseudocode):
HAL_TIM_Base_Start_IT(tim1); //start timer to measure period
HAL_TIM_IC_Start_DMA(tim2); //start input capture
while(1) //handle other tasks while waiting on input capture
{
//do other things here
}
//input capture period timer has elapsed, so stop capture and store data
base_time_interrupt()
{
//stop IC
HAL_TIM_IC_Stop_DMA();
//DMA input capture data from peripheral
//get number of samples captured
}Is this possible, or is there another viable option to gather this data? If this is possible, what needs to be done?
Some implementation details:
I'm using the STM32G474RE on the NUCLEO-G474R board. I'm using STM32CubeIDE configuration utility to set up and configure the peripherals, and using TIM2 CH3 for the input capture.
