Recently I spent some time solving the problem of incorrect CPU operation. After generating the project (completely basic, only TIM6 set as TimeSource for HAL), the program diverged when trying to enter the interrupt from TIM6 (I'm guessing). Known Issue: Signal Handler on 0xFFFFFFF9.
To confirm the problem, a colleague generated a similar project on another computer and received the same situation.
Running the example, however, did not cause such situations. However, generating a new project based on the *ioc file from the example again caused the above-mentioned problem.
It turned out that the following line of code was missing in the "system_stm32g4xx.c" file in the SystemInit() function:
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET;
Tested on HAL library version 1.4.0 - 1.5.1
If the issue is known, sorry for spamming.
This seems to be a bug in the template system_stm32g4xx.c : missed `#else` after `#if defined(USER_VECT_TAB_ADDRESS)`
As alternative, Cube should define USER_VECT_TAB_ADDRESS in the project settings (and it must match the target address).
This is a deliberate design choice by ST. Unfortunately, they don't consider this a bug.
The solution is to #define USER_VECT_TAB_ADDRESS in your system_*.c file. By default it is commented out.