Skip to main content
Ala
Senior
Nov 14, 2020 9:28 AM UTC
Solved

GPIO INPUT/OUTPUT

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

This topic has been closed for replies.
Piranha
PiranhaBest answer
Principal III
Nov 14, 2020 10:29 AM UTC

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... :)

5 replies

waclawek.jan
Super User
Nov 14, 2020 9:58 AM UTC

You can always read the digital state of the pin, unless it's set as analog.

So, simply leave it as Out.

JW

Ala
AlaAuthor
Senior
Nov 14, 2020 10:11 AM UTC

So if I define it as GPIO_OUTPUT, I can both read this pin and write it as HIGH/LOW?

Piranha
PiranhaBest answer
Principal III
Nov 14, 2020 10:29 AM UTC

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... :)