I2C Memory Address suggestion

All about Sub-20 Multi Interface USB Adapter USB to I2C, SPI, GPIO, RS232, RS485, Ir, LCD

Moderator: serg

Post Reply
Kazurthas
Posts: 2
Joined: Mon Mar 21, 2011 1:14 pm

I2C Memory Address suggestion

Post by Kazurthas »

Hi,
I'm currently using SUB-20 as my USB to I2C interface.
There's 1 point I've found out when using SUB-20 DLL:
In sub_i2c_read and sub_i2c_write functions, the memory address variable is an integer (int ma). I find this quite strange, as in the implementation of the function, you would have to do bit shifting to get the actual memory address bytes. Additionally, with an integer, you can enter maximum of 4 bytes memory address with 32-bit system (this normally is not a problem, but probably there are users who want more address bytes). The same applies for bit bang I2C read and write.
Thus I think it would be better to change the memory address variable as an array of bytes just like the buffer to store I2C read and write data (char* ma). Then it would also be more clear for the user to know how to address the memory byte by byte.
Just a suggestion, please give me your opinion about it.

Kaz

xol
Site Admin
Posts: 241
Joined: Sat Aug 29, 2009 8:04 am

Re: I2C Memory Address suggestion

Post by xol »

Hi,
int ma is treated by i2c functions as 4 bytes array. We ignore sign. I agree it could be unsigned int but it is not critical.
As for address size, I have not seen in my 20 year practice any I2C device with long memory address. 32-bit address allows access up to 4GByte of memory.

Having a memory address an integer variable and not byte array makes it simple to perform address operations. For instance increment and decrement.

Kazurthas
Posts: 2
Joined: Mon Mar 21, 2011 1:14 pm

Re: I2C Memory Address suggestion

Post by Kazurthas »

Ah ok, I got it now.
Thanks for enlighten me :)

Post Reply