FDC1004 Capacitance sensor interface with PIC16F877a

Thread Starter

karthi keyan 9

Joined Apr 17, 2018
30
Hi,
I am using FDC1004 for capacitance measurement. I set configuration and FDC register through I2C but still, I am getting 255 in 0x00 and 0x01 Registers of FDC1004. I feel that FDC got saturated. Please look into the attachment for more details.

Code:

{
unsigned long data1,data2;
}

while(1)
{
i=1;
Lcd4_Clear();
Call_senor(); // FDC1004

result = data1; // 0x00 Reg
Lcd4_Set_Cursor(2,1);
send_data_to_LCD(result);
__delay_ms(2000);

result = data2; //0x01 Reg
Lcd4_Set_Cursor(2,1);
send_data_to_LCD(result);
__delay_ms(2000);
}
}
/*
*This function is used to call the I2C driver and acquire the data.
*/
void Call_senor()
{
I2C_Start();
while(I2C_Write_Byte(0xA0)==1) // Write address
{
I2C_Start();
}
I2C_Write_Byte(0x08); // Conf reg
I2C_Write_Byte(0x0C); //MSB
I2C_Write_Byte(0x00); //LSB
I2C_Stop();

I2C_Start();
while(I2C_Write_Byte(0xA0)==1)
{
I2C_Start();
}
I2C_Write_Byte(0x0C); //FDC reg
I2C_Write_Byte(0x05); //MSB
I2C_Write_Byte(0x80); //LSB
I2C_Stop();

__delay_ms(50);

I2C_Start();
while(I2C_Write_Byte(0xA0)==1)
{
I2C_Start();
}
I2C_Write_Byte(0x00);
I2C_ReStart();
I2C_Write_Byte(0xA0);


data1 = I2C_Read_Byte(); // 0x00 register data
I2C_Send_ACK();
data2 = I2C_Read_Byte(); // 0x01 register data
I2C_Send_NACK();

I2C_Stop();

}
 
Top