Delay with timers(Non blocking delay)
Hi,
I need microsec/millisec delay in my project but I don't want to effect the process flow.I am using STM32G4.
I am using timer for microseconds delay below is the function.
void delay_us (uint16_t us)
{
__HAL_TIM_SET_COUNTER(&htim1,0); // set the counter value a 0
while (__HAL_TIM_GET_COUNTER(&htim1) <= us); // wait for the counter to reach the us input in the parameter
}
Above function is working fine but the problem is with while loop in the delay function
it is getting struck there for given usec time it is blocking the
remaining process for that time to execute.
How to develop non blocking delay function with timers without while loop.
I have to provide multiple delays in my project.
Can I use same timer with different channels for different delay requirement
Please suggest/share the resources if available.
Thanks
