2019-04-05 09: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.
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
Both should work. The second one can use BSRR register.
2019-04-05 09:31 AM
It should be reporting level seen on the pin, via the schmitt trigger on the input.
2019-04-05 09: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.
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
Both should work. The second one can use BSRR register.
2019-04-05 03:28 PM
Thank you,
sounds great. So, it should work.
Many regards
Torsten