I see in the errata for LPC176x that it is impossible to set a pin to open drain-mode unless it set as GPIO. How does that work if the pin is set to I2C mode?
Solved! Go to Solution.
Although the user manual states otherwise, setting the pin to open-drain mode manually in PINMODE_ODx is not required for I2C functions. As soon as you select one of SDA1, SCL1, SDA2, SCL2 for a pin in PINSELx, the corresponding output stage is forced into open-drain mode.
This is why the GPIO.1 erratum doesn't affect you when using I2C1 and I2C2.
Hi,
I've attached the I2C pins initialization function, please refer to it.
/* Sets up board specific I2C interface */
void Board_I2C_Init(I2C_ID_T id)
{
switch (id) {
case I2C0:
Chip_IOCON_PinMux(LPC_IOCON, 0, 27, IOCON_MODE_INACT, IOCON_FUNC1);
Chip_IOCON_PinMux(LPC_IOCON, 0, 28, IOCON_MODE_INACT, IOCON_FUNC1);
Chip_IOCON_SetI2CPad(LPC_IOCON, I2CPADCFG_STD_MODE);
break;
case I2C1:
Chip_IOCON_PinMux(LPC_IOCON, 0, 19, IOCON_MODE_INACT, IOCON_FUNC2);
Chip_IOCON_PinMux(LPC_IOCON, 0, 20, IOCON_MODE_INACT, IOCON_FUNC2);
Chip_IOCON_EnableOD(LPC_IOCON, 0, 19);
Chip_IOCON_EnableOD(LPC_IOCON, 0, 20);
break;
case I2C2:
Chip_IOCON_PinMux(LPC_IOCON, 0, 10, IOCON_MODE_INACT, IOCON_FUNC2);
Chip_IOCON_PinMux(LPC_IOCON, 0, 11, IOCON_MODE_INACT, IOCON_FUNC2);
Chip_IOCON_EnableOD(LPC_IOCON, 0, 10);
Chip_IOCON_EnableOD(LPC_IOCON, 0, 11);
break;
}
}
Have a great day,
Ping
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Ping,
thank's for the example but it did not really answer my question.
In your code you set the I2C-pins in open drain mode (Chip_IOCON_EnableOD(LPC_IOCON, 0, 11)
but according to the errata this is not possible if the pin is not used as a GPIO. So the question is, will it automatically be an OD when used as I2C. Otherwise there might be problems.
However, I can use the I2C interface without problem, but I would still know what gives in this case and any other setup of functions.
Although the user manual states otherwise, setting the pin to open-drain mode manually in PINMODE_ODx is not required for I2C functions. As soon as you select one of SDA1, SCL1, SDA2, SCL2 for a pin in PINSELx, the corresponding output stage is forced into open-drain mode.
This is why the GPIO.1 erratum doesn't affect you when using I2C1 and I2C2.
Thank you Rolf.
Just want I wanted to hear!
Regards
Mike