STM32 gotchas
140. Not all TIM2/TIM5 are created equal (in some STM32 they are not 32-bit)

All STM32 models (but the smallest 'L0) have a selection of at least half a dozen of timers. They vary in capabilities, but ST tends to maintain the same name (number) for similar capability timer across all families.

For example, in most STM32 models, TIM2 and TIM5 are 32-bit timers - this is in contrast to the fact that most timers are 16-bit. However, there are exceptions to this unwritten "rule" - and when migrating between families, these may come as an unpleasant surprise.

In this particular case, in the 'L0 and 'F1 families, TIM2 and TIM5 are 16-bit too, and there are no 32-bit timers in 'L0 and 'F1. In 'L1, TIM2 is 16-bit, and TIM5 is 32-bit, but TIM5 is not available in all 'L1 models.

A great overview of timers' capabilities, and their availability in all STM32 families, is in AN4013.