Hello Carl_G,
Thank you for your observation regarding the behavior of TIM2 and the HSI in STOP mode. Based on the information provided from our G0 reference manual, there are some points to be considered when using low-power modes:
- Enabling debugging in STOP mode allows the internal RC oscillator (likely the HSI) to continue feeding the system clocks (FCLK and HCLK). This is necessary to maintain the debugger connection and functionality
- Argument: According to section 40.9.1 (already mentioned in Debug section), the core does not allow FCLK or HCLK to be turned off during a debug session is enabled. This is because these clocks are required for the debugger connection, and during a debug session, they must remain active. The MCU integrates debug allowing the user to debug software in low-power modes (But it is just an emulation).
- Best practice to enter STOP mode: To ensure that the HSI and TIM2 stop as expected in STOP mode, you should disable the debug feature in STOP mode. This can be done by clearing the DBG_STOP bit.

I hope this answer meets your needs. If you have any further questions or need additional assistance, please feel free to reach out.