Skip to main content
Ala
Senior
November 14, 2020
Solved

GPIO INPUT/OUTPUT

  • November 14, 2020
  • 1 reply
  • 1442 views

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.
Best answer by Piranha

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

1 reply

waclawek.jan
Super User
November 14, 2020

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
November 14, 2020

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
November 14, 2020

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