Open Drain output readable as input (external signal level)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-04-05 9:28 AM
I have not tried, I would need this 'feature':
Have a GPIO pin configured as Open Drain output, driven by the MCU. If MCU sets it to high but on the outside an external chip drives it low - could I read the status on the external pin without to change the direction of the GPIO?
Do I see the signal level on the pin or would I read back my '1' I have written to output register?
(I know, I can read back on outputs, but my understanding is: it reads back the output register value, not really the signal level, e.g. if there would be a short.)
Why: Assume I would try to implement an I2C in GPIO mode (I would need 4 Mbps which is not supported by the native I2C peripheral). So, for the SDA line I use Open Drain out. But during the phase for the ACK/NACK bit which is driven by the external I2C slave, I want to read how this external SDA signal is driven, e.g. low for ACK.
Changing the direction of MCU GPIO pin all the time, in order to read the SDA input for 1 clock period, would be time consuming and creates overhead on my 'I2C GPIO pattern'.
So, reading back the external signal level on a GPIO output (instead of reading back the output register value) would be great.
Maybe somebody knows or has done already (before I will try it).
Thank you.
Torsten Jaekel
Solved! Go to Solution.
- Labels:
-
GPIO-EXTI
-
STM32H7 series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-04-05 10:06 AM
Reading the pin level can be done anytime it's reporting the pin level (in digital mode).
So you have 2 options
- Program output as open drain low level and turn as input when you want to release the line and read the pin level (after rise time by external pull up is completed)
- Program output as open drain as high or low
Both should work. The second one can use BSRR register.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-04-05 9:31 AM
It should be reporting level seen on the pin, via the schmitt trigger on the input.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-04-05 9:33 AM
If you look at the IO cell diagram, there isn't an internal connection between ODR and IDR, IDR reports the external level.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-04-05 10:06 AM
Reading the pin level can be done anytime it's reporting the pin level (in digital mode).
So you have 2 options
- Program output as open drain low level and turn as input when you want to release the line and read the pin level (after rise time by external pull up is completed)
- Program output as open drain as high or low
Both should work. The second one can use BSRR register.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-04-05 3:28 PM
Thank you,
sounds great. So, it should work.
Many regards
Torsten
