Question
Use timer base and input capture at the same time
I use timer gated mode for a HC-SR04 ultrasonic sensor which needs microsecond delay. Is it possible to use the same timer as time base to get microseconds?
if (HAL_TIM_Base_Start(&htim3) != HAL_OK) // time base for usDelay()
Error_Handler();
if (HAL_TIM_IC_Start_IT(&htim3, TIM_CHANNEL_2) != HAL_OK) // ECHO
Error_Handler();
...
void usDelay (uint16_t uSec)
{
__HAL_TIM_SET_COUNTER(&htim3, 0);
while (__HAL_TIM_GET_COUNTER(&htim3) < uSec);
}The code stuck here.
while (__HAL_TIM_GET_COUNTER(&htim3) < uSec);
