How can i add a way to check if an I2C device is active and can respond?
For example checking if the DS1631 sensor is seated in its socket or not?
Code is C18 for 18F26K22
For example checking if the DS1631 sensor is seated in its socket or not?
Code is C18 for 18F26K22
Code:
unsigned char Init_DS1631(void)
{
unsigned char Idata=0b10001101; // Config=12bit / 1shot
OpenI2C2(MASTER, SLEW_OFF); // Initialize I2C module
SSP2ADD=0x13; // 100khz = 8Mhz / ( ( 0x13+1) * 4 )
IdleI2C2();
StartI2C2(); // Generate I2C2 start condition
IdleI2C2();
WriteI2C2(0x90); // Address
IdleI2C2();
WriteI2C2(0xAC); // Config
IdleI2C2();
WriteI2C2(Idata); // Write config data
IdleI2C2();
StopI2C2();
}
Last edited: