FTDI Community

Please login or register.

Login with username, password and session length.
Advanced Search  

News:

Welcome to the FTDI Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ FTDI Support


New Bridgetek Community is now open

Please note that we have created the Bridgetek Community to discuss all Bridgetek products e.g. EVE, MCU.

Please follow this link and create a new user account to get started.

Bridgetek Community

Author Topic: FT2232H and Digital Temperature Sensors TMP112  (Read 185 times)

nevs

  • Newbie
  • *
  • Posts: 2
    • View Profile
FT2232H and Digital Temperature Sensors TMP112
« on: November 13, 2019, 07:20:07 AM »

Hi,

I use TMP112A Digital Temperature Sensors from Texas Instrument (http://www.ti.com/product/TMP112) and I want read value of Temperature Register, but I have problem. The read value should have 16 bits, so I have to read two bytes. The first byte is read correctly, the second byte returns value 0xFF.

Read Word Format:
1] Starty by Master | Device address | Ack By TMP112 | Register address | Ack By TMP112 | Stop By Master
2] Starty by Master | Device address | Ack By TMP112 | 1 Data Byte | Ack By Master | 2 Data Byte | Ack By Master | Stop By Master

I think the problem is in Ack By Master when is reading the first and second byte. I don't know how make "Ack By Master" in the middle of reading.

My code:

int i2c_tmp_read(uint8_t addr, uint8_t reg, uint16_t * val)
{
    FT_STATUS status;
    long unsigned int num_to_send, num;
    uint8_t buf[2] = {0, 0};
   
    // prepare data
    num_to_send = 1;
    num = 0;
    // write data
    status = I2C_DeviceWrite(ftHandle, addr, num_to_send, &reg, &num,
                I2C_TRANSFER_OPTIONS_START_BIT
                | I2C_TRANSFER_OPTIONS_STOP_BIT);
    if (status != FT_OK)
    {
        return (-1);
    }
    // prepare data
    num_to_send = 2; 
    num = 0;
    // read data
    status |= I2C_DeviceRead(ftHandle, addr, num_to_send, buf, &num,
                I2C_TRANSFER_OPTIONS_START_BIT
                | I2C_TRANSFER_OPTIONS_NACK_LAST_BYTE
                | I2C_TRANSFER_OPTIONS_STOP_BIT);               
    if ((status != FT_OK) || (num != num_to_send))
    {
        return (-1);
    }
       
    *val = (buf[1] << 8) | buf[0];

    return (0);
}

Existing options:
#define   I2C_TRANSFER_OPTIONS_START_BIT      0x00000001
#define I2C_TRANSFER_OPTIONS_STOP_BIT      0x00000002
#define I2C_TRANSFER_OPTIONS_BREAK_ON_NACK   0x00000004
#define I2C_TRANSFER_OPTIONS_NACK_LAST_BYTE   0x00000008
#define I2C_TRANSFER_OPTIONS_FAST_TRANSFER_BYTES   0x00000010
#define I2C_TRANSFER_OPTIONS_FAST_TRANSFER_BITS   0x00000020
#define I2C_TRANSFER_OPTIONS_FAST_TRANSFER      0x00000030
#define I2C_TRANSFER_OPTIONS_NO_ADDRESS      0x00000040

My question is: Is there an option that made Ack By Master? How to solve this problem?

I thank you in advance for your help  :).

Marketa


Logged

nevs

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: FT2232H and Digital Temperature Sensors TMP112
« Reply #1 on: November 18, 2019, 09:58:28 AM »

OK, when I use libMPSSE__0_6_Beta.zip everything works... ;D
Logged