Can I set a buffer more than 256 byte for I2C in Slave Mode?

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

cross mob
LeYu_281131
Level 3
Level 3

Hi,

I am trying to write a simple I2C program as I2C_Slave on a CY8CKIT-050.

I already a success with "Read_Buffer[255]" and "I2C_1_SlaveInitReadBuf((uint8 *) Read_Buffer, 255);"

Nothing is Problem if I use just 256 bytes.

but For My Project, the Read_Buffer should have more than 256 bytes almost 1000 bytes.

If the PSoC is the Master Mode,

I can send and receive more than 256 bytes with "I2C_1_MasterReadByte" and "I2C_1_MasterWriteByte".

but as the slave, I can not find any API to solve this problem.

there is only command to set a buffer as "I2C_1_SlaveInitWriteBuf" and "I2C_1_SlaveInitReadBuf".

and the two commands support only 256 bytes.

In my project,

Host(Android) send a command to give time for prepared data.

and, Host(Android) read 1000 bytes data in a time.

If you have any advise, please let me know.

Thank you

0 Likes
1 Solution

Hi user_45452503​,

If that's the case, you need to modify the global variables, I2CS_slRdBufSize and I2CS_slRdBufIndex to uint16 from uint8. It is just a software buffer that I2C uses and hence this is possible. It is just a firmware limitation. But these are generated sources files and you will not be able to modify them. For this you can do two things.

1. Create a  new .h file for your I2C component modifying all the firmware (replacing the current variables by your own variable). You may also have to modify all the APIs firmware according to your new defined variable.

2. Create a custom component and modify it according to your requirements.

Regards,

Bragadeesh

Regards,
Bragadeesh

View solution in original post

0 Likes
7 Replies
BragadeeshV
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi user_45452503​,

Can you try using EZI2C slave? It can have buffer size up to 65536 bytes.

Regards,

Bragadeesh

Regards,
Bragadeesh
0 Likes

Hi Bragadeesh

If I have normal situation, I could use EzI2C, but not now.

The Android System already fixed as normal I2C protocol, "Slave Address" + "Data"

but, As I know, EzI2C has special structure for SDA, "Slave Address" + "8/16 bit Sub-Address" + "Data"

Can I use EzI2C without Sub-Address?

Regards,

YuSang

0 Likes

Hi user_45452503​,

If that's the case, you need to modify the global variables, I2CS_slRdBufSize and I2CS_slRdBufIndex to uint16 from uint8. It is just a software buffer that I2C uses and hence this is possible. It is just a firmware limitation. But these are generated sources files and you will not be able to modify them. For this you can do two things.

1. Create a  new .h file for your I2C component modifying all the firmware (replacing the current variables by your own variable). You may also have to modify all the APIs firmware according to your new defined variable.

2. Create a custom component and modify it according to your requirements.

Regards,

Bragadeesh

Regards,
Bragadeesh
0 Likes

Hi Bragadeesh

Thank you for your advise.

I think both way is good to me.

but I do not know, How to do that.

If you have any resource for reference, Please let me know.

Regards,

YuSang

0 Likes

Hi user_45452503,

You can refer to the component author guide to create your own custom component.

https://www.cypress.com/file/137436/download

Regards,

Bragadeesh

Regards,
Bragadeesh
0 Likes

Hi Bragadeesh

Thank you for the reference for the second solution, Create Custom Component.

Do you have any reference for the first solution?

I mean change "I2C.h" and "I2C_SLAVE.c".

As you mentioned "Clean and Build" will generate new header and c files for I2C component.

so, Just change uint16 from uint8 is not enough for the solution.

therefore, I want to know how to replace header and c without side effect.

if you have any solution, please let me know.

Regards,

YuSang

0 Likes

Hi user_45452503​,

You will have to create your own .c and .h files and add them along with your source files. We don't have any reference as such for this method.

Regards,

Bragadeesh

Regards,
Bragadeesh
0 Likes