LPC4337 I2C - Write to Slave Register?

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

LPC4337 I2C - Write to Slave Register?

685 Views
andrew_murfin
Contributor II

Hello

I am using the LPC4337 to manipulate the LSM9DS1 IMU.  I have found success using the "Chip_I2C_MasterCmdRead" function to read data from the sensor's registers, however I can't figure out how to write data to those subaddress' registers.  

For example, if I want to read data from the accelerometer's control register 8, I do this:

uint8_t buffer;

Chip_I2C_MasterCmdRead(i2cDev, 0x6B/*address of slave*/, 0x22/*subaddress of ctrl_reg8*/, &buffer, 1);

That will put the data onto "buffer" for me to view.  However, if I want to WRITE onto this register (in order to change settings), I can't find any functions which will allow me to do this.  The "Chip_I2C_MasterSend" function only has an option for the slave's main address, without any option to send to a specific subaddress.  I guess what I'm looking for might look like this:

Chip_I2C_MasterCmdWrite(I2CModule, slave_address, subaddress, cmd, *buffer, length);

Is there a provided function which I have looked over, and if not can you help me create a function which will work for my needs?

Thanks!

-Andy 

Labels (3)
0 Kudos
1 Reply

464 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Andrew,

   Actually LSM9DS1  is not NXP's product, so we don't have the according LPC4337 code for it directly.

  But, it is not the problem, actually, you just need to read the LSM9DS1 DATASHEET, then know the I2C command, just use the LPC4337 i2c driver send the according I2C data is OK.

 We don't have the direct API for your LSM9DS1, it seem your LSM9DS1 still have the subaddress, I think you need to know the LSM9DS1 write I2C sequence at first, if the sbuaddress is following the address, I think you can put the subaddress in the Chip_I2C_MasterCmdRead data area. or you can write the API code which add the subaddress, it's not difficult, you need to know the LSM9DS1 write sequence at first, then modify the API, then send it to your LSM9DS1, check the I2C bus, whether the modified write code meet your LSM9DS1 or not.

Please check LSM9DS1 datasheet, then modify the Chip_I2C_MasterCmdRead by yourself.

If you still have problem, just let me know.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos