Control onboard LED via PWM on STM32F4 Discovery board (HAL library)
The alternate functions cannot be freely mapped.

LD4 is green led on PD12, and PD12 does not have an alternative feature that maps to TIM2.

However, it can be mapped to Timer 4.