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

PSoC™ 5, 3 & 1 Forum Discussions

MiMo_4142486
Level 1
First question asked Welcome!
Level 1

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
First comment on KBA 1000 replies posted 750 replies posted
Level 9

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
First comment on KBA 1000 replies posted 750 replies posted
Level 9

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
First comment on blog 100 replies posted 50 replies posted
Level 5

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

https://github.com/cychu18/PSoC_MPU6050

 

0 Likes