Address registers I2C in MK10

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Address registers I2C in MK10

跳至解决方案
1,561 次查看
nikivendola
Contributor III

Hi All,

in the figure below you can see the time diagram of a MAG3110 I2C (slave).

137978_137978.pngImmagin2e.png

The Master is a MK10.
The addresses  of Device and Register must be written first one then after tx, the other in I2Cx_A1 register or there are other registers?

标记 (3)
0 项奖励
回复
1 解答
1,310 次查看
mjbcswitzerland
Specialist V

Hi

I2Cx_A1 is used only when you are acting as a slave and not when acting as bus master. This is clear in the register description:

pastedImage_0.png

Regards

Mark

在原帖中查看解决方案

5 回复数
1,310 次查看
Stano
NXP Employee
NXP Employee

Hi Nikivendola,

The I2C communication is in basic style.

For the "READ" command the first byte you need to write is the Device_ID - it is 0xC4 for MAG3110. Then the slave answers by ACK, next byte you need to write the register address you want to use, the slave answers by ACK, then the master need to generate "repeat_start" and read the byte. The slave in this action sends the data from addressed register and automatically increments the internal registers address pointer. Now it is up to you (master) - is you send the ACK, the slave will send next data from the next register. If you send NACK and then the STOP condition, the communication will be finished.

The important is to use the right addresses in this communication.

For the 'WRITE" command, after first two byte written and answered ACK by slave, you can write such data into addressed register. The slave will answer ACK and then master can finish the write process by STOP condition.

In the normal read mode the slave sends the 16-bit data - two bytes. In the Fast mode the only higher byte is send - 8-bit data.

If you need more help, you are welcome.

Best Regards,

Stano.

1,310 次查看
nikivendola
Contributor III

Thanks for the reply.

So I have to use to identify the slave 0xC4 ...

however, in which the master registry you have to write the device address (which is 0xC4) and to what another register in which the master must write the Register address, which can be, for example 0x10 (CTRL_REG1)?

It is two different addresses where you have to write nell'I2C of MK10?Immagin2e.png

0 项奖励
回复
1,310 次查看
mjbcswitzerland
Specialist V

Hi

All of the addresses and the data are written to the I2C_D register. There are no special registers used for addressing either the slave on the bus or the slave's internal register - it is just a sequence of data byte transmissions befined by you.

To send the slave's address the only special operation is that you set the master's start bit beforehand so that the data on the bus is understood by slaves as an address.

Regards

Mark

I2C: http://www.utasker.com/docs/uTasker/uTaskerIIC.PDF

1,310 次查看
nikivendola
Contributor III

But in the I2C address register _A1 I gotta put 0xC4 to identify the slave?

0 项奖励
回复
1,311 次查看
mjbcswitzerland
Specialist V

Hi

I2Cx_A1 is used only when you are acting as a slave and not when acting as bus master. This is clear in the register description:

pastedImage_0.png

Regards

Mark