cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with the delay function in the library for STM32H7B0

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?

11 REPLIES 11

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.

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.