Hello,
I have built two i2c_write and i2c_read polling function on top of the driverlib.
I need to do a I2C read that contains a repeated start condition.
Since my device responded wrongly, I plugged a logical analyzer on my I2C bus and I noticed that a stop occurs before the repeated start while the driverlib functions I use should'nt trigger stop condition.
My target device works well when it comes to do a stop between two commands, as well as others devices connected on the bus, but I can't manage to handle Repeated start gracefully.
The logical analyzer output:
bool i2c_read(uint8_t device_address, uint8_t register_address, uint8_t *data, uint8_t len) { bool result = false; USCI_B_I2C_initMaster(USCI_B2_BASE, device_addressS); USCI_B_I2C_setMode(USCI_B2_BASE, USCI_B_I2C_TRANSMIT_MODE); USCI_B_I2C_enable(USCI_B2_BASE); _disable_interrupts(); /* Sending the register address */ if (!USCI_B_I2C_masterSendMultiByteStartWithTimeout(USCI_B2_BASE, register_address, 400)) goto end; /* Reading the result */ USCI_B_I2C_setMode(USCI_B2_BASE, USCI_B_I2C_RECEIVE_MODE); USCI_B_I2C_enable(USCI_B2_BASE); if (len == 1) { if (!USCI_B_I2C_masterReceiveSingleStartWithTimeout(USCI_B2_BASE, TIMEOUT)) goto end; *data = USCI_B_I2C_masterReceiveSingle(USCI_B2_BASE); } else { USCI_B_I2C_masterReceiveMultiByteStart(I2C_BASE); while (len--) { if (len == 1) { if (!USCI_B_I2C_masterReceiveMultiByteFinishWithTimeout(I2C_BASE, data++, 400)) goto end; } else { msleep(1); *data++ = USCI_B_I2C_masterReceiveMultiByteNext(I2C_BASE); } } } result = true; end: _enable_interrupts(); USCI_B_I2C_disable(I2C_BASE); return result; }
Why do I observe this stop condition ?
What am I doing wrong ?