Skip to main content
Senior III
June 17, 2026
Solved

Systick Interrupt handler not executed and gets reset if any interrupt is enabled

  • June 17, 2026
  • 20 replies
  • 286 views

I have used the HAL_Delay function as below, the micro is stm32g474ret6.

while (1)
{
/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */
HAL_GPIO_WritePin(LED2_GPIO_Port, LED2_Pin, SET);
HAL_GPIO_WritePin(Buzzer_GPIO_Port, Buzzer_Pin, RESET);
HAL_Delay(1000);
HAL_GPIO_WritePin(LED2_GPIO_Port, LED2_Pin, RESET);


}
/* USER CODE END 3 */
}

The problem is the code always struck in the HAL_Delay function 

 

with uwTick always returning 0. The systick interrupt handler is not called. 

Another observation if i enable the timer1 interrupt (i assume enable any interrupt) the code is reset. I generated the PWM using timer1 without interrupts. 

What is the problem when i enable interrupts how do i check it? Is it something to do with the Interrupt vector table.

Best answer by STuser2

RESET PROBLEMS WITH STM32G474RET6 | Community

This did the trick.

20 replies

STuser2Author
Senior III
June 17, 2026

This is my CubeMX project for reference, request to please suggest resolving the issue.

Ozone
Principal
June 18, 2026

> The systick interrupt handler is not called. 

Are you sure, i.e. had you set a breakpoint in the handler ?

I ask because the main loop of you code does not do what you probably think it does.
After the 1000ms delay you reset the LED, and then immediately set it.
A human eye is not capable of detecting events of a few microsend duration, the LED appears to be always on.

 

 

STuser2Author
Senior III
June 18, 2026

Yes i have set the break point

The program does not halt. Is it related to hardware or software to find the root cause.

STuser2Author
Senior III
June 18, 2026

These are the settings when i read from the stlink utility

Below are the option byte settings

 

Anything wrong with them please advise.

Ozone
Principal
June 18, 2026

I don’t use CubeIDE, but the settings look ok to me.

When you start debugging, does the IDE download and verify your application successfully ?

Does it stop on “main()”, as supposed ?

STuser2Author
Senior III
June 18, 2026

Yes it does stops at main(). 

 

when i step over the Timer

HAL_TIM_Base_Start_IT(&htim1); it resets and also systick handler does not happen. I verified the systick handler without the timer interrupt as well.

Ozone
Principal
June 18, 2026

As said, I don’t use Cube/HAL, nor CubeIDE.

Have you stepped into the HAL_Init() code, to see if Systick is initialized ?

Or stop before entering the “while (1)” loop in main, and check in the peripheral view if the Systick registers are initialized.

If I’m not mistaken, you can set another timer than Systick to drive the Cube/HAL timings.

STuser2Author
Senior III
June 18, 2026

I will check it now and post my observations. 

STuser2Author
Senior III
June 18, 2026

This code is commented but still executing. The file is core_cm4.h. 

 

Ozone
Principal
June 18, 2026

> This code is commented but still executing. The file is core_cm4.h. 

What you see in the CubeIDE is the interpretation of the editor’s parser, but not of the compiler. 
I’m pretty sure you could set a breakpoint there, and it will work.
Those parsers usually do not see #defines that don’t come from include files but from makefiles or other meta-files (like__Vendor_SysTickConfig in this case).

At least the register values suggest it is executed, as all required flags are set, and the reload value seems plausible.
You can try to locate the actual interrupt handler (somewhere in the Cube code), and set a breakpoint there and see if it fires.
And check if respective HAL delay routines get called.

Andrew Neil
Super User
June 18, 2026

 if i enable the timer1 interrupt (i assume enable any interrupt) the code is reset. 

What, exactly, do you mean by “the code is reset” here ?

 

These are the settings when i read from the stlink utility

The STLink Utility has long been obsolete - it was probably obsolete before the G0 was introduced.

 

Have you tried using STM32CubeProgrammer ?

 

You haven’t said what versions of CubeMX or CubeIDE you’re using.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
STuser2Author
Senior III
June 18, 2026

 

The CubeMx version is

I like using STLink Utility may be i will switch over to ST Cube Programmer.

Andrew Neil
Super User
June 18, 2026

 if i enable the timer1 interrupt (i assume enable any interrupt) the code is reset. 

What, exactly, do you mean by “the code is reset” here ?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
STuser2Author
Senior III
June 18, 2026

 

Once the code is executed after line 96 the control is lost and does not execute the next instructions.

Andrew Neil
Super User
June 18, 2026

Once the code is executed after line 96 the control is lost and does not execute the next instructions

It must be executing instructions somewhere - a microcontroller doesn’t just stop.

If you let it run in the debugger, then halt it - where is it?

 

My guess would be that it’s in the Default Handler - which is an infinite loop - because you haven’t provided a handler for the timer interrupt.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
STuser2Author
Senior III
June 18, 2026

Strangely when i cross verified with some of the older projects i found this missing

static void MX_NVIC_Init(void); Need to use older version of Cube mx and generate code. I am not sure if that is the problem.

 

STuser2Author
Senior III
June 18, 2026

I have changed to CubeMx 13.0 no change

Do you recommend changing the controller? I mean is the controller damaged?