cancel
Showing results for 
Search instead for 
Did you mean: 

SysTick_Handler not called, STM32G0B1

Xme
Associate II

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();

}

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

11 REPLIES 11
TDK
Guru

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
Associate II

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
Associate II

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
Associate II

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
Associate II

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 ?

Imen.D
ST Employee

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".
Thanks
Imen
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
Associate

2023 : Problem still not solved in STMCube...

gbm
Lead III

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.