Du must das Bit AFIOEN Bit 0 im RCC_APB2ENR erst setzen
APB2 peripheral clock enable register (RCC_APB2ENR)

Bit 0 AFIOEN: Alternate function IO clock enable
Set and cleared by software.
0: Alternate Function IO clock disabled
1: Alternate Function IO clock enabled

Siro