I'm using this Microcontroller S32K142 64 pin.
In the reference manual, I can see a lot of pins which I assume to be Output only are mentioned as Input / Output. For example, the Microcontroller is the master I2C Clock. So, in that case, the clock can only be output, right? But why is it given as I/O?
1 Answer 1
Most I2C devices allow clock stretching, by which the slave can 'slow down' a bit when it can't catch up with the speed of SCLK generated by the master.
The slave does that so by stretching the SCLK line low after receiving/sending a byte (the master relinquishes the control on SCLK at this time). The slave pulls the clock back to high when it's ready to process the next byte. The master detects this and takes the control of SCLK again, and the communication resumes.
In such I2C devices, SCLK also has to be a bidirectional line (open-drain/open-collector).
Also being I/O SCLK pin, this gives the flexibility of configuring the I2C device as either master/slave.
-
2\$\begingroup\$ Additionally, I2C seems to be only one possible fucntion of this pin. For most chips, a pin that can do I2C can also be programmed as GPIO. \$\endgroup\$Wouter van Ooijen– Wouter van Ooijen2021年05月20日 17:34:49 +00:00Commented May 20, 2021 at 17:34
-
\$\begingroup\$ @WoutervanOoijen I don't think you are correct. That list looks like a list of what all functions are available as alternate functions for the PTA3 pin, and LPI2C0_SCL is only one of the alternate functions for this PTA3 pin. \$\endgroup\$Justme– Justme2021年05月20日 20:03:18 +00:00Commented May 20, 2021 at 20:03
-
\$\begingroup\$ I haven't read this one, but in most datasheets 'alternate' means 'apart from GPIO'. \$\endgroup\$Wouter van Ooijen– Wouter van Ooijen2021年05月21日 16:28:10 +00:00Commented May 21, 2021 at 16:28