Dear all
I would like to Know what is read and write procedure to Get RTC data without library function.
weather its proper
I2c write
i2c_start() ; // start I2C communication: SDA goes down while SCL remains high
i2c_wr(ADDR_RTCC_WRITE); // send the RTCC's address for write = 0xde
i2c_wr(rtcc_reg) ; // send the register's address
i2c_wr (time_var) ; // send the data byte
i2c_stop() ; // stop I2C communication: SDA goes high while SCL remains high
I2c Read
i2c_start() ; // start I2C communication: SDA goes down while SCL remains high
i2c_wr(ADDR_RTCC_WRITE); // send the RTCC's address for write = 0xde
i2c_wr(rtcc_reg) ; // send the register's address
i2c_restart() ; // switch to reads
i2c_wr(ADDR_RTCC_READ) ; // send the RTCC's address for read = 0xdf
i2c_rd() ; // read the byte from the RTCC (register's content)
i2c_nack ; // NoACK from MCU to the RTCC (no more bytes to read)
i2c_stop() ; // stop I2C communication: SDA goes high while SCL remains high
Weather I2c function like we use PIC it will work on Arduino IDE.?? is any code example available
without wire library but using normal syntax
example we like using
[b]unsigned short I2C_Read(unsigned short ack)
{
unsigned short incoming;
I2C_Hold();
RCEN = 1;
I2C_Hold();
incoming = SSPBUF; //get the data saved in SSPBUF
I2C_Hold();
ACKDT = (ack)?0:1; //check if ack bit received
ACKEN = 1; //pg 85/234
return incoming;
}[/b]
void I2C_Write(unsigned data)
{
I2C_Hold(); //Hold the program is I2C is busy
SSPBUF = data; //pg82/234
}
void I2C_Hold()
{
while ( (SSPCON2 & 0b00011111) || (SSPSTAT & 0b00000100) ) ; //check the this on registers to make sure the IIC is not in progress
}