Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

interfaceing pic16f877, lcd & rtc ds1307

Status
Not open for further replies.

durgap

Newbie level 3
Joined
Mar 27, 2009
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,315
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
 

Hi,


The i2c routine can be difficult to get going.

Here is a complete working project , author unknown.

It should be very easy to convert to a 877, if you have proteus you can see this project working using the .dsn file.
 

Attachments

  • rtc_asm.rar
    25.1 KB · Views: 99

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.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top