Change I2C slave address after init, K20

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

Change I2C slave address after init, K20

444 Views
fporter
Contributor I

Hello,

We have several devices using the K20 MCUs running the same software that need to have their I2C slave address assigned on power up based on installed slot programming pin IDs.

Currently the slave address is defined as 7 via the Kinetis Design Studio Component Inspector and have found in the generated code where the slave address is assigned (in IntI2cLdd1_Init() ).  The address specified in component inspector is hardcoded in the line

I2C0_A1 = I2C_A1_AD(0x07); /* Define slave address */

The program pins are read using a BitsIO component but this takes places after the Processor Expert PE_low_level_init() is executed.

In order to redefine the I2C slave address can I

  1. call the <name>_I2C_Disable() function,
  2. set the slave address (repeat the above line of code but with desired address),
  3. call the <name>_I2C_Enable function?

If not, what should be done to reassign the I2C slave address when running?

An aside, in IntI2cLdd1.h I found:

#define IntI2cLdd1_SLAVE_ADDRESS 0x07U /* Slave address value */

using address defined in Component Inspector but it is not used in the generated code. Why?

thanks,

Fred

Labels (1)
Tags (1)
0 Kudos
1 Reply

427 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi fporter,

   If you want to change the slave address, if the slave is not started, you can modify the address directly.

   I also think you can use your flow that:

  1. call the <name>_I2C_Disable() function,
  2. set the slave address (repeat the above line of code but with desired address). You can use the register to modify your slave address directly.
  3. call the <name>_I2C_Enable function

Please try it on your side.

 

Wish it helps you!

If you still have questions about it, please kindly let me know!

Best Regards,

Kerry

-------------------------------------------------------------------------------

Note:

- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored

Please open a new thread and refer to the closed one, if you have a related question at a later point in time.

-----------------------------------------------------------------------------

0 Kudos