Cannot drive I2C SDA pin to low

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
yaga_3967241
Level 3
Level 3
50 sign-ins 25 sign-ins 10 replies posted

Hello,

I am using PSoC LP5 and have a I2C master using UDB as in below picture. I2C3_SDA pin is bidirectional, open drain drives low. The pin connects a pull up registers which is not in the picture. When I set I2C3_SDA pin using pin API I2C3_SDA_Write(0) or CyPins_ClearPin(I2C3_SDA_0), the pin measurement is always high. If I disconnect the pin from the I2C component, I can set it to low using same API.

My question is: Why I2C3_SDA pin cannot be set to low when connecting to I2C component?

Regards,

Winston

yaga_3967241_0-1640138835600.png

 

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.

Hi @yaga_3967241 ,

>> it complains I2C needs a bidirectional pin while Mux is not bidirectional
You will get this error as the SDA and SCL pins of the I2C UDB component are bidirectional so only a bidirectional pin can be connected to the same where as the MUX requires an input pin and not a bidirectional pin.

I believe you want to use the I2C SDA and SCL pins here as a GPIO right?
For this you will have to modify some of the internal registers so that you can convert the SDA and SCL pins to GPIO when required and back to I2C pins when  required to use I2C.

I have attached here a sample code which shows you how you can set the SDA and SCL lines as GPIO and toggle the same using the write APIs and later switch them back to I2C (after switching to I2C you can no longer toggle them using the write API's)

Let me know if this helps.
Regards
Alen

View solution in original post

0 Likes
4 Replies
AlenAn14
Moderator
Moderator
Moderator
500 replies posted 100 solutions authored 250 replies posted

Hi @yaga_3967241 ,

The I2C UDB component requires that the SDA and SCL pins to be bidirectional hardware pins.
If you check the Digital IO pin data sheet you can see the following for the pin write API:

AlenAn14_0-1640165603011.png

In the Note it is mentioned that this API should not be used with a hardware digital output pin as it is driven by the hardware signal attached to it, which in this case is the I2C UDB Component.

Hence you will not be able to set the state of this pin from firmware if the same is connected to another component as a hardware connection.

Regards
Alen

0 Likes
yaga_3967241
Level 3
Level 3
50 sign-ins 25 sign-ins 10 replies posted

Hi Alen,

Thanks for the prompt reply. I need to use the I2C3_SDA pin for other purpose in some cases, so I tried to disconnect the I2C3_SDA pin from the I2C component in certain case. I tried to use Mux line in below image. But as you mentioned, it complains I2C needs a bidirectional pin while Mux is not bidirectional. So is there a way to use I2C3_SDA pin while its I2C function is not needed?

Thanks,

Winston

yaga_3967241_0-1640206550188.png

 

0 Likes

Hello.

I've done this with PSoC4, which has HSIOM hence slightly different implementation versus PSoC5 DSI.  I've not tried this with PSoC5.

You can find some PSoC4 details here:
Manual Use of Pin After SCB Disable - Infineon Developer Community

For PSoC5 you control the GPIO output function by using the mux built into the GPIO pin block.  You do this by writing to the Port Pin Configuration Register, PRT[0..14]_PC[0..7].  Bit 7 is the bypass bit.  Do the bypass after you disable I2C.

I would suggest you observe the port pin config registers while config'd for I2C.  Then, disconnect I2C and use those GPIO's as GPIO's and observe the pin config registers.  Make a note of the differences so s/w can go back and forth between the 2 configurations.

And, read the appropriate sections of 5LP Technical Reference Manual and the 5LP Registers Technical Reference Manual.

lock attach
Attachments are accessible only for community members.

Hi @yaga_3967241 ,

>> it complains I2C needs a bidirectional pin while Mux is not bidirectional
You will get this error as the SDA and SCL pins of the I2C UDB component are bidirectional so only a bidirectional pin can be connected to the same where as the MUX requires an input pin and not a bidirectional pin.

I believe you want to use the I2C SDA and SCL pins here as a GPIO right?
For this you will have to modify some of the internal registers so that you can convert the SDA and SCL pins to GPIO when required and back to I2C pins when  required to use I2C.

I have attached here a sample code which shows you how you can set the SDA and SCL lines as GPIO and toggle the same using the write APIs and later switch them back to I2C (after switching to I2C you can no longer toggle them using the write API's)

Let me know if this helps.
Regards
Alen

0 Likes