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.

Reading RTC DS1307 memory

Status
Not open for further replies.

toyib

Junior Member level 1
Junior Member level 1
Joined
May 12, 2008
Messages
15
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
indonesia
Activity points
1,387
how do i connect ds1307 to 8051

hai all.....

i use AT89S51 can u explaint how to read the DS1307 data (seconds, minutes, hours,day etc.)?

how can i save them (seconds, minutes, hours,day etc.) in the AT89s51 memory (RAM)??

can u send the code(in assembly)?
 

rtc with memory

The following application note from MAXIM explains in details how to connect the DS1307 to 8051-derivatve including an example of asm code ..

"Interfacing the DS1307 with an 8051-Compatible Microcontroller"
**broken link removed**

Regards,
IanP
 

thank's for answer....

i have read it
but i don't undestand yet
please give me simple rutin (.asm) for reading data from DS1703 and save in AT89S51


thank's
 

Use this code
Code:
; **********************************************************
; SUB READS THE CLOCK AND WRITES IT TO THE SCRATCHPAD MEMORY
; ON RETURN FROM HERE DATE & TIME DATA WILL BE STORED IN THE
; DATE & TIME REGISTERS 
; **********************************************************
READ_CLOCK:
         MOV         R1,#SECS   ; SECONDS STORAGE LOCATION
         MOV         BYTECNT,#00H
         CLR         LASTREAD
         CALL       SEND_START
         MOV         A,#DS1307W
         CALL       SEND_BYTE
         MOV         A,#00H
         CALL       SEND_BYTE
         CALL       SEND_STOP
         CALL       SEND_START
         MOV         A,#DS1307R
         CALL       SEND_BYTE

READ_LOOP:
         MOV         A,BYTECNT
         CJNE        A,#09H,NOT_LAST
         SETB        LASTREAD

NOT_LAST:
         CALL       READ_BYTE
         MOV         @R1,A
         MOV         A,BYTECNT
         CJNE        A,#00H,NOT_FIRST
         MOV         A,@R1
         CLR         ACC.7      ; ENSURE OSC BIT=0 (ENABLED)
         MOV         @R1,A
NOT_FIRST:
         INC         R1
         INC         BYTECNT
         MOV         A,BYTECNT
         CJNE        A,#0AH,READ_LOOP
         CALL       SEND_STOP
         RET
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
[/code]
 

im sorry i don't understand yet
here my circuit

72_1216873274.jpg


how i can read RTC momory
what i must do


please give me some code (read and give value of RTC memory) that can be compiled with asem51



thank's
 

First you read and understand the I2C protocol.Ten you will understand how to read the time from rtc.Then just compare the codes given above and try to understand what it is actually doing..

Regards
Sajeev
 

can RTC DS1307 save any configratio??
alarm setting for example


thank's friend
 

toyib said:
can RTC DS1307 save any configratio??
alarm setting for example


thank's friend

No, DS1307 has only time,date,year..etc registers.It dont have any alarm setting registers.You have do it in microcontroller by using variables.DS1307 has an extra 56bytes of ram .You can use it as general purpose ram.


Regards
Sajeev
 

ok guys thNK'S for answers
i can more understand about RTC1307 than before


toyib
 

yeah toyib you should learn first what I2C is... just read the datasheet.....if anything that you don't understand, you can post here...
 

ok thank's 4 all i'll try
and the result .......
i'll report it later


thank's
 

Might anyone know how to use the DS1307 and a 16F628A to count backwards from 99 DAYS?
 

Re: how do i connect ds1307 to 8051

hai all.....

i use AT89S51 can u explaint how to read the DS1307 data (seconds, minutes, hours,day etc.)?

how can i save them (seconds, minutes, hours,day etc.) in the AT89s51 memory (RAM)??

can u send the code(in assembly)?
Hi
use this code for read and get the the time from micro controller
====================================
unsigned char DS1307_get(unsigned char addr)
{
unsigned char ret1,x;
I2C_start(); /* Start i2c bus */
I2CSend(DS1307_ID); /* Connect to DS1307 */
I2C_ack();
I2CSend(addr); /* Request RAM address on DS1307 */
I2C_ack();
I2C_start(); /* Start i2c bus */
I2CSend(DS1307_ID+1); /* Connect to DS1307 for Read */
//I2C_ack();
for(x=0;x<7;x++)
{
a[x]=I2CRead();
if(x==6)
I2C_noack();
else
I2C_ack();
}

//ret = /* Receive data */

I2C_stop(); /* Stop i2c bus */
return ret1;
}
=========================
unsigned char I2CRead(){
unsigned char i, Data=0;
for(i=0;i<8;i++){
SCL = 0;
SCL = 1;
if(SDA)
Data |=1;
Data<<=1;
}
SCL = 0;
SDA = 1;
return Data;
}
==============================
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top