1
\$\begingroup\$

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

\$\endgroup\$
1
\$\begingroup\$

It was: __HAL_TIM_GET_COUNTER

I should RTFM better

\$\endgroup\$
1
\$\begingroup\$

__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.

\$\endgroup\$
-2
\$\begingroup\$

Firstly, go stm32fXxx_hal_tim.h file. And then you can look whatever you want to function. In my header file, __HAL_TIM_GetCounter function updated as __HAL_TIM_GET_COUNTER

I think you can use that function.

\$\endgroup\$
  • 2
    \$\begingroup\$ Of course the OP can use that function, they already posted it in an answer more than one year ago. \$\endgroup\$ – Dmitry Grigoryev Aug 16 at 8:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.