PSoC 5 I2C Read

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

cross mob
MiMo_4142486
Level 1
Level 1
First question asked Welcome!

Hi, 

The datasheet for the I2C block shows the following code for manual read. However, how can I read from a specific register?

The I2C_MasterSendStart includes the slave address, but I don't see the register address being called out. 

Example Code:

status = I2C_MasterSendStart(0x08, I2C_READ_XFER_MODE);
if(I2C_MSTR_NO_ERROR == status) /* Check if transfer completed without errors */
{
/* Read array of 5 bytes */
for(i=0; i<5; i++)
{
if(i < 4)

{
userArray[i] = I2C_MasterReadByte(I2C_ACK_DATA);
}
else
{
userArray[i] = I2C_MasterReadByte(I2C_NAK_DATA);
}
}
}
I2C_MasterSendStop(); /* Send Stop */

0 Likes
1 Solution
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

I have posted the following code sample.

https://community.infineon.com/t5/Code-Examples/MCU-Tester-a-Swiss-Army-Knife-for-PSoC-CY8CKIT-059-v...

I hope that you can refer to i2c_utils.[ch]  in that project.

moto

View solution in original post

0 Likes
2 Replies
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

I have posted the following code sample.

https://community.infineon.com/t5/Code-Examples/MCU-Tester-a-Swiss-Army-Knife-for-PSoC-CY8CKIT-059-v...

I hope that you can refer to i2c_utils.[ch]  in that project.

moto

0 Likes
WaMa_286156
Level 5
Level 5
First comment on blog 100 replies posted 50 replies posted

Also, some people have had to use the mpu6050, and it has similar setup:

https://github.com/cychu18/PSoC_MPU6050

 

0 Likes