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

PSoC™ 6 Forum Discussions

vivekatamantya
Level 1
5 sign-ins First reply posted First question asked
Level 1

Hello all,

I am using the CY8CKIT-062S4 PSoC6 kit for I2C communication with a device. In this case, the PSoC6 kit is an I2C master device and the other device is an I2C slave.|

Now, coming to the problem, actually, the I2C slave device is already having the pull-up resistors to 3.3V. 

vivekatamantya_0-1658144181857.png

as you can see in the above picture. Now, I am connecting the PSoC 6 device to this device using the J20 pin header as J20.1 to Vcc (3.3V), J20.2 as SCL, J20.3 as SDA, and J20.4 as GND (0V).

As the slave device is already having the pull-up resistors so, I am initializing the PSoC6 SCB0 block as follows (using the PDL library),

Cy_GPIO_SetDrivemode(I2C_Channel_SCL_PORT, I2C_Channel_SCL_NUM, CY_GPIO_DM_OD_DRIVESLOW);
Cy_GPIO_SetDrivemode(I2C_Channel_SDA_PORT, I2C_Channel_SDA_NUM, CY_GPIO_DM_OD_DRIVESLOW);

The problem with the interface of this I2C slave is that the I2C master should support the I2C multi-master to interface this slave device. But the thing is that I haven't seen any words which show that this PSoC kit microcontroller supports I2C multi-master.

Now, coming back to the real problem, after successfully initializing the I2C block of the PSoC 6 device, when I am trying to write to the slave device, after writing one byte of data, the I2C master remains busy, I didn't get the I2C_MASTER_WRT_COMPLETE callback also, after writing that, the SDA pin keeps low and never high, so after that, I am unable to do anything, please help me to resolve the problem.

I am initializing the I2C at 400kbps and config is as follows: 
.i2cMode = CY_SCB_I2C_MASTER,
.useRxFifo = false,
.useTxFifo = true,
.slaveAddress = 0U,
.slaveAddressMask = 0U,
.acceptAddrInFifo = false,
.ackGeneralAddr = false,
.enableWakeFromSleep = false,
.enableDigitalFilter = false,
.lowPhaseDutyCycle = 16,
.highPhaseDutyCycle = 9,

The I2C read and write of the I2C slave are as follows:

vivekatamantya_1-1658144797694.png



Thank you.

Regards,
Vivek Karna

0 Likes
1 Solution
PandaS
Moderator
Moderator 25 solutions authored 10 likes received 50 replies posted
Moderator

Hi @vivekatamantya ,

Can you probe a logic analyzer and check the process.

1. Check if the I2C lines are pulled to low.

2. If that is the case, it might be due to clock stretching, slave is pulling the line low. And after sometime timeout occurs.

 

Warm Regards

Sobhit

View solution in original post

0 Likes
3 Replies
PandaS
Moderator
Moderator 25 solutions authored 10 likes received 50 replies posted
Moderator

Hi @vivekatamantya ,

I have recently worked on a similar issue on the following thread.

https://community.infineon.com/t5/PSoC-4/PSoC4S-MAX-How-to-use-Cy-SCB-I2C-MasterSendStart-quot-API/t...

You might be missing some initialization steps. If I am not wrong , you are using PDL. So there are two types of APIs - High level APIs(Interrupt is necessary) and Low level APIs(Interrupt is not required). 

https://infineon.github.io/psoc6pdl/pdl_api_reference_manual/html/group__group__scb__i2c.html

Follow the code example I have for configuring the I2C peripheral. If you still face the problem, feel free to let us know.

 

Thanks and Regards

Sobhit

0 Likes
vivekatamantya
Level 1
5 sign-ins First reply posted First question asked
Level 1

Hello @PandaS,

Thank you for your reply.

I have to use interrupt for the I2C device block, so I have to use High-Level API for the I2C master. 

vivekatamantya_0-1658153703705.png

I am using the above Master Write and Master Read API to perform the above example. But after 1 successful writing, the Master is busy and sometimes, the bus is busy. I have followed all the example of PDL library for I2C and following the same procedure as done in that.

Regarding your thread, I had tried low-level API also, but after sending start bit, it writes 3 bytes of data but doesn't get SUCCESS after writing that and it get MASTER_BUSY and it comes out from that. So, that also didn't work.

Thank you.

Regards,
Vivek Karna

0 Likes
PandaS
Moderator
Moderator 25 solutions authored 10 likes received 50 replies posted
Moderator

Hi @vivekatamantya ,

Can you probe a logic analyzer and check the process.

1. Check if the I2C lines are pulled to low.

2. If that is the case, it might be due to clock stretching, slave is pulling the line low. And after sometime timeout occurs.

 

Warm Regards

Sobhit

0 Likes