PSoC4: EzI2C Slave with master Raspberry Pi

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

cross mob
ShVy_264716
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted

I am working on I2C communication between Raspberry Pi as master and PSoC4 as slave. To set PSoC4 as I2C slave, I am programming it with EZI2C Slave (SCB v3.0) component using Creator 3.2. I went through the following piece of while studying the datasheet of the component:

   

#define BUFFER_SIZE (0x0Au)
#define BUFFER_RW_BOUNDARY (0x04u)
uint8 ezi2cBuffer[BUFFER_SIZE];
SCB_EzI2CSetBuffer1(BUFFER_SIZE, BUFFER_RW_BOUNDARY, ezi2cBuffer);

   

 

   

What I could understand from the datasheet and this piece of code is that this SCB_ExI2CSetBuffer1() API sets the "ezi2cBuffer" as the buffer to which Master I2C device writes data and from which Master I2C device reads data. If I understood in this way, then I am afraid that I will get so much confused about how to set the same buffer for simultaneous read and write operations from master.

   

For example, I write a value "0x0000" from master Pi to slave PSoC. The slave PSoC gets this value as a command to send a string "OK" back to the master. On the reading from slave, the master gets the string "OK".  If I want to execute this, I have to define separately a read buffer and a write buffer, but it is not possible as this SCB_ExI2CSetBuffer1() API only declares a single buffer for both.

   

Any help in understanding this and developing the comminucation would be highly appreciated.

   

 

   

Regards

   

Shaunak

0 Likes
3 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

So do not use EzI2C component, but the I2C component in slave mode. There you get two separate buffers for read and write access from master.

   

 

   

Bob

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

Thank you, Bob. I did it using normal I2C component in slave mode. Here is the project attached.

   

 

   

Regards

   

Shaunak

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Did not check, but that seems to be what I suggested. Remove the copyright from your main.c and replace it with your own! It is your work, not Cypress's.

   

 

   

Bob

0 Likes