Part Number: MSP430FR2433
Is there example code using DriverLib for the common case where the slave has an address space of registers and the master first transmits a register address and then receives one or more bytes from the slave? This common case is discussed in TI’s App Report “Understanding the I2C Bus” SLVA704. The case is also called a “combined transaction” where the master sends a restart bit to turn the link around.
IMO this is so common that TI should provide an example, even a new API in DriverLib.
I have struggled to find the right combination of DriverLib calls. For example, this doesn’t work (It hangs waiting for RXIFG):
... disable, configure, set slave address, and enable....
// start then send register address (whose MSB==0 tells slave this is a read)
EUSCI_B_I2C_masterSendMultiByteStart(I2CInstanceAddress, registerAddress);
// restart and receive data and stop
result = EUSCI_B_I2C_masterReceiveSingleByte(I2CInstanceAddress);
I have tried other combinations. I wish the documentation described the legal sequences of calls to driver lib.
My context is: CCSv8, MSP430FR2433 Launchpad, STMicro LIS3MDL compass chip. I don’t have a logic analyzer.
I wish there were an API:
readSingle(eUSCIInstance, slaveAddress, registerAddress)
readMultiple(eUSCIInstance, slaveAddress, registerAddress, buffer, length)
writeSingle(eUSCIInstance, slaveAddress, registerAddress)
writeMultiple(eUSCIInstance, slaveAddress, registerAddress, buffer, length)
I think there is another thread suggesting it can be done. There is also another thread suggesting multiple bytes cannot be received without using an ISR that calls EUSCI_B_I2C_masterReceiveNext(). (“I2C Driver Lib Timeout Value”)