Question
How to know when HAL_TIM_IC_CaptureCallback function is done
i have code in HAL_TIM_IC_CaptureCallback
void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim) {
if (htim->Channel == HAL_TIM_ACTIVE_CHANNEL_1) {
/* Get the Input Capture value */
iC2Value1 = HAL_TIM_ReadCapturedValue(htim, TIM_CHANNEL_1);
if (iC2Value1 != 0) {
/* Duty cycle computation */
iC2Value2 = ((HAL_TIM_ReadCapturedValue(htim, TIM_CHANNEL_2)));
distance = ((float) iC2Value2) / 147.0;
dutyCycle = (iC2Value2 * 100.0) / (float) iC2Value1;
/* uwFrequency computation
TIM4 counter clock = (RCC_Clocks.HCLK_Frequency) */
frequency = (float) HAL_RCC_GetHCLKFreq() / (float) iC2Value1;
} else {
dutyCycle = 0;
frequency = 0;
}
}
}i want to set a flag in there to know when the capture has finished ie when done flag=1 so that i can proceed with doing something else in my while loop. Although what i found is that that the
void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim) {
if (htim->Channel == HAL_TIM_ACTIVE_CHANNEL_1) {
runs multiple times for when getting one capture( i may be wrong on this i'm not sure but that seemed to be the case). Can someone let me know how to set a flag so i know when the capture has finished
