2022-03-21 12:15 PM
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?.
2022-03-21 01:16 PM
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
2022-03-21 02:11 PM
> nothing works.
Initializing the pin as input will set it to high impedance. How are you determining that it isn't?