Skip to main content
Xme
Associate II
October 19, 2021
Question

SysTick_Handler not called, STM32G0B1

  • October 19, 2021
  • 25 replies
  • 16240 views

I am using CubeIde for the first time.

First test - run minimal program with HAL from CubeIDe Configurator, under debugger

Simple program, only SYSTICK and uart , but SysTick_Handler() is not trigged at all .

And function HAL_Delay hangs because uwTick is always 0. Tried with setting brakepoint inside handler - no results

Used HSI, SYSCLK 16MHZ, Cortex System Timer 16MHz,

RCC GPIO and USART1 - HAL configured.

here is main() generated from cubeide (I removed comments):

-----------------------------------------------------------

int main(void)

{

  HAL_Init();

 SystemClock_Config();

 MX_GPIO_Init();

 MX_USART1_UART_Init();

 HAL_Delay(100);

// here program hangs, when reaches HAL_Delay function. uwTick = 0

 while (1)

 {

 }

}

-----------------------------------------------------------

and here is the SysTick_handler from stm32g0xx_it.c

-----------------------------------------------------------

void SysTick_Handler(void)

{

 HAL_IncTick();

}

-----------------------------------------------------------

25 replies

TDK
October 19, 2021

There isn't a bug in the code that you've shown. Perhaps systick isn't being configured correctly in SystemClock_Config. Perhaps interrupts are disabled. Set a breakpoint in HAL_InitTick and see that it gets there and successfully completes.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Xme
XmeAuthor
Associate II
October 19, 2021

HAL_InitTick returns HAL_OK.

I am using code generated from cubeide. No code is written manually. If I missed something here, I dont know what its is.

Xme
XmeAuthor
Associate II
October 19, 2021

In NVIC configuration Time base: System tick timer : "Generate IRQ handler" is checked, and "Call HAL handler" checked.

It looks like irq is not enabled at all. I tried __enable_irq(); from CMIS but with no result.

Xme
XmeAuthor
Associate II
October 20, 2021

LedToogle example from ST works. The differences are in system_stm32g0xx.c file, at section VECT_TAB_ADDRESS. When I will use system_stm32g0xx.c from example sysytick in my test application works. But when file system_stm32g0xx.c is taken from new projectit generated from CubeIDE systick interrupt doesnt work.

And question: I am doing sth wrong, or is bug in generating code ?

Xme
XmeAuthor
Associate II
October 20, 2021

problem - SBC->VTOR is not initialised.

When I add to SystemInit() line: SCB->VTOR = FLASH_BASE it now works.

So question ST has a bug, or I have something missed when generating simple test project ?

ST Technical Moderator
October 20, 2021

Hello @Xme​ and welcome to the Community :) ,

Please have a look at my answer in this post. Hope this answers your question.

Note that I already raised the issue internally with the CubeMX team to take the necessary action.

Thanks for your contribution and if you still have issues, please don't hesitate to come back to the Community.

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
TDK
October 20, 2021
Making such a big change to a critical piece of the startup code is going to cause significant confusion for many users, experienced and inexperienced alike. Expect this to be a recurring question on the forum and a continual point of confusion.
"If you feel a post has answered your question, please click ""Accept as Solution""."
SCOUT.1
Visitor II
March 7, 2023

2023 : Problem still not solved in STMCube...

XR.1
Senior
November 19, 2024

2024 (almost 2025): Problem still not solved in STMCube...

Tesla DeLorean
Guru
November 19, 2024

Perhaps it's a problem with the board or part configuration?

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
gbm
Super User
March 7, 2023

Maybe I am too dumb, but what is exactly wrong with keeping the default VTOR value of 0? User Flash is normally mapped there, right? In many of my projects not using the bootloader I removed the VTOR setting from system_***.c and I couldn't see a problem with that.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
Tesla DeLorean
Guru
March 7, 2023

Or even just using the linker symbol​ so the VTOR just tracks how the project is built.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Visitor II
April 22, 2025

So, how to resolve this issue? I want to write some code for key scanning with systick, but right now I can't use the Systick_Handle to do that. This function in standard lib is easy to use.

XR.1
Senior
April 22, 2025

Hi,

Right now I barely recall what I exaclty did. Please help me refreshing my memory and tell me the contents of the function SystemInit() in your project, which is located in the file system_stm32g0xx.c (line 185).

 

What I can recall is that the issue was around the VTOR register: this is what I have right now:

 

/**
 * @brief Setup the microcontroller system.
 * @PAram None
 * @retval None
 */
void SystemInit(void)
{
 /* Configure the Vector Table location -------------------------------------*/
#if defined(USER_VECT_TAB_ADDRESS)
 SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation */
#endif /* USER_VECT_TAB_ADDRESS */
}

 

Bkell.1
Associate II
June 13, 2026

This Issue is still here today.. It affected me.

AI said

When ST design engineers created the firmware repository for the STM32G0 family, they reused the core system template files from the older STM32F0 family.

  • The STM32F0 (Old Core): Uses an ARM Cortex-M0 core. This core does not have an SCB->VTOR register. Its vector table is permanently, physically hardwired to address 0x00000000. Therefore, the system_stm32f0xx.c template never needed to touch a vector table register.

  • The STM32G0 (Your Core): Uses an ARM Cortex-M0+ core. This core does have an SCB->VTOR register.

Because ST copied the F0 template architecture over to the G0 repository, they left the USER_VECT_TAB_ADDRESS flag wrapped in that #if defined preprocessor safety guard. But because they forgot to add the corresponding checkbox configuration in the CubeMX graphical user interface for the G0 series, the code generator completely shadows out its own fix. The register is there, the code to configure it is there, but CubeMX generates a project that is physically incapable of turning it on by default.

 

 

The fix was to either manually  during init

// Directly point the CPU's vector table base register to the start of Flash

SCB->VTOR = 0x08000000;

 

Or put USER_VECT_TAB_ADDRESS as defined in the Project

Visitor
June 25, 2026

Thank you very much  Bkell.1
I've been running the CubeMX project for half a day and dosen`t work.
Everything always worked fine, but now G030 won't start without a define

Or put USER_VECT_TAB_ADDRESS as defined in the Project