GPIO INPUT/OUTPUT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-14 1: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.
- Labels:
-
GPIO-EXTI
-
STM32CubeMX
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-14 2: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... :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-14 1: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-14 2:11 AM
So if I define it as GPIO_OUTPUT, I can both read this pin and write it as HIGH/LOW?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-14 2: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... :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-14 4: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-14 4:20 AM
Indeed. Good point!
