STM32H7 TIM5_CH1 output routed to wrong pin (PA1 instead of PA0)
Hi everyone,
I’m trying to generate a square wave using TIM5 Output Compare (OC) on an STM32H7 board. I configured TIM5_CH1 to output on PA0, both in CubeMX and manually in HAL_TIM_MspPostInit(). Here is a snippet of my GPIO init:
GPIO_InitStruct.Pin = GPIO_PIN_0;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF2_TIM5;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);And the TIM5 channel configuration:
sConfigOC.OCMode = TIM_OCMODE_TOGGLE;
sConfigOC.Pulse = 3749;
HAL_TIM_OC_ConfigChannel(&htim5, &sConfigOC, TIM_CHANNEL_1);
The problem is that the square wave always appears on PA1, not PA0, even though I haven’t configured TIM5_CH2 anywhere.
I checked the datasheet pin mapping:
PA0 → TIM5_CH1
PA1 → TIM5_CH2
PA2 → TIM5_CH3
PA3 → TIM5_CH4
I suspect this might be related to alternate function routing or some hardware conflict on PA0 (maybe boot/debug pins), but I’m not sure.
Has anyone seen this behavior on STM32H7? What could cause TIM5_CH1 output to be redirected from PA0 to PA1?
Thanks in advance!
