anboli
Full Member level 2
i have the problem with I2C program, while interfacing with ds1307 RTC.
can anyone upload the I2C header or program for the 8051 controller?
here is my source code for I2C.
void I2CInit()
{
SDA = 1;
SCL = 1;
}
void I2CStart(){
SDA=1;
SCL=1;
_nop_(); //No operation
_nop_();
SDA=0;
SCL=0;
// SCL = 1;
// _nop_(); //No operation
// _nop_();
// SDA = 0;
// SCL = 0;
}
//===============================================================================
void I2CRestart(){
SCL = 0;
SDA = 1;
delay(4);
SCL = 1;
SDA = 0;
}
//===============================================================================
void I2CStop(){
SDA=0;
SCL=1;
_nop_();
_nop_();
SDA=1;
SCL=0;
// SCL = 0;
// SDA = 0;
// LCD_delay(4);
// SCL = 1;
// SDA = 1;
}
void I2CAck(){
SDA = 0;
SCL = 1;
_nop_();
_nop_();
SCL = 0;
SDA = 1;
}
//===============================================================================
void I2CNak(){
SDA = 1;
SCL = 1;
SCL = 0;
}
can anyone upload the I2C header or program for the 8051 controller?
here is my source code for I2C.
void I2CInit()
{
SDA = 1;
SCL = 1;
}
void I2CStart(){
SDA=1;
SCL=1;
_nop_(); //No operation
_nop_();
SDA=0;
SCL=0;
// SCL = 1;
// _nop_(); //No operation
// _nop_();
// SDA = 0;
// SCL = 0;
}
//===============================================================================
void I2CRestart(){
SCL = 0;
SDA = 1;
delay(4);
SCL = 1;
SDA = 0;
}
//===============================================================================
void I2CStop(){
SDA=0;
SCL=1;
_nop_();
_nop_();
SDA=1;
SCL=0;
// SCL = 0;
// SDA = 0;
// LCD_delay(4);
// SCL = 1;
// SDA = 1;
}
void I2CAck(){
SDA = 0;
SCL = 1;
_nop_();
_nop_();
SCL = 0;
SDA = 1;
}
//===============================================================================
void I2CNak(){
SDA = 1;
SCL = 1;
SCL = 0;
}