STM32 gotchas
48.TIMx_CHxN cannot be used for input capture

Timers in STM32 have only a single counting element, but they have several multipurpose channels, which can be set as either capture or compare. Those channels have associated pins through the AF matrix in GPIO, the respective pins being designated as TIMx_CHx (e.g. TIM2_CH1 for the pin corresponding to Channel 1 of Timer 2).

The "direction" of the pins set in GPIO_MODER as AF and assigned to TIMx in respective GPIO_AFR, is controlled from the timer: if the respective channel is set to Input Capture (in TIMx_CCMRx.CCxS), it acts as an input (its output drivers are disabled); if it is set to Output Compare in TIMx_CCMRx.CCxS, it functions as an output (its output drivers are enabled pending other timer control bits, such as TIMx_CCER.CCxE or in case of Advanced timers, TIMx_BDTR.MOE).

In Advanced Timers, such as TIM1, TIM8, TIM20, TIM16/TIM17 etc, some channels have also a complementary output pin, TIMx_CCxN. These usually output an inverted version of TIMx_CCx waveform (with optional deadtime inserted), but they can function standalone, too. While from this fact it would appear that these pins can then be a replacement for respective TIMx_CCx, so, by extension, that they can in some circumstances (e.g. if TIMx_CCx are not used or even not available on some packages) be used as input for Input Capture on that channel, this is not the case.

TIMx_CHxN cannot be used for Input Capture.