cancel
Showing results for 
Search instead for 
Did you mean: 

stm32g474 interrupt problem

RHert.1
Associate II

Hi all

I have a problem with interrupts on my STM32G474VEH6 based board. Timer 6 generates an interrupt every 1ms.

Program crash at HAL_TIM_Base_Start_IT(&htim6);

But after resetting the power of the board, the software starts working correctly.

The same code works fine on Nucleo-g474re.

Generate code with STM32CubeMX 6.6.1

IDE: Visual Studio 2022 with VisualGDB 5.6R8 build 4723.

Tested on STM32CubeIDE 1.10.1 same result.

Thanks in advance for your help

5 REPLIES 5
Bob S
Principal

What have you done to debug the crash? What exactly does "crash" mean? Does it reboot? Get stuck in a loop somewhere? End up in a fault handler? Make sure you have code for the fault handlers besides the default "jump here" infinite loop. Debugging in CubeIDE should catch the faults and decode the fault registers and show you the stack backtrace.

RHert.1
Associate II

The program enters a function and gets stuck inside without exiting.

Nothing happens. Еverything is stuck.

The system is not reset.

When I do a step by step in the HAL_TIM_Base_Start_IT() everything goes through but the interrupt doesn't fire.

Bob S
Principal

OK, so it gets stuck in a function. When you halt the CPU - where is it in that function? What is it trying to do or what it is waiting for? Is the TIM6 interrupt handler (or the callback functions to your code) looking for variables that are not yet initialized? Is there some oscillator that is slow to start and your program doesn't wait long enough?

RHert.1
Associate II

Hi Bob

When I stop the MCU it stops at "IS_TIM_SLAVE_INSTANCE(htim->Instance)".

0693W00000WLOgBQAX.pngOne more point: if I try to "reset the device" (not reload), the system won't enter for debugging, it looks like the MCU won't start after the reset. The same happens if I check "Reset device after programming"

BR

Roman

Try this on a "known good" board such as Nucleo.

> STM32G474VEH6 based board

Check (physically, i.e. measuring directly at the pins) all VDD/GND connections, including analog. Check the boot pins/bits settings according to AN2606 to prevent inadvertent bootloader entry.

JW