PSoC4 I2C

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

cross mob
SaGh_4441651
Level 3
Level 3
First like received First like given

I need to configure to use 1 I2C both as master and slave. At first the I2C is configured as master and then once the master is done sending data, it is configured as slave. I am thinking of using a SCB block and then switching between the configuration. Is it possible to do so?

0 Likes
1 Solution

Yes, if you use the unconfigured SCB.  The function SCB_I2CInit(SCB_I2C_INIT_STRUCT *config) lets you to change the mode of operation.  See page 28 of the datasheet of the SCB component.

View solution in original post

5 Replies
OtGo_1311741
Level 3
Level 3
First like received First like given

Hi,

One question, why do you want to change the I2c from master to slave?

Normally, the I2C block inside a microcontroller is configured as a master and any other external device (eeprom, adc, etc.) is treated as slave.  If you want to share communication between two or more microcontrollers having other devices too, you can configure the microcontroller's I2C as multmaster.

0 Likes

Why do you want to change the I2c from master to slave - That is how the application is designed (for reasons I cannot mention)

How is having multi master going to help in this situation? I need to write data to a device (acting as master) and then wait for the other device to send me data(now acting as slave)

0 Likes

Hi, there is no need to post the specific application of your circuit.  But for example, I use a microcontroller as master and a I2C eeprom as slave.  The master sends commands to the eeprom and if it is a command that requires a response, the eeprom will send the response and the master will receive it without changing to slave.

In other words, master starts communication and depending on the command used, it will wait a response from the slave.

I suggest you to check the examples available in Cypress website.

Good luck.

0 Likes

I understand your explanation. But as of now I still want my I2C to switch between master and slave. Is it possible with SCB?

0 Likes

Yes, if you use the unconfigured SCB.  The function SCB_I2CInit(SCB_I2C_INIT_STRUCT *config) lets you to change the mode of operation.  See page 28 of the datasheet of the SCB component.