Skip to main content
NASI
Associate III
June 1, 2022
Question

Call HAL lib inside Call back

  • June 1, 2022
  • 2 replies
  • 944 views

Hello,

Is it Ok to read GPIO pins inside a timer call back as follow:

void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef* htim)

{

if (htim == &htim2 ) //15 ms

{

BT1 = HAL_GPIO_ReadPin(GPIOx, Pin_x);

BT2 = HAL_GPIO_ReadPin(GPIOx, Pin_x);

BT3 = HAL_GPIO_ReadPin(GPIOx, Pin_x);

...

}

}

Thank you

This topic has been closed for replies.

2 replies

KnarfB
Super User
June 1, 2022

It is. Look at (debug step) the implementation.

hth

KnarfB

Andrew Neil
Super User
June 1, 2022

0693W000008xsqBQAQ.png

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.