AnsweredAssumed Answered

Understanding SysTick_Handler()

Question asked by Omar Suárez on Aug 28, 2017
Latest reply on Nov 14, 2017 by Clive Two.Zero

Hello everyone,


I am setting up a project to make some tests with an STM32F7 MCU. I am using the STM32Cube HAL and the idea is to configure some timers and their interrupts using this HAL. The board is equipped with and 25MHz HSE so in the code I am configuring the HSE and disabling the PLL.


The problem is that if I don't write the SysTick_Handle() function inside my code the MCU and the interrupts don't work. The PC goes to the SysTick_Handler() defined inside "startup_stm32f769xx.s".

I am trying to understand why is it a must to define the SysTick_Handler() in the code so you can use the HAL properly but I am not sure whether I really understand why.


In the FAQs of the HAL manual the third step of the sequence to use the HAL drivers is:

"Add HAL_IncTick() function under SysTick_Handler() ISR function to enable polling process when using HAL_Delay() function"

But I am not using the HAL_Delay() function, so why I need to define it?

Anyone can help with this?


This is my code :

#include <stm32f7xx_hal.h>

static TIM_HandleTypeDef s_TimerInstance;

void SysTick_Handler(void){

* @brief  This function initializes the SystemClock as HSE
* @param  None
* @retval None
void initClock(){
    RCC_ClkInitTypeDef RCC_ClkInitStruct;
    RCC_OscInitTypeDef RCC_OscInitStruct;
    HAL_StatusTypeDef ret = HAL_OK;
    /* Enable Power Control clock */
    RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
    RCC_OscInitStruct.HSEState = RCC_HSE_ON;
    RCC_OscInitStruct.PLL.PLLState = RCC_PLL_OFF;
    ret = HAL_RCC_OscConfig(&RCC_OscInitStruct);
    if(ret  != HAL_OK){
    /* Select HSE as system clock source */
    RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
    RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
    RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
    ret = HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_7);
    if(ret != HAL_OK){


void InitializeTimer(){
    s_TimerInstance.Init.Prescaler = 512;
    s_TimerInstance.Init.CounterMode = TIM_COUNTERMODE_UP;
    s_TimerInstance.Init.Period = 65535;
    s_TimerInstance.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
    s_TimerInstance.Instance = TIM6;

void GPIO_Init(){
    GPIO_InitTypeDef GPIO_InitStructure;

    GPIO_InitStructure.Pin = GPIO_PIN_8;
    GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
    GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
    GPIO_InitStructure.Pull = GPIO_NOPULL;
    HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);

    GPIO_InitStructure.Pin = GPIO_PIN_13;
    HAL_GPIO_Init(GPIOJ, &GPIO_InitStructure);

void TIM6_DAC_IRQHandler(){

void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef* htim){
    HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_8);
    HAL_GPIO_TogglePin(GPIOJ, GPIO_PIN_13);

int main(void){

    HAL_NVIC_SetPriority(TIM6_DAC_IRQn, 0, 0);
    while(1){    }



Thanks in advanced,