I2C3 address?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I2C3 address?

2,766 Views
Tsung-FangTu
Contributor I

Hi all!  

We have a board based on i.MX53 SMD design and there is a LCM module which is wired to I2C3 bus. To control the LCM, we are just following the standard /dev/i2c-2 file open (success!) and then ioctl(file, I2C_SLAVE, address). However, we have no clue on the I2C3 address.  Could anyone provide us an advise? Thanks!

T.F.

0 Kudos
9 Replies

1,837 Views
Tsung-FangTu
Contributor I

Well, we finally figure it out, the slave address on the data sheet is wrong.... WT...

Anyway, I appreciate your kind reply and support!

0 Kudos

1,837 Views
xizhouwang
Contributor II

It seams hardware is not working. Using a known good slave device or i2c simulator to check your conncetions and find out which side need to be fixed,  master or slave?

0 Kudos

1,837 Views
Tsung-FangTu
Contributor I

Yes, we did, but both i2cget and i2cset are failed. We also use Logic Analyzer to catch the signal, the slave device address specifying is successful, but failed in read/write processing. Any comment on this situation?

0 Kudos

1,837 Views
xizhouwang
Contributor II

Using i2cget and i2cset to check the hardware connection works before testing your own software.

i2cset will initial the slave device and write the byte to it and you need monitor the device have received the correct byte.

.

0 Kudos

1,837 Views
Tsung-FangTu
Contributor I

Dear Xizhou, thanks for your prompt reply again!

No, as my description, i2cset doesn't work me. I always got write error...

Should I manually initial the i2c device?

0 Kudos

1,837 Views
xizhouwang
Contributor II

This link explain i2c address

http://www.totalphase.com/support/kb/10039/

 

If i2cset works for you, use it as a sample for your application.

Write a block of data to a slave device could use these 3 functions. open_i2c_dev, set_slave_addr, i2c_smbus_write-i2c-block_data from the i2ctools pkgs.

Hope this helps.

0 Kudos

1,837 Views
Tsung-FangTu
Contributor I

Hi! Xizhou Wang, sorry for my late reply, and we did utilize the i2ctools to test the LCM, and we have specified the i2c slave address based on the hardware data sheet, however, the current problem we met is i2c connection or initialization...

Below are my testing code:

------------------------------------------------------------------------
int file;
int adapter_nr = 2; /* i2C3 for iMX53 */
char filename[20];

snprintf(filename, 19, "/dev/i2c-%d", adapter_nr);
file = open(filename, O_RDWR);
if (file < 0) {
printf("Error opening i2c-2 port!, file = %d\n", file);
exit(1);
}
else
printf("Opening i2c-2 successful! \n");

int addr = 0x40; /* The I2C slave address */

if (ioctl(file, I2C_SLAVE, addr) < 0) {
printf("i2c-2 device address specifying failed!, file = %d\n", file);
exit(1);
}
else
printf("i2c-2 device address specifying successful! \n");

__s32 res;
char buf[10];

buf[0] = 0x00;

res = write(file, buf, 1);
if (res != 1) {
printf("i2c-2 write failed!\n");
printf("res = %d\n", res);
exit(1);
}
else
printf("i2c-2 write successful! \n");
------------------------------------------------------------------------

My testing always failed on the "write", res = -1, and I got same result if I use the i2ctools by:$./i2cset 2 64 0

Have tried to re-wire the LCM to i2c-1, but nothing changed.

Does the i2c device need an initialization process? Can anyone kindly provide us an advise, suggestion, or hint?

BTW, we have tried to test the i2c protocal by welding TI BQ32000 which is an clock w. i2c interface, but we always failed on the ioctl command, due to it's i2c slave address is 11010000b which was complaint for too huge. We also got no clue on why i2c slave address can not exceed 0x77... any idea?

Thanks in advance!

0 Kudos

1,837 Views
xizhouwang
Contributor II

On the Linux QSB, Adding i2ctools pkg from the BSP in the build. There will be a few sample apps in the tools folder. i2cget and i2cset could be a good start point as the user space application reference.

0 Kudos

1,837 Views
Tsung-FangTu
Contributor I

Just did some search and realize I should adopt /linux/drivers/i2c/bussed/i2c-imx.c instead of implementing the driver by myself. But I still need the instruction for me to use the linux driver in my application (say, steps of function calls to communicate to the LCM). Any comment/suggestion is more than welcome!

T.F.

0 Kudos