Skip to main content
NBlac
Associate III
July 24, 2018
Question

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

  • July 24, 2018
  • 1 reply
  • 569 views

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

    This topic has been closed for replies.

    1 reply

    Tesla DeLorean
    Guru
    August 10, 2018

    @ST Community​  any FAEs covering HRTIM functionality?

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