cancel
Showing results for 
Search instead for 
Did you mean: 

How to use HRTIM instead of general purpose timer for period measurement (input capture)?

NBlac
Associate III

I have successfully measured the period (2us) of some pwm signals with timer3 with the NUCLEOh743 board with this code:

uint32_t inputCaptureVal;
void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)
{
  UNUSED(htim);
	if (htim->Instance==TIM3)
	{
		inputCaptureVal=__HAL_TIM_GetCounter(htim);
		__HAL_TIM_SetCounter(htim,0);
	}
}

With this: htim3.Init.Prescaler = 20; and the chip running at 96MHz, i should be able to measure a 1us period with 208.83ns accuracy. However, i am unable to measure anything under 2+us. Also for a period of 170us i am measuring 163us and i am encountering similar faults for different measurements. Any ideas?

I would like to use HRTIM in order to measure smaller times between two events (pwm or anything else). Is that possible with a similar approach by using

HAL_HRTIM_Capture1EventCallback

??

thanks and please help me with any mistakes i might be making

1 REPLY 1

@ST Community​  any FAEs covering HRTIM functionality?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..