movlw B'00010000' ; sqwe enable at 1Hz
call Send_Byte
call StopI2C ; Initial STOP Condition
return
Sir=,
Is this the correct i2c code for setting ds1307 rtc. If wrong please tell me where I am wrong.
1. I have started i2c by "StartI2C"
2.Next send the device id with a write flag.
3.Send the address of the rtc
4. Send the data to be filled in that address.
5.Stop the i2c
Should i restart after every address access, or should i send a nAck after each access. I am confused how to access individual address and fill data in it.
Please help
Sir, I am not able to get even the first acknowlege (ACKSTAT=0) after a address send
call StartI2C ; Set SSPCON2.SEN
bcf I2C_Ctrl,0 ; Clear for Write Command
movf I2C_Ctrl,W ; Send Slave Address to I2C Bus
movlw 0xD0 ;address id of ds1307
call Send_Byte
; **an ACSTAT test fails , the bit is = 1
Please suggest what to do, I have even changed the rtc.