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.

TMP112 interface with PIC16F690

Other Parts Discussed in Thread: TMP112

Hello.

Does anyone know how can I interface the temperature sensor TMP112 with Microchip PIC16F690?

It would be a great help if someone could show an example code in C.

  • Hello Natailia,

    I can help you with this as long as you are able to program your PIC16F690. If you already have your I2C lines connected to TMP112, its just a matter of reading register 0 of TMP112. More details about how to do this is in figure17 of data sheet:

    http://www.ti.com/lit/ds/symlink/tmp112.pdf

    Regards,

    Abhi

  • I'm having troubles with the I2C lines. So far I got this:

    #define SDA RC0
    #define SCL RC1

    #define SDA_DIR TRISC0
    #define SCL_DIR TRISC1

    #define SDA_HIGH() SDA_DIR=1
    #define SDA_LOW() SDA_DIR=0

    #define SCL_HIGH() SCL_DIR=1
    #define SCL_LOW() SCL_DIR=0

    #define I2C_TM_BUS_FREE 5 // min. 600ns

    #define I2C_TM_START_SU 5 // min. 100ns
    #define I2C_TM_START_HD 4 // min. 100ns

    #define I2C_TM_SCL_LOW 5 // min. 1300ns
    #define I2C_TM_SCL_HIGH 4 // min. 600ns

    #define I2C_TM_DATA_SU 1 // min. 100ns
    #define I2C_TM_DATA_HD 0 // min. 0ns

    #define I2C_TM_SCL_TO_DATA 4 // max. 300ns 

    #define I2C_TM_STOP_SU 4 // min. 100ns

    #define I2C_TM_SCL_TMO 10 // max. 1000ns 

    Do you have any sugestions to improve the code?

  • Hello Natailia,

    It's very difficult for us to relate the code to the I2C wave forms, do you have any provision to hook up an oscilloscope on the SCL and SDA lines? This way I can help you in making sure that you are following the protocol correctly.

    Best Regards,

    Abhi

  • Hello, thanks for replying.

    I actually do understand SCL, SDA, start and stop bit and I have this part of code. I've assign SDA and SCL to a PIC16F690 pin each one and programmed stop and start bit, it's that all I need to do to configure?

  • Hello Natailia,

    As far as the timing values defined, they seem to verify with the Fast mode MIN values specified in Table13 of TMP112 datasheet. This is a good start and I hope you are using pull up resistors (10Kohms recommended) on the SCl,SDA lines while conncting to the PIC. Also make sure that your communication waveforms resemble Figure 16 of datasheet. 

    Good Luck!

    Best Regards,

    Abhi