This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C123GH6PM: I2C1 issue with TM4C123GH6PM

Part Number: TM4C123GH6PM
Other Parts Discussed in Thread: EK-TM4C123GXL, , TMP102, TMP006

Hi,

I have TI launchpad EK-TM4C123GXL. I have connected one TI temperature sensor(tmp102) to I2C1 of TM4C123GH6PM MCU. I want to read the temperature data using i2c1 bus. Please find the attached code. 

While executing this code using XDS200 connected to TM4C123GH6PM. It was observed that no I2C clock and SDA transactions.

Thanks & Regards,

NarpatDevkit_Sensor_Interface.zip

  • Before I did into the code, please verify that you have the appropriate pullup resistors on SDA (PA7) and SCL (PA6).

  • Hi Bob,

    Thanks for the quick response.

    We have all the appropriate pull-ups on SDA & SCL.

    Hardware wise, it is good.

    Thanks & Regards,

    Narpat

  • OK, I don't have a hardware setup yet, but some things I have run into. When I compiled the files you sent I got an error that TMP102_54VADD_R was not defined. If this is the slave address of the TMP102, then it is the same as the write address. You only supply the 7 bits, the function changes the 8th, read/write bit. You don't define separate addresses for read and write. If the A0 pin is tied high, then this would be 0x49.

    I also see in line 70 of main.c a direct register write to clear the FIFO. There is no I2C FIFO on this device. Your code example probably came from a TM4C129x device that does have the I2C FIFO.

  •  I ran the code (including the write to the non-existent FIFO control) and I see the appropriate SCL and SDA pin toggles. I don't have a TMP102 attached so I have NAK instead of ACK. Here is the logic analyzer trace. You might want to double check all of your hardware connections.

  • Thank you Bob,

    After doing the required changes I am able to see the I2C transaction.

    Now, I am able to read temp sensor (tmp102) registers. I am getting default values of temp registers (temp_high & temp_low) as 80 & 75. Need to implement the correct logic to get the temp value.

    Is there any reference code for tmp102 ?

    Thanks & Regards,

    Narpat

  • I don't have a TMP102 example, but I will move your question to the sensor group. There is an example using the EK-TM4C123GXL with a TMP006 in TivaWare: C:\ti\TivaWare_C_Series-2.1.4.178\examples\boards\ek-tm4c123gxl-boostxl-senshub\temperature_tmp006

  • Hi Narpat,

    The format of the temperature register (pointer 0) is the same as the temp high and temp low registers (pointers 2 and 3.) If you've already read and verified those registers, then you have what you need to read temperature as well.

    I don't believe we have any reference code.

    Thanks,

    Ren 

  • Thank you Bob,

    I am able to read the Temp sensor values.

    I have another requirement that how do we allocate the buffer for I2C in TM4C123GH6PM ?

    Thanks & Regards,

    Narpat

  • Thanks Ren for your quick response,

    I am able to read the temp sensor values through i2c.

    Thanks & Regards,

    Narpat

  • Narpat Mali said:
    how do we allocate the buffer for I2C in TM4C123GH6PM ?

    I don't understand the question. Are you asking how to create a buffer in C that can be used to store your temperature readings? Just declare an array. Since the data is 12 bits, it is most convenient to use uint16_t. If the array needs to be accessed from both an interrupt routine and the main code, then it should be static (declared outside of function scope).

      uint16_t tempReadings[100];