cancel
Showing results for 
Search instead for 
Did you mean: 

Open Drain output readable as input (external signal level)?

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

1 ACCEPTED SOLUTION

Accepted Solutions
S.Ma
Principal

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.

View solution in original post

4 REPLIES 4

It should be reporting level seen on the pin, via the schmitt trigger on the input.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

If you look at the IO cell diagram, there isn't an internal connection between ODR and IDR, IDR reports the external level.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
S.Ma
Principal

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.

Thank you,

sounds great. So, it should work.

Many regards

Torsten