cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 TIM5_CH1 output routed to wrong pin (PA1 instead of PA0)

sumeyyekaragul
Associate

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!

5 REPLIES 5
TDK
Super User

> an STM32H7 board

Which board? Which chip? Consult the schematic. Probably PA0/PA1 have been mismatched somehow.

> What could cause TIM5_CH1 output to be redirected from PA0 to PA1?

Nothing will cause this; the problem is elsewhere. The code you showed will initialize PA0. No problems there.

If you feel a post has answered your question, please click "Accept as Solution".

Thank you for your answer.

Which board?

STM32 Nucleo-144 development board with STM32H743ZI2 MCU

I’m not sure if it’s a user-related issue. As I mentioned, the situation is the same on different channels, and no matter which pin I initialize, the output always appears on pa1.

Hello,

Please share your ioc file or even your complete project and what CubeMx version are you using?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Also share what pin you're measuring the signal on with a picture. Probably just using the wrong pin and/or it's mislabeled in the reference you're using.

If you feel a post has answered your question, please click "Accept as Solution".
TDK
Super User

> As I mentioned, the situation is the same on different channels, and no matter which pin I initialize, the output always appears on pa1.

Probably you are not running the code that you think you're running.

If you feel a post has answered your question, please click "Accept as Solution".