2023-08-26 07:05 PM
When using the delay function, I encountered an incomprehensible manifestation, for verification I brought a signal to the output of the microcontroller and received a switching frequency two times lower. I checked SystemCoreClock, it shows the configured frequency in the debugger. To check, I started a timer and got the correct output switching frequency. With what it can be connected?
2023-08-27 01:27 PM
The fact of the matter is that the solution from ST solves the problem of unstable delay duration and it remains in any case of a back-to-back duration. Well, unless, of course, you consider the code where there are several interrupts missing and you just blink one LED.
2023-08-27 01:57 PM - edited 2023-08-27 02:00 PM
I guess they do what they do for the SysTick-based timer because it is 24-bit, so they cannot use the running counter immediately in their notorious timeout trick ( if (HAL_GetTick() - start > timeout)... ). So they must use the interrupt to accumulate ticks in unsigned 32-bit variable. With a 32-bit hardware timer running up, you can just let it run freely and implement HAL_GetTick() as reading the counter. No interrupts, no overhead, no problems.
The "HAL" API is simple, one shouldn't expect too much of it and push over its limitations. Want a precise timer? there are enough hardware timers and HRTIM.