Riaz Haider -4 Newbie Poster

hi....
i have connected a real time clock chip DS12887 with an 8051.
the data of the rtc is brought into the controller and displayed on two 7 segment displays.
the 7 segs are connected to P 1 of the uc. BCD data is recieved in the form of 2 nibbles having 2 digits of time. So i get hours in one byte, minutes in the next and then seconds.
PROBLEM: i have a momentary switch(actually an infrared switch) which i have used such that when it is tripped time is displayed on the display.
but the problem i am having is that sometimes i get correct 3 bytes on the display such that hours then minutes then seconds while sometimes i get three second displays in one go.
The code is in ASM and is as follows

;; SETTING THE TIME	MODE

	MOV R0,#11
	MOV A,#83H
	MOV @R0,A

;;; SETTING THE TIME

	MOV  	R0,#0
	MOV  	A,#23H
	MOVX 	@R0,A
	MOV  	R0,#02
	MOV  	A,#36H
	MOVX  	@R0,A
	MOV  	R0,#04
	MOV  	A,#12H
	MOVX 	@R0,A
	MOV 	R0,#11
	MOV 	A,#03
	MOVX 	@R0,A

		;;;;;



NO_CROSS:	JB P3.0, NO_CROSS
			SETB READY
HOURS: 
			MOV R0, #4
			MOVX A,@R0
			MOV P0,A
			MOV P1,A 			
			ACALL DELAY
			ACALL DELAY
			ACALL DELAY
			
		
			
MINUTES: 
			MOV R0,#2
			MOVX A,@R0
			MOV P0,A
			MOV P1,A 			
			
			ACALL DELAY
			ACALL DELAY
			
			
SECONDS: 
			MOV R0,#0
			MOVX A,@R0
			MOV P0,A
			MOV P1,A 
			
			ACALL DELAY
			ACALL DELAY
			ACALL DELAY
			MOV P1,#00H
			ACALL DELAY
			ACALL DELAY
			ACALL DELAY
			ACALL DELAY

								
RUNONCE:	JNB P3.0, RUNONCE
			MOV P1,#00H
			CPL READY			
			SJMP NO_CROSS
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.