2023-11-21 11:45 PM
Hi, I have a pin labeled "DISABLE_HV" that I want switch between open drain and ground (and vice versa) to switch-off and switch-on a DC-DC converter. How can I implement this functionality in the code using HAL library?
Solved! Go to Solution.
2023-11-22 01:08 AM
Hello @ECiot.1 ,
When you said "open drain" do you mean floating?
I that case to switch from floating to ground you need to configure the pin in output open-drain.
So when you set the pin to 1 in ODR it goes to floating. When you set the pin to 0 in ODR it switches to ground.
2023-11-22 12:57 AM
"Open drain" is a setting of the GPIO output structure, which simply disables the upper transistor of the output structure. It means, if you set a pin to GPIO Output in GPIO_MODER and Open drain in GPIO_OTYPER, if you write 1 to respective bit in GPIO_ODR (directly or through GPIO_BSRR), the pin is floating; if you write 0 to that ODR bit, the pin is switched to ground.
JW
2023-11-22 01:08 AM
Hello @ECiot.1 ,
When you said "open drain" do you mean floating?
I that case to switch from floating to ground you need to configure the pin in output open-drain.
So when you set the pin to 1 in ODR it goes to floating. When you set the pin to 0 in ODR it switches to ground.
2023-11-22 03:26 AM
Yes I want to switch between floating and ground. Then if I write HAL_GPIO_WritePin(DISABLE_HV_GPIO_Port, DISABLE_HV_Pin, GPIO_PIN_SET) I obtained the pin floating and if I write HAL_GPIO_WritePin(DISABLE_HV_GPIO_Port, DISABLE_HV_Pin, GPIO_PIN_RESET) I obtained the pin to ground, is it correct?
2023-11-22 04:57 AM
Yes, that's correct.