I want to talk and exchange data via I2C to another frdmkl25Z. How do I set up the addresses, please?

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

I want to talk and exchange data via I2C to another frdmkl25Z. How do I set up the addresses, please?

605 Views
andychernock
Contributor III

I do I set up the I2C addressing when exchanging data between two FRDM boards?

Tags (2)
0 Kudos
1 Reply

452 Views
quevedo
Contributor V

Hello,

First of all, it is important to know if one of the boards will work as master and the other as slave, or if master and slave roles will be switched during communication. If you can choose the way they work, I would suggest the first option, since it is simpler to control communication (no data collision detect needed).

Considering that one of the boards is master and the other is slave, master will always start communication requests, regardless of data direction (M -> S or S -> M). While in master mode, an I2C device has no address. Adresses are for slaves. When configuring I2C on slave board, you must choose any 7-bit address (0x01 - 0x7F) that is not being used by any othed I2C device on the same bus. The chosen address must be loaded on I2Cx_A1 register in the slave MCU. Note that "x" can be either 0 or 1, depending on which I2C module you are configuring. Also note that this 7-bit address must be written into bits 1-7 of I2Cx_A1, meaning that you have to shift the address left by 1 bit before writing it to the register. After that, you may use I2C PE component or an I2C library for master MCU, configuring slave address to the chosen address.

Feel free to contact me. If you wish, tell me exactly what you want to do with the 2 boards, and I may help with some code.

Cheers,

Antonio

0 Kudos