MSP430G2231 reading 16-bit i2c response

83 Views Asked by At

I'm writing a program that reads temperatures from a couple TMP117 sensors.

4x Adafruit TMP117 sensor boards to be exact, with each having a different ADDR pin configuration to give them different i2c slave addresses.

For i2c I'm using the MSP430 USI i2c library. I'm having some trouble figuring out if my i2c command sequence respects the "NACK" signal bit response from the master that the TMP117s require (TMP117 datasheet fig.7-10).

My command sequence is declared as such:

uint16_t commands[] = {0x90, 0x00, I2C_RESTART, 0x91, I2C_READ, I2C_READ};

The first command (0x90) is the slave address bit-shifted by 1 from the original address of 0x48, to accomodate for the r/w bit. Same goes for the fourth command (0x91) but with the lsb set. My buffer variable for the response:

uint8_t status[2];

And the i2c reading call as per the example provided in the i2c library readme:

i2c_send_sequence(commands, 6, status, LPM3_bits);

And waiting for response with while(!i2c_done());

This doesn't produce anything in the status variable even after the program breaks from the i2c_done loop. Is there something wrong with my conversion from the i2c_send_sequence's *received_data parameter to uint8_t array, since I'm requesting two bytes with my payload? Or is the second I2C_READ in my payload missing the "NACK" bit? If so, then what would be the correct way of handling the read request and the data?

This is my first time using the TMP117 without any dedicated library, so I'm a bit lost as to what I'm doing wrong here.

Here is my logic trace of the signal: Trace The timebase here is 500us/div.

Any help would be greatly appreciated.

0

There are 0 best solutions below