durgap
Newbie level 3
DS1307_init
call StartI2C ; Set SSPCON2.SEN
bcf I2C_Ctrl,0 ; set for write Command
movf I2C_Ctrl,W ; Send Slave Address to i2C Bus
call Send_Byte
movlw 0x00 ; 00H address
call Send_Byte
movlw B'00000000' ; clk_halt bit disabled
call Send_Byte
movlw 0x02 ; 02H address 12/24 hrs format
call Send_Byte
movlw B'00000000' ; 24 hrs mode setting
call Send_Byte
movlw 0x07 ; 07H address SQWE /RS0/RS1 call Send_Byte
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
call StartI2C ; Set SSPCON2.SEN
bcf I2C_Ctrl,0 ; set for write Command
movf I2C_Ctrl,W ; Send Slave Address to i2C Bus
call Send_Byte
movlw 0x00 ; 00H address
call Send_Byte
movlw B'00000000' ; clk_halt bit disabled
call Send_Byte
movlw 0x02 ; 02H address 12/24 hrs format
call Send_Byte
movlw B'00000000' ; 24 hrs mode setting
call Send_Byte
movlw 0x07 ; 07H address SQWE /RS0/RS1 call Send_Byte
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