USB serial I2C example variable

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

cross mob
shower
Level 1
Level 1
5 sign-ins First reply posted First question asked

Hi, there

   I'm working on USB serial i2c example based on cy7c65215  USB to serial bridge. 

   I find that if change the variable CY_I2C_CONFIG and CY_I2C_DATA_CONFIG to a static variable, the waveform output from cy7c65215 goes to an unexpected waveform, quite different from what I set 

shower_0-1661489667062.png

shower_0-1661504166527.png

 

the picture up there is the right waveform that I expect the slave address is 0x69 when I did not add the 'static' before the variable definition.

but if I add the 'static '  keyword before the variable definition, the waveform goes bad, like the picture below 

shower_2-1661490071442.png

 

Does anyone know what goes on after I add the static keyword? 

 

 

0 Likes
3 Replies
Meghavi
Moderator
Moderator
Moderator
250 replies posted 100 solutions authored 10 likes received

Hi,

Can you please let me know the reason for declaring this as static? Static variables are mostly used for preserving their value even out of their scope.

Also, please share the second waveform. I see that both waveforms are the same.

Regards,

Meghavi

 

0 Likes
shower
Level 1
Level 1
5 sign-ins First reply posted First question asked

hi, 

   I've changed the message to a right waveform in the 2nd picture.

   the reason for the static is for a test . 

   At first, I changed these 2 variables to global variables, because I want to cut the huge I2CMaster  to some small parts, like I2C_Init and I2C_readreg ..... 

   because these configure do not need to be changed during these functions, I changed them to global variables for convenience, but after that, the waveform becomes abnormal in the third picture. 

   In that picture, the address is not the 0x69 that I set in my code. the address shown on that is  0x6D.

for global variable  are stored in static memory area  after compile. I guess the cause phenominon is because of the variable area in memory , So , I did a test , to  add  static keyword to variables. 

 then  the static variable works bad , like global variable did.

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

Hi,

Can you kindly set the slave address as 0x45 and let us know the result? 

Regards,

Meghavi

0 Likes