Work with STM32F4 Timer
Check the UIF bit of the TIM2->SR register. Here is a complete working example (mostly) without HAL, but the loop should work with HAL too.

void tim2_test() {
    /* My LED is on port B. Change this if yours is different */
    RCC-&gt;AHBENR |= RCC_AHBENR_GPIOBEN;

    /* Enable TIM2 */
    RCC-&gt;APB1ENR |= RCC_APB1ENR_TIM2EN;

    /* Counter reload value. Must be a 16 bit integer, i.e. between 1 and 65535
    SystemCoreClock should be set by HAL */
    TIM2-&gt;ARR = SystemCoreClock / 10000 - 1;

    /* Prescaler value, pick it so that both this and the previous
    value fall between 1 and 65535 */
    TIM2-&gt;PSC = 9999;

    /* Start the timer with default settings, it'll count from 0 up to ARR */
    TIM2-&gt;CR1 = TIM_CR1_CEN;

    /* Port B pin 0 as output. Change this for your LED */
    GPIOB-&gt;MODER = (GPIOB-&gt;MODER &amp; ~GPIO_MODER_MODER0) | GPIO_MODER_MODER0_0;

    while(1) {

        /* Check the update flag. It'll be set every time the timer overflows */
        if(TIM2-&gt;SR &amp; TIM_SR_UIF) {

            /* Reset the flag, so that we can catch the next overflow */
            TIM2-&gt;SR &amp;= ~TIM_SR_UIF;

            /* Toggle LED pin, change this for your board */
            GPIOB-&gt;ODR ^= 1;
        }
    }
}