cancel
Showing results for 
Search instead for 
Did you mean: 

I am using the STM MCU timer for PWM. This PWM signals goes as input to external MOSFET configured as push pull. So I want the timer pin to be in high impedance state during some instance of time and rest of the time give the PWM output signal.

anu2083
Associate

I tried the following functions to make the timer pin high impedance, but nothing works:-

          __HAL_TIM_DISABLE(&htim3);

          TIM_CCxChannelCmd(&htim3, TIM_CHANNEL_3, TIM_CCx_DISABLE);

          __HAL_TIM_MOE_DISABLE(&htim3);

I also tried to configure the pin as input, but nothing works.

          GPIO_InitTypeDef GPIO_InitStruct = {0};

          GPIO_InitStruct.Pin = TIM3_CH3_PIN;

          GPIO_InitStruct.Mode = GPIO_MODE_INPUT;

          GPIO_InitStruct.Pull = GPIO_NOPULL;

          HAL_GPIO_Init(TIM3_CH3_PORT, &GPIO_InitStruct);

Can some suggest how I can use the timer pin as PWM and at some other time, put the same pin in high impedance state?.

2 REPLIES 2

Which STM32?

Which pin?

The easiest way is to change the pin to Input in its GPIOx_MODER field. Other way is to disable it by clearing its respective TIMx_CCER.CCxE bit. These are simple register manipulation and you can try to perform them also in the debugger, before writing any code.

Some of the Cube/HAL/SPL "commands" you threw around may do the same, but you'd need to debug them, which leads exactly to the same register manipulations and observing the results in debugger.

TIM3 does not have TIMx_BDTR, thus you can't disable its output by setting TIMx_BDTR.MOE. Only Advanced timers have it.

JW

TDK
Guru

> nothing works.

Initializing the pin as input will set it to high impedance. How are you determining that it isn't?

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