cancel
Showing results for 
Search instead for 
Did you mean: 

port A pins not correctly configured for input capture

kswST
Associate

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

2 REPLIES 2

Is it just TIM2, or also other Timers?

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.
kswST
Associate

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.