2020-11-14 01:28 AM
does any body know how to define a pin in CubeMX, so it would be GPIO_INPUT and GPIO_OUT at the same time?
I want to write to a pin and read it's state too
Solved! Go to Solution.
2020-11-14 02:29 AM
Yes, exactly. Take a note that you can read both - ODR and IDR registers. Normally they will show the same values, but theoretically in case of some short circuit, IDR will show the actual physical level of the pin. If it will still function... :)
2020-11-14 01:58 AM
You can always read the digital state of the pin, unless it's set as analog.
So, simply leave it as Out.
JW
2020-11-14 02:11 AM
So if I define it as GPIO_OUTPUT, I can both read this pin and write it as HIGH/LOW?
2020-11-14 02:29 AM
Yes, exactly. Take a note that you can read both - ODR and IDR registers. Normally they will show the same values, but theoretically in case of some short circuit, IDR will show the actual physical level of the pin. If it will still function... :)
2020-11-14 04:06 AM
> ODR and IDR registers. Normally they will show the same values
They may differ not only in pathological cases, but also if the given ouput pin is set as Open Drain.
JW
2020-11-14 04:20 AM
Indeed. Good point!