Maybe you misidentified your pins.
This is for a g031 nucleo board, not much different, and works for either pin-
#include "MyStm32.hpp"
int main(){
RCC->APBENR2 |= 1<<18; //TIM17 clock enable
TIM17->CCMR1 = 1;//TI1, (PA7/AF5 or PB9/AF2)
TIM17->CCER = 1; //capt enable
TIM17->CR1 = 1; //TIM17 enable
GpioPin( PINS::PA7 ).altFunc( AF5 ); // normally a pull wanted so no floating pin-> .pull( PULLDOWN )
//GpioPin( PINS::PB9 ).altFunc( AF2 ); //but floating in this case means we can just touch the pin to get transitions
while(1){
uart << "TIM17 CCR1: " << TIM17->CCR1 << endl;
//shows capture values ok
}
}
The only thing happening in the pin init is rcc enable for port, and setting the afr register then changing mode to alternate.
edit- Also, if both pins are set to alternate function both become an input to the timer capture.