Member #480137

Member Since: October 18, 2013

Country: United States

  • Product SEN-09418 | about 7 months ago

    Hey Guys!

    Am a newbie in PIC programming. I recently purchase this tmp102 breakout board for my school project. Am trying to read the temperature register with PIC16F877A using CCS Compiler. I connect the SDA and SCL to the SDA and SCL pins of the PIC respectively and ADD0 to ground. The tmp102 is powered with 3.3vcc. Everything went weird as what am getting is 255(0xFF) and 255(0xFF) for the MSB and LSB respectively. This might not be the appropriate place to post this challenge, but has any one done something related to this or can link me to other resources?

    Here is the code am using in CCS C

    // tmp102 code
    #include  
    #FUSES NOWDT                     
    #FUSES HS                        
    #FUSES NOBROWNOUT                
    #FUSES NOLVP, PUT 
    
    #use delay(clock=20000000)
    #use i2c(Master, sda=PIN_C4,scl=PIN_C3) // Configure Device as Master
    #use rs232(baud=4800,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=UART, ERRORS)
    
    #define TMP_RD       0x72
    #define TEMP_REG    0x00
    
    void main()
    {
    
    delay_ms(2000);         
     fprintf(UART,"TMP102 Example \r\n");
     fprintf(UART,"Reading Started...\r\n");
     delay_ms(500);
     while (1)
       {
          unsigned int8 msb, lsb;
    
          i2c_start();   
          i2c_write(TMP_RD);      // Read from this I2C address, R/*W Set
          delay_ms(50);
          i2c_write(TEMP_REG);       //Set pointer regster to temperature register  
          msb= i2c_read(1);            //Read the MSB data
          lsb = i2c_read(0);            //Read the LSB data
          i2c_Stop();
    
          printf(" %u ", msb); // check
          printf(" %u ", lsb);    // check
    
          delay_ms(3000); 
       }
    }
    

    Thanks

No public wish lists :(