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

SysTick_Handler not called, STM32G0B1

  • October 19, 2021
  • 9 replies
  • 16042 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();

}

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

9 replies

TDK
Super User
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 ?

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

"When your question is answered, please close this topic by clicking ""Accept as Solution"".ThanksImen"
TDK
Super User
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 VenmoUp vote any posts that you find helpful, it shows what's working..
gbm
Principal
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 VenmoUp 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 */
}