Multiple I2C slave configuration in processor expert

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

Multiple I2C slave configuration in processor expert

1,086 Views
pranavshinde
Contributor II

Hi,

I am using S32K144 for my product.

I have different I2C slaves connected to S32K144 which I need to access periodically.

How do I manage them in processor expert?

It looks like I need to call Master_Init function every time while accessing a different I2C slave.

Is there any better way?

0 Kudos
2 Replies

1,036 Views
Jeremy_He
NXP Employee
NXP Employee

Hi Pranav,

Besides calling Master_Init every time you switch to a different slave, you can also change the address or other params in below 2 variables directly.

lpi2c_master_state_t  I2C_StateUser;

/*init i2c master,only need to call for one time*/
LPI2C_DRV_MasterInit(INST_LPI2C1, &lpi2c1_MasterConfig0,&I2C_StateUser);

/*Address which is set in PE will be communicated by default*/

LPI2C_DRV_MasterSendDataBlocking(INST_LPI2C1,dataSend,1,true,1000);

when you want to switch to a different slave ID, just change the value of the below variable.

lpi2c1_MasterConfig0.slaveAddress = I2C_ADDRESS_CS2100;
I2C_StateUser.slaveAddress = I2C_ADDRESS_CS2100;

/*Address of I2C_ADDRESS_CS2100 will be communicated*/

LPI2C_DRV_MasterSendDataBlocking(INST_LPI2C1,dataSend,1,true,1000);

1,036 Views
pranavshinde
Contributor II

Thanks Jeremy,

I found another way to change the slave address using LPI2C_DRV_MasterSetSlaveAddr function.

0 Kudos