AnsweredAssumed Answered

Question about i2cio module

Question asked by Arna Lee on Mar 19, 2018
Latest reply on Mar 26, 2018 by Kan_Li

Hello Sirs,

 

I am studying NHS3100 board kit.

I want to add my motion sensor with I2C interface.

 

I read some document and it is said that "The user of the I2CIO module only needs to use the API functions below to have full I2C communication. "

 

I tried my test and the code snippet based on "app_demo_dp_tlogger" is below but it does NOT work.

And I have already linked the mods "i2cio" into my project.

 

---

    RegData = 0x57;
//    Sensor_WriteReg(LIS3DH_I2C_DEVICE2_WRITE_ADDR, LIS3DH_CTRL_REG1, &RegData);
{
 uint8_t sendBuf[2] = {0x00};
    I2CIO_Init();
 sendBuf[0] = LIS3DH_CTRL_REG1;
 sendBuf[1] = 0x57;
    I2CIO_Tx(sendBuf,2);
}
 printf("Write slaveAddr 0x%02X, reg_addr 0x%02X, Write Data 0x%02X\r\n", LIS3DH_I2C_DEVICE2_WRITE_ADDR, LIS3DH_CTRL_REG1, RegData);
---
The running/testing log is below:
---
Sensor_Init for I2C...
Chip_I2C_MasterSend slaveAddr 0x32, txBuff: 20 57
Chip_I2C_MasterTransfer
Chip_I2C_EventHandler: I2C event 3
Chip_I2C_EventHandler: I2C event 1
Chip_I2C_EventHandler: I2C transfer status 4
---
From my observation, the routine stuck in the while statement in the funciton "Chip_I2C_EventHandler":
---
/* Wait for the status to change */
while (*stat == I2C_STATUS_BUSY) {
}
---
I didn't see I2C_STATUS_DONE which will be set in the function "I2C0_IRQHandler" => "Chip_I2C_MasterStateHandler" as my own understand.
Anyone could help me to review if anthing wrong?
Thanks,
Arna

Outcomes