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.

how to interface ds1302 with at89s8252?

Status
Not open for further replies.

tapan.entc

Newbie level 6
Newbie level 6
Joined
Dec 25, 2009
Messages
11
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
bhubaneswar, India
Activity points
1,393
ds1302 with at89s8252

how to interface ds1302 with at89s8252?
i have a problem on ram memory used in ds1302. There is no special registers for sec, min ,date as in other RTC.

So how i will write a code in assembly??

Please help me ...........

please give me assembly code for this.

please help me .......
 

Re: ds1302 with at89s8252

Hi tapan.entc,

I suggest that you can use forum's search facility to find solutions to your problems because this area might be discussed within the forum. Check some topic as below






regards
bassa
 

Re: ds1302 with at89s8252

thanks bassa.

thanks for replying...
it will be better if you give suggestion on ds1302.

waiting for ur reply
 

Re: ds1302 with at89s8252

Hi,

herewith I upload "Interfacing a DS1302 With an 8051-Type Microcontroller" from MAXIM with C source code "DEMO1302.C" and you can modify the code to suit your requirements (**broken link removed**)

as well you check the following topics





and also go through the following links


**broken link removed**

hope this will help better

regards
bassa
 

Re: ds1302 with at89s8252

hello bassa
thanks for replay and giving the links..... i will go for that links.
'but before that i have a request that please go through my asm code
and tell me where i am wrong .

i am interfacing ds 1302 with at89s52 and displaying the time in 2*16 lcd
please check the program and give me suggestion that where i am wrong.
the code is as :


Code:
;###############################################
;PROGRAM FOR INTERFACING RTC WITH AT89S8252
;author: Tapan Rout
;###############################################      
  	CE  EQU  P1.7        ; 
        IO  EQU  P3.4
        SCLK EQU  P1.6

	com_adr  equ 0fe00h	;LCD COMMAND REGISTER ADDRESS
	dat_adr  equ 0fe01h	;LCD DATA REGISTER ADDRESS

	ORG 0000H
	AJMP MAIN

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;MAIN PROGRAM STARTS HERE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	ORG 030H
MAIN:

	ACALL LCD_INIT		;initializing LCD

        MOV  R1,#8EH          ;  WRITE PROTECT  MODE
        MOV  R0,#0
        LCALL WRITE

	MOV  R1,#90H          ; TRICKLE CHARGER REGISTER AND DIODE SELECT
        MOV  R0,#0ABH		;2 DIODES, 8K
        ACALL WRITE

        MOV  R1,#80H          ; WRITE  SECONDS
        MOV  R0,#0
        ACALL WRITE

        MOV  R1,#82H          ; WRITE MINUTES
        MOV  R0,#05H
        ACALL WRITE

        MOV  R1,#84H           ;WRITE  HOURS 
        MOV  R0,#11H
        CALL WRITE		

        MOV  R1,#86H          ; WRITE DATE : 27 
        MOV  R0,#27H
        ACALL WRITE

        MOV  R1,#88H           ;WRITE  MONTH : 9(SEPTEMBER)
        MOV  R0,#9
        ACALL WRITE

        MOV  R1,#8CH          ; WRITE YEAR : 09 (2009)
        MOV  R0,#09H
        ACALL WRITE			
           
;/*
	mov scon,#50h
	mov tmod,#20h
	mov th1,#0fdh
	MOV TL1,0FDH
	mov tcon,#45h
	setb tr1   	;*/
SS:   
  	setb TI

 SS1:	MOV  R1,#81H         ; READ SECONDS
        CALL READ
        MOV  20H,R0

        MOV  R1,#83H         ; READ MINUTES
        CALL READ
        MOV  21H,R0
	
	MOV  R1,#85H         ; READ HOUR 
        CALL READ
        MOV  22H,R0
	
        MOV  R1,#87H         ; READ  DATE
        CALL READ
        MOV  23H,R0

        MOV  R1,#89H         ; READ MONTH 
        CALL READ
        MOV  24H,R0

        MOV  R1,#8DH         ; READ YEAR
        CALL READ
        MOV  25H,R0			

DIS:
	MOV A,21H		;read minutes and display in lcd
	PUSH ACC
	MOV A,#86H
	ACALL COMNWRT
	ACALL DELAY
	MOV A,#':'
	ACALL DATAWRT
	ACALL DELAY
	POP ACC
	ACALL ASCIICONV	

	MOV A,22H		;rad hours and display in lcd
	PUSH ACC
	MOV A,#84H
	ACALL COMNWRT
	ACALL DELAY
	POP ACC
	ACALL ASCIICONV

	MOV A,22H
	JB ACC.5,GO		;check the condition for AM or PM
	MOV A,#8AH
	ACALL COMNWRT
	ACALL DELAY
	MOV A,#'A'
	ACALL DATAWRT
	ACALL DELAY
	MOV A,#'M'
	ACALL DATAWRT
	ACALL DELAY
	SJMP GO1
GO:	MOV A,#8AH
	ACALL COMNWRT
	ACALL DELAY
	MOV A,#'P'
	ACALL DATAWRT
	ACALL DELAY
	MOV A,#'M'
	ACALL DATAWRT
	ACALL DELAY

GO1:	
	JNB RI,SS1
	CLR RI

       AJMP  SS

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;WRITE  OPERATION
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
  WRITE:
  	CLR  SCLK		;CLEAR SCLK LINE 
        NOP
        NOP
        SETB CE        		; SET CE  HIGH FOR WRITE OPERATION
        NOP
        MOV  A,R1		;LOAD THE ADDRESS
        MOV  R2,#8		;COUNT =8
  WRITE_1: RRC  A          	; 
        MOV  IO,C		; SEND LSB FIRST AND THEN CONTINUE
        NOP
        NOP
        SETB SCLK		
        NOP
        NOP
        CLR  SCLK
        DJNZ R2,WRITE_1
        NOP
        NOP
  ;*************
        MOV  A,R0		;LOAD THE DATA
        MOV  R2,#8		;SET  COUNT =8
  WRITE_2: RRC  A          ; 
        MOV  IO,C
        NOP
        NOP
        SETB SCLK
        NOP
        NOP
        CLR  SCLK
        DJNZ R2,WRITE_2
        NOP
        NOP
        CLR  CE
        NOP
        NOP

        RET
;**********************************************/
;READ OPERAION
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  READ:
  	SETB  CE		;SET CE
        MOV  A,R1		;LOAD ADDRESS FIRST
        MOV  R2,#8
  READ_1: RRC  A
        MOV  IO,C		;MOVE THE ADDRESS THROUGH IO PIN
        NOP
        NOP
        SETB SCLK		;SET SCLK 
        NOP
        NOP
        CLR  SCLK		;CLEAR SCLK FOR WRITE OPERATION
        DJNZ R2,READ_1
        NOP
        NOP
        SETB IO
        CLR  A
        CLR  C
        MOV  R2,#8
  READ_2: MOV  C,IO
        RRC  A
        NOP
        NOP
        SETB SCLK
        NOP
        NOP
        CLR SCLK
        NOP
        NOP
        DJNZ R2,READ_2
        MOV  R0,A
;        ANL  A, #7FH
        CLR  CE
	
        RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;LCD INITIALIZATION
;...............................................
LCD_INIT:
	MOV A,#38H
	ACALL COMNWRT
	ACALL DELAY

	MOV A,#0CH
	ACALL  COMNWRT
	ACALL DELAY

	MOV A,#01H
	ACALL  COMNWRT
	ACALL DELAY

	MOV A,#06H
	ACALL  COMNWRT
	ACALL DELAY

RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;
COMNWRT:
	MOV DPTR,#COM_ADR
	MOVX @DPTR,A
	NOP
	NOP
       RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
DATAWRT:
	MOV DPTR,#DAT_ADR
	MOVX @DPTR,A
	NOP
	NOP	
       RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ASCIICONV:
	PUSH ACC
;	MOV A,R0
	SWAP A
	ANL A,#0FH
	ORL A,#30H
	ACALL DATAWRT
	ACALL DELAY
;	MOV A,R0
	POP ACC
	ANL A,#0FH
	ORL A,#30H
	ACALL DATAWRT
	ACALL DELAY
RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
DELAY:
	MOV R3,#200
BACK:	MOV R4,#255
	DJNZ R4,$
	DJNZ R3,BACK

RET

        END
 

Re: ds1302 with at89s8252

tapan.entc said:
hiii pranam77,i am not able to attach the file. can u tell me
If you are trying to attach a hex file, or a source code, you cant. You have to ZIP it or compress it in .RAR and then Upload it. Cheers
 

Re: ds1302 with at89s8252

hello pranam

please see the code and help me ....

i have only one day left for me to complete this code

i hope you will suggest me..
 

Re: ds1302 with at89s8252

tapan.entc said:
hello pranam. please see the code and help me ....i have only one day left for me to complete this code. i hope you will suggest me..
Frankly speaking, i am not the right person to debug source codes. You may get better replies from fellow memebers. Please be patient....Cheers
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top