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.

8051 microcontroller (prototyped with AT89S52) based clock using RTC DS12887 and LCD

Status
Not open for further replies.

papunblg

Advanced Member level 3
Joined
Oct 22, 2010
Messages
716
Helped
172
Reputation
344
Reaction score
165
Trophy points
1,343
Location
Kolkata India
Activity points
6,421
(Any comment, modification humbly accepted.)
Here is a 8051 microcontroller (prototyped with AT89S52) based clock using RTC DS12887+ chip using LCD DISPLAY. The advantage of RTC DS12887 is that the chip includes battery for backup in power failure! The Prototype is shown in the picture has two separate vero boards. One includes the AT89S52 and the RTC. And the second board has the LCD and a preset pot to control the brightness. All the parts could be assembled on a single vero board. Actually the same board (second one) I used in my previous project(8051 based voltmeter). Crystal used with AT89S52 is 12MHz. In DS12887+, pin no 2,3,16,20,21,22 are non contact pins and are not present in actual package. A 10K pot is used to control the brightness of the LCD. Of course, 5V regulated supply is used for the whole circuit. Pullup resistors are not required for port 0 and must be connected with RTC pins 4 to 11 .

Code to set date and time-[first burn the hex file and run the code to setup. Can be change date and time and run again]
-------------------------------
ORG 00H
; Turning on RTC
ACALL ONETIME_LCDINIT
ACALL DELAY_200M
MOV R0,#10
MOV A,#20H
MOVX @R0,A
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MOV R0,#11
MOV A,#83H
MOVX @R0,A
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MOV R0,#0
MOV A,#0H
MOVX @R0,A
MOV R0,#02
MOV A,#15H
MOVX @R0,A
MOV R0,#04
MOV A,#14H
MOVX @R0,A
;;;;;;;;;;;;;;;;;;;;;;;

MOV R0,#07
MOV A,#03H
MOVX @R0,A
MOV R0,#08
MOV A,#09H
MOVX @R0,A
MOV R0,#09
MOV A,#11H
MOVX @R0,A


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MOV R0,#11
MOV A,#03
MOVX @R0,A

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

OV1:
MOV A,#84H
ACALL COMMAND
MOV R0,#4
MOVX A,@R0
ACALL BCDTOASCII
MOV A,#':'
ACALL DATA_DISPLAY
MOV R0,#2
MOVX A,@R0
ACALL BCDTOASCII
MOV A,#':'
ACALL DATA_DISPLAY
MOV R0,#0
MOVX A,@R0
ACALL BCDTOASCII
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MOV A,#0C4H
ACALL COMMAND
MOV R0,#7
MOVX A,@R0
ACALL BCDTOASCII
MOV A,#'/'
ACALL DATA_DISPLAY
MOV R0,#8
MOVX A,@R0
ACALL BCDTOASCII
MOV A,#'/'
ACALL DATA_DISPLAY
MOV R0,#9
MOVX A,@R0
ACALL BCDTOASCII

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ACALL DELAY
ACALL DELAY
SJMP OV1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
BCDTOASCII:
MOV B,A
SWAP A
ANL A,#0FH
ORL A,#30H
ACALL DATA_DISPLAY
MOV A,B
ANL A,#0FH
ORL A,#30H
ACALL DATA_DISPLAY
RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ONETIME_LCDINIT:
MOV A,#38H
ACALL COMMAND
MOV A,#0EH
ACALL COMMAND
MOV A,#01H
ACALL COMMAND
MOV A,#06H
ACALL COMMAND
MOV A,#86H
ACALL COMMAND
RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
COMMAND:
ACALL READY
MOV P1,A
CLR P2.0
CLR P2.1
SETB P2.2
CLR P2.2
RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
DATA_DISPLAY:
ACALL READY
MOV P1,A
SETB P2.0
CLR P2.1
SETB P2.2
ACALL DELAY
CLR P2.2
RET
READY: SETB P1.7
CLR P2.0
SETB P2.1
BACK: CLR P2.2
ACALL DELAY
SETB P2.2
JB P1.7,BACK
RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
DELAY_200M:
MOV R7,#4
L1_DELAY:
MOV TMOD,#10
MOV TH1,#3CH
MOV TL1,#0B0H
SETB TR1
AGAIN: JNB TF1,AGAIN
CLR TR1
CLR TF1
DJNZ R7,L1_DELAY
RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
DELAY: MOV R3,#50
HERE3: MOV R4,#255
HERE2: DJNZ R4,HERE2
DJNZ R3,HERE3
RET
END
-----------------------------------------------------------
Code to display date and time:-[ burn the hex file and run the code to display.]

ORG 00H
; Turning on RTC
ACALL ONETIME_LCDINIT
ACALL DELAY_200M
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MOV R0,#11
MOV A,#03
MOVX @R0,A
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
OV1:
MOV A,#84H
ACALL COMMAND
MOV R0,#4
MOVX A,@R0
ACALL BCDTOASCII
MOV A,#':'
ACALL DATA_DISPLAY
MOV R0,#2
MOVX A,@R0
ACALL BCDTOASCII
MOV A,#':'
ACALL DATA_DISPLAY
MOV R0,#0
MOVX A,@R0
ACALL BCDTOASCII
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MOV A,#0C4H
ACALL COMMAND
MOV R0,#7
MOVX A,@R0
ACALL BCDTOASCII
MOV A,#'/'
ACALL DATA_DISPLAY
MOV R0,#8
MOVX A,@R0
ACALL BCDTOASCII
MOV A,#'/'
ACALL DATA_DISPLAY
MOV R0,#9
MOVX A,@R0
ACALL BCDTOASCII
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ACALL DELAY
SJMP OV1
BCDTOASCII:
MOV B,A
SWAP A
ANL A,#0FH
ORL A,#30H
ACALL DATA_DISPLAY
MOV A,B
ANL A,#0FH
ORL A,#30H
ACALL DATA_DISPLAY
RET
ONETIME_LCDINIT:
MOV A,#38H
ACALL COMMAND
MOV A,#0EH
ACALL COMMAND
MOV A,#01H
ACALL COMMAND
MOV A,#06H
ACALL COMMAND
MOV A,#86H
ACALL COMMAND
RET
COMMAND: ACALL READY
MOV P1,A
CLR P2.0
CLR P2.1
SETB P2.2
CLR P2.2
RET
DATA_DISPLAY:
ACALL READY
MOV P1,A
SETB P2.0
CLR P2.1
SETB P2.2
ACALL DELAY
CLR P2.2
RET
READY: SETB P1.7
CLR P2.0
SETB P2.1
BACK: CLR P2.2
ACALL DELAY
SETB P2.2
JB P1.7,BACK
RET

DELAY_200M:
DELAY_FORLOOP:
MOV R7,#4
L1_DELAY:
MOV TMOD,#10H
MOV TH1,#3CH
MOV TL1,#0B0H
SETB TR1
AGAIN: JNB TF1,AGAIN
CLR TR1
CLR TF1
DJNZ R7,L1_DELAY
RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
DELAY: MOV R3,#50
HERE3: MOV R4,#255
HERE2: DJNZ R4,HERE2
DJNZ R3,HERE3
RET
END

------------------------
Picture of the working model below
ttp .jpgDSC01484.JPG
 

hi,
additional serial ADC and or serial EEPROM will be nice..
 

this is a very good tutorial.whr can i buy ds12887 and what is its cost
 

I purchased DS12887A+ from a shop LRM market near Candni Chowk, New Delhi. @Rs.500/- [year 2010]. I heard that some shops in that market are notorious for cheating. So actual price may vary.

SD12887 is easy to use (programming) for its parallel connection. Easy to use as no additional components are required, even a 10year battery included inside the IC. Price is a factor.

But DS1307 is very very low priced RTC but above mentioned advantages are not present.
 

will u pls make it for 7 segment
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top