2025-04-08 2:57 AM
I've discovered that when I configure the TIM2 timer to ‘input Capture direct mode’ for any port A input pin it doesn’t add the necessary line in HAL_TIM_Base_MspInit() to configure the pin to alternate mode, namely the following line is missing in HAL_TIM_Base_MspInit():
‘GPIO_InitStruct.Alternate = GPIO_AF1_TIM2;’
The line is present when port B is selected, so that works.
My work-around (for PA0) is to add the line to the main code:
GPIOA->AFR[0] |= (1U << GPIO_AFRL_AFSEL0_Pos);
I'm using Stm32CubeMX v.6.14.0 with STM32Cube_FW_U0_V1.2.0
2025-04-08 3:07 AM
Is it just TIM2, or also other Timers?
2025-04-08 6:32 AM
I've not investigated the others as TIM2 is the one I'm using and my work-around is OK. I thought I should report it though in case it helps others.