Skip to main content
SCamp.1041
Associate III
November 8, 2019
Question

__HAL_TIM_GetCompare does not exist for STM32F1 HAL library

  • November 8, 2019
  • 1 reply
  • 756 views

I am switching my project from an STM32F4 MCU to an STM32F1 MCU and am stuck on this one issue where a function I previously used to get the input capture period of a timer on the F4 series chip does not exist for the F1 series chip.

Why might this be? Does that mean the F1 series of MCUs do not support input-capture modes on timers?

// Input Capture callback in non blocking mode.
void HAL_TIM_IC_CaptureCallback (TIM_HandleTypeDef * htim) {
 if (htim->Instance == TIM4) {
 inputCaptureOld = inputCaptureNew;
 inputCaptureNew = __HAL_TIM_GetCompare(&htim4, TIM_CHANNEL_1); // read TIM4 channel 1 capture value
 __HAL_TIM_SetCounter(&htim4, 0); // reset counter to zero after input capture interupt occurs
 }
}

Above is the code I had for the F4 chip to capture the period of an external clock signal on channel 1.

This topic has been closed for replies.

1 reply

waclawek.jan
Super User
November 13, 2019

You are supposed to use the HAL_TIM_ReadCapturedValue() function, rather than the macros, to read the captured value.

JW

PS. Please change your username to a normal nick