# __HAL_TIM_GetCounter with STM32F103

I found a lot of tutorial to get counter value from an interrupt timer something like:

    /* USER CODE BEGIN WHILE */
while (1)
{
count = __HAL_TIM_GetCounter(&htim2);    //read TIM2 counter value
/* USER CODE END WHILE */


Generally, this code is used with HAL libraries and STM32F4 I used the same but the function is not declared in HAL Libraries. Do you know why? What I'm supposed to use instead?

Thank you

__HAL_TIM_GetCounter() is apparently deprecated and moved to Legacy/stm32_hal_legacy.h. If you have a lot of old code, you can put #define USE_LEGACY in stm32f1xx_hal_conf.h to include it automatically.