Part Number: MSP430FR2355
Other Parts Discussed in Thread: TMP102
Hi,
I'm using the MSP430 to communicate with some temperature devices through I2C. I'm using the driverlib library and I experienced an odd behavior of the I2C channel when using this library.
When trying to repeatedly send multiple byte message, the first byte of the message is not sent.. here is a code example:
void I2C_EUSCI_B1_Config()
{
Param.selectClockSource = EUSCI_I2C_CLOCKSOURCE_SMCLK;
Param.i2cClk = CS_getSMCLK();
Param.dataRate = EUSCI_B_I2C_SET_DATA_RATE_100KBPS;
Param.autoSTOPGeneration = EUSCI_B_I2C_NO_AUTO_STOP;
EUSCI_B_I2C_initMaster(EUSCI_B1_BASE,¶m);
EUSCI_B_I2C_enable(EUSCI_B1_BASE);
}
Void main()
{
While(1)
{
// I2C Tx message – 0x01, 0xAA
EUSCI_B_I2C_setSlaveAddress(EUSCI_B1_BASE, TMP102_ADDRESS);
EUSCI_B_I2C_masterSendMultiByteStart(EUSCI_B1_BASE, 0x01);
EUSCI_B_I2C_masterSendMultiByteNext(EUSCI_B1_BASE, 0xAA);
EUSCI_B_I2C_masterSendMultiByteStop(EUSCI_B1_BASE);
// I2C Tx message – 0x01, 0xBA
EUSCI_B_I2C_masterSendMultiByteStart(EUSCI_B1_BASE, 0x01);
EUSCI_B_I2C_masterSendMultiByteNext(EUSCI_B1_BASE, 0xBA);
EUSCI_B_I2C_masterSendMultiByteStop(EUSCI_B1_BASE);
}
}
The first time it enters the while loop, the first message is sent correctly - 0x01 and then 0xAA. But in the next messages the 0x01 is not sent again.
In all messages only the 0xAA and 0xBA are sent.
I saw another strange behavior, after sending the first message (0x01, 0xAA) and then trying to send single byte message, no data byte is sent... only the address.
Seems like, for some reason, it discards the first byte of the transmission.
Would appreciate you help,
Thank you!