Multiple I2C slave configuration in processor expert

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Multiple I2C slave configuration in processor expert

1,404件の閲覧回数
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 件の賞賛
返信
2 返答(返信)

1,354件の閲覧回数
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,354件の閲覧回数
pranavshinde
Contributor II

Thanks Jeremy,

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

0 件の賞賛
返信