I2C MPC5478G

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

I2C MPC5478G

跳至解决方案
358 次查看
ALTUN
Contributor I

Hi, I want to communicate with an amplifier using the MPC5748G. I'm using the i2c_transfer_mpc5748g sample code from the Power Architecture. The amplifier's address is 0x70. What modifications do I need to make to achieve this? also i2c driver sends
adress->data  but i want to make it adress of amplifier(adress) ->amplifier register(subadress)-> data.

0 项奖励
回复
1 解答
318 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

the Slave device address is set within Component inspector and it is automatically sent as first byte after START is issued.
The Slave’s register/memory address, must be stored into first byte(s) of the “txBuffer” depending on address size.
 
So assuming 16bit address is used and you want to write 8 bytes (1,2,3,..,8) to Slave address 0x000C, then prepare txBuffer as
 
txBuffer = {0x00, 0x0C, 1, 2, 3, 4, 5, 6, 7, 8};
 
and use I2C_DRV_MasterSendDataBlocking(instance, txBuffer, 10, true, timeout);
 
If you want to read 8 bytes from the same memory address then use this
 
I2C_DRV_MasterSendDataBlocking(instance, txBuffer, 2, false, timeout); // just memory/register address will be sent after Slave address so total 3 bytes, STOP is not generated
I2C_DRV_MasterReceiveDataBlocking(instance, rxBuffer, 8, true, timeout); // Repeat Start is issued following Slave address and waiting reading for 8 bytes

Hope it helps.

BR, Petr

在原帖中查看解决方案

1 回复
319 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

the Slave device address is set within Component inspector and it is automatically sent as first byte after START is issued.
The Slave’s register/memory address, must be stored into first byte(s) of the “txBuffer” depending on address size.
 
So assuming 16bit address is used and you want to write 8 bytes (1,2,3,..,8) to Slave address 0x000C, then prepare txBuffer as
 
txBuffer = {0x00, 0x0C, 1, 2, 3, 4, 5, 6, 7, 8};
 
and use I2C_DRV_MasterSendDataBlocking(instance, txBuffer, 10, true, timeout);
 
If you want to read 8 bytes from the same memory address then use this
 
I2C_DRV_MasterSendDataBlocking(instance, txBuffer, 2, false, timeout); // just memory/register address will be sent after Slave address so total 3 bytes, STOP is not generated
I2C_DRV_MasterReceiveDataBlocking(instance, rxBuffer, 8, true, timeout); // Repeat Start is issued following Slave address and waiting reading for 8 bytes

Hope it helps.

BR, Petr