cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H723VG using Timer outputs as GPIO Output

CBerg
Senior

Hi community!

I have a STM32H723VG and I use Timer1 on that device to generate complementary PWM Outputs (Chx + ChxN) on channel 1-3 plus a 1-channel PWM on Channel 4. When the PWM is not needed, I have to set the output pins of the timer either high or low. My idea was to re-configure the Timer output pins as GPIOs, then I can use HAL_GPIO_WritePin() to set the output states.

The procedure is as follows: I stop the PWM by stopping all 4 channels with

HAL_TIM_PWM_Stop_IT(&htim1, TIM_CHANNEL_4);
HAL_TIM_PWM_Stop(&htim1, TIM_CHANNEL_1);
HAL_TIMEx_PWMN_Stop(&htim1, TIM_CHANNEL_1);
HAL_TIM_PWM_Stop(&htim1, TIM_CHANNEL_2);
HAL_TIMEx_PWMN_Stop(&htim1, TIM_CHANNEL_2);
HAL_TIM_PWM_Stop(&htim1, TIM_CHANNEL_3);
HAL_TIMEx_PWMN_Stop(&htim1, TIM_CHANNEL_3);

 

Then I use >>HAL_GPIO_Init()<< to re-configure the pins as GPIOs

GPIO_TypeDef * GPIO_port = GPIOE;
uint16_t GPIO_Pin = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13;
HAL_GPIO_WritePin(GPIO_port, GPIO_Pin, GPIO_PIN_RESET);

// fill GPIO Init Struckt - set Pins as Output Push-Pull
GPIO_InitTypeDef GPIO_InitStruct = {0};
GPIO_InitStruct.Pin = GPIO_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIO_port, &GPIO_InitStruct)


After that I can use HAL_GPIO_WritePin(...) to set the Pin state, e.g.

HAL_GPIO_Init(GPIOE, GPIO_PIN_12, GPIO_PIN_SET)


This works perfect on Pins 8, 9, 10, 11 and 13. But not on Pin 12 (PE12 / Timer Channel 3).
If I set this pin to HIGH, it goes high for ~500 ns, then it goes low again.

 

Has anyone an idea, why PE12 is behaving different than the other 5? What could I do to change that?

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
CBerg
Senior

Solved: The code is OK. The Reason was a broken wire.

The answer to my question is: replace the broken wire with a new one (not broken) and measure again.

View solution in original post

1 REPLY 1
CBerg
Senior

Solved: The code is OK. The Reason was a broken wire.

The answer to my question is: replace the broken wire with a new one (not broken) and measure again.