unstable custom delay function (STM32 & STM32CubeIde)
Hello,
I have a small problem when using a custom delay function as follows :
void delay_us(uint32_t delayus) {
uint32_t start_count = __HAL_TIM_GET_COUNTER(&htim2);
while ((__HAL_TIM_GET_COUNTER(&htim2) - start_count) < delayus) {
}
}
The attached image shows the configuration of timer 2.
This delay function should allow me to generate short pulses. except that sometimes it does and sometimes nothing happens when I use it. I don't know what the problem is. Could you please help me?
