EZI2Cs : Is it possible to store more than 1 byte in 1 I2C RAM Adress?

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

cross mob
Anonymous
Not applicable

Hi!

   

 

   

I managed to get the EZI2Cs(lave) to work. However I need it to be configured in a way which allows me to store more than 1 byte in a I2C Ram Adress.

   

 

   

For example something like this would be neat (modified from the EZI2Cs data sheet):

   

 

   

 <p>struct I2C_Regs {   // Example I2C interface structure

   
    int status1;      
   
    int status2;     
   
} MyI2C_Regs;</p>
   

with status1 fitting entirely into adress 0x00 and status2 entirely fitting into 0x01.

   

But instead it will be status1.MSB in 0x00, status1.LSB in 0x01, status2.MSB in 0x02 and status2.LSB in 0x03...

   

Is there any way to change it and make a multibyte Variable fit into 1 I2C Ram Adress?

   

 

   

Thanks in advance  and best regards

0 Likes
6 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You cannot squeeze a 2-byte int into a char without losses. When you are quite sure that your int is >= 0 and <= 255 you may truncate it by casting into an unsigned char.

   

 

   

Bob

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Oh, I just see: Your first post. Welcome in the fascinating world of PSoCs!

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 Thank you for the welcome 🙂

   

PSoCs are quite fascinating indeed. I'm just starting to get them to know.

   

 

   

So the only way to get multibyte variables into 1 I2C Ram Adress would be to write my own I2C Module I guess.
 

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Negative.

   

You do not need to write any new code, but you need to understand how I2C works. The master may transmit any number of bytes to the slave. As long as the slave's buffer is large enough, it will accept and store the data, when not, then the bytes will be discarted an NAKed. Similar actions are taken when Master reads from slave.

   

When you get in troubles, it is always advisable to post your complete project, so that we all can have a look at all of your settings. To do so, use
Designer->File->Archive Project
and attach the resulting file (do NOT use chrome, that still may not work).

   

 

   

Bob
 

0 Likes
azcypro1
Level 3
Level 3
10 replies posted 5 replies posted Welcome!

Which i2C RAM Mfg,/Partnum are you using?  I want to see the datasheet before I tell you how I think it's possible.

   

 

   

Bill

0 Likes
azcypro1
Level 3
Level 3
10 replies posted 5 replies posted Welcome!

Sorry, should've looked at the subject better (and earlier).  Not as-is.  You're right- to store/retrieve a word per-address would require either your own component, or just some code using the FLASH library.  Since the PSoC is oragnized by bytes, not words, there's only one byte of data per-address.  However, you can throw out the LSbit and use only the upper 7 bits to send an address, then your code on the PSoC can do the translation to put the second byte at the <byte addr>+1.  So the actual LSbit of the address is available only to your PSoC code, the device sending the data to the PSoC would only see7 address bits per-word.  However from that master device's POV, it could just ignore the MSbit (set it to zero), and the PSoC could translate.

   

 

   

Is that making sense?

0 Likes