Hi everyone,
I am trying to use dsPIC33F to interface with my TMP112 temperature sensor. However, I am running into some weird issue. It looks like I was able to write to the slave TMP112 and receive the Acknowledge(ACK). However, I am not able to receive the data sent from the TMP112 device. Any thoughts on why?
I am running at Fscl = 100kHz.
below is the main temperature read function.
double I2C_Read_Temperature(){
unsigned char I2C1_TX_BUF[1];
I2C1_TX_BUF[0]=Temperature_Register;
I2C1_Write(1,I2C1_TX_BUF); //byte length one.
//I2C1_Write is a complete write function that includes Start bit,
//data transmit, and Stop bit.
/*initialize RX Buffer*/
I2C1_RX_BUF[0]=0;
I2C1_RX_BUF[1]=0;
I2C1_Read(2); //read in data of 2 byte
//I2C1_Read is a complete read function that first write Read to the slave
// and then start reading data.
unsigned char T_H = I2C1_RX_BUF[0];
unsigned char T_L = I2C1_RX_BUF[1];
double temperatureResult = Decimal_Convert(T_H,T_L);
return temperatureResult;
}
thank you for your help!
Chih-Wei