Hi,
I have a custom board using the CC2541 chip, with two sensors attached to the I2C bus.
When reading data from sensor, I can see long gaps in communication, which I'm not used to working with different MCUs (TIVA, etc.).
It might be related to delays in I2CSTAT register update, since the I2C library is waiting between states (according to "Table 20-4. Master Receiver Mode" in user guide).
I need it in order to read data at high rate without affecting BLE connectivity.
//Read I2C registers void i2c_read_registers(uint8 dev_addr,uint8 reg_addr,uint8 numBytes, uint8* spaceToWrite) { //Find device addresses dev_addr_write = (dev_addr*2)|0x00; dev_addr_read = (dev_addr*2)|0x01; // Sent start condition and wait for it to be received I2CCFG = I2C_SR; waitI2CStat(SR_SENT); // Send Device Address I2CDATA = dev_addr_write; I2CCFG = I2C_DO; waitI2CStat(SLAW_ACK_SENT); // Send Register address I2CDATA = reg_addr; I2CCFG = I2C_DO; waitI2CStat(DATA_ACK_SENT); // Send Restart condition I2CCFG = I2C_SR; waitI2CStat(RS_SENT); // Send Device Address Read I2CDATA = dev_addr_read; I2CCFG = I2C_DO; waitI2CStat(SLAR_ACK_SENT); while(numBytes>1) { // Do Continued Transfer I2CCFG=I2C_CO; waitI2CStat(DATA_ACK_RECV); *spaceToWrite = I2CDATA; spaceToWrite++; numBytes--; } //Do Final Transfer I2CCFG=I2C_DO; waitI2CStat(DATA_NACK_RECV); *spaceToWrite = I2CDATA; // Send Stop Condition I2CCFG=I2C_SP; }
Thanks,
Ofir