CYUSB236, I2CMaster sample code inquiry

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

cross mob
Minsu
Level 1
Level 1
First reply posted First question asked Welcome!

Minsu_0-1638947512291.png

 

I am developing with your CYUSBS236 SDK.

I'm testing it with the example code you provided.

Minsu_2-1638947697982.png

 

Minsu_1-1638947625442.png

there are so many problems
First of all, let me ask about CyGetI2cConfig.

Minsu_3-1638947845932.png

I set "isMaster" to 1
Then I checked with CyGetI2cConfig
However. I can't get the value of "isMaster"

Minsu_5-1638948178151.png

In the CyGetI2cConfig function, instead of cyI2CConfig, I made a new test_cyI2CConfig and tested it, but it contains a strange value.

Your code seems to show the value of cyI2CConfig as it is above.

 

It seems to me that "slaveAddress" also doesn't change like "isMaster" does.

Is that right?

 

It seems to me that "slaveAddress" also doesn't change like "isMaster" does.

So I mean.
I wonder why "slaveAddress" and "isMaster" that do not change are set to "CySetI2cConfig"?

 

Detailed answer please.

 

0 Likes
1 Solution
Meghavi
Moderator
Moderator
Moderator
250 replies posted 100 solutions authored 10 likes received

Hi,

Can you please let me know which error are you getting? 

Also please try the below snippet:

printf("Setting new I2C configuration...\n");
cyI2CConfig.frequency = 1000;
cyI2CConfig.slaveAddress = 0x60;
cyI2CConfig.isMaster = 1;
printf ("New Configuration - I2C Frequency : %d , Slave address : %d, isMaster : %d\n",
cyI2CConfig.frequency,
cyI2CConfig.slaveAddress,
cyI2CConfig.isMaster);

rStatus = CySetI2cConfig (cyHandle, &cyI2CConfig);
if (rStatus != CY_SUCCESS){
printf ("CySetI2cConfig returned failure code.\n");
return rStatus;
}
printf("Setting new I2C configuration successful.\n");


// Check to see if the new configuration is applied on I2C
printf("Checking the new I2C configuration ...\n");
rStatus = CyGetI2cConfig (cyHandle, &cyI2CConfig);
if (rStatus != CY_SUCCESS){
printf ("CyGetI2cConfig returned failure code.\n");
return rStatus;
}
printf ("I2C Configuration retrieved - I2C Frequency : %d , Slave address : %d, isMaster : %d\n",
cyI2CConfig.frequency,
cyI2CConfig.slaveAddress,
cyI2CConfig.isMaster);

 

And kindly share the screenshot of whether you are getting error in CySetI2cConfig or CyGetI2cConfig.

 

Regards

View solution in original post

0 Likes
1 Reply
Meghavi
Moderator
Moderator
Moderator
250 replies posted 100 solutions authored 10 likes received

Hi,

Can you please let me know which error are you getting? 

Also please try the below snippet:

printf("Setting new I2C configuration...\n");
cyI2CConfig.frequency = 1000;
cyI2CConfig.slaveAddress = 0x60;
cyI2CConfig.isMaster = 1;
printf ("New Configuration - I2C Frequency : %d , Slave address : %d, isMaster : %d\n",
cyI2CConfig.frequency,
cyI2CConfig.slaveAddress,
cyI2CConfig.isMaster);

rStatus = CySetI2cConfig (cyHandle, &cyI2CConfig);
if (rStatus != CY_SUCCESS){
printf ("CySetI2cConfig returned failure code.\n");
return rStatus;
}
printf("Setting new I2C configuration successful.\n");


// Check to see if the new configuration is applied on I2C
printf("Checking the new I2C configuration ...\n");
rStatus = CyGetI2cConfig (cyHandle, &cyI2CConfig);
if (rStatus != CY_SUCCESS){
printf ("CyGetI2cConfig returned failure code.\n");
return rStatus;
}
printf ("I2C Configuration retrieved - I2C Frequency : %d , Slave address : %d, isMaster : %d\n",
cyI2CConfig.frequency,
cyI2CConfig.slaveAddress,
cyI2CConfig.isMaster);

 

And kindly share the screenshot of whether you are getting error in CySetI2cConfig or CyGetI2cConfig.

 

Regards

0 Likes