Interface RTC pcf 8563 with 89c52

Status
Not open for further replies.

Jenifer a

Newbie level 6
Joined
Jul 23, 2013
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
118
Hai....

I need to interface PCF 8563 with 89c52..... Can anyone help me with the ASM codes



Thanks in advance
 

Thank you very much.....
sry i cannot download from that... please give me some ideas or sample codes....
 

hai.....

can you please help me with the asm codes to enable the clockoutput of pcf8563 interfacing with 89c52.

Thanks in advance....
 

Address 0Dh controls the CLKOUT output frequency

8.1 CLKOUT output
A programmable square wave is available at the CLKOUT pin. Operation is controlled by
the register CLKOUT_control at address 0Dh. Frequencies of 32.768 kHz (default),
1.024 kHz, 32 Hz, and 1 Hz can be generated for use as a system clock, microcontroller
clock, input to a charge pump, or for calibration of the oscillator. CLKOUT is an open-drain
output and enabled at power-on. If disabled it becomes high-impedance.

0x0D is CLKOUT register address

Write one of the below value to register at address 0x0D

10000000 = 0x80 = 32.768 KHz
10000001 = 0x81 = 1.024 KHz
10000010 = 0x82 = 32 Hz
10000011 = 0x83 = 1 Hz
 
Thank you very much.....
how to load this value? i done it but i didnt get it.....

I wrote write routine for rtc. in that i load this value by using this command
mov 0dh,#10000000b but i didnt get

This is my write routine......
Code:
;****** rtc write routine *******

rtcwt:	
    lcall delay      ; clk write
    lcall strtc		 
    mov a,#10100010b ;rtc write addr
    lcall dsndrtc
    mov a,#02h         ;word addr
    lcall dsndrtc
    mov a,#00h
    lcall dsndrtc
    mov 0dh,#10100000b ;clk out
    mov a,0dh
    lcall dsndrtc
    lcall stprtc
;****RTC  start routine ****

strtc:
    setb p1.3 ;initial condition
                    (set sda)
    setb p1.2 ;set sclk pulse

    clr p1.3  ;high to low
                 transmission of 
                 data line 
                 with high clock

    clr p1.2  ;to transmite data
                 clear clock
    ret

;**** RTC stop routine ****

stprtc:	
     clr p1.3	    ;stop con
     setb p1.2	
     setb p1.3
     ret

;**** data tx for rtc bit by bit ****

Dsndrtc:	
     push 4fh
     mov 4fh,#08h ;to transmit 8 bits

frt:
    rlc a
    jc her	;if carry set
                 go to "her"
    clr p1.3	;if carry low
                 clear data line
    sjmp tyh

her:	
   setb p1.3  ;if carry high
                   set data line
tyh:	
    setb p1.2
    clr p1.2
    djnz 4fh,frt
	
ger:	
    setb p1.3  ;ack 
    setb p1.2
    clr p1.2
    pop 4fh
    ret
end
 
Last edited:

In the maxim integrated link I gave there is a i2c asm routine to send a byte (shown below). Use it to send data (byte) to your PCF device. First send the CLKOUT register address byte and then send byte for required frequency.


Code ASM - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
;-----------------------------------------------------------------------
; THIS SUB SENDS ONE BYTE OF DATA TO THE DS1307
;-----------------------------------------------------------------------
SEND_BYTE:
MOV BITCOUNT,#08H ; SET COUNTER FOR 8 BITS
SB_LOOP:
JNB ACC.7,NOTONE ; CHECK TO SEE IF BIT 7 OF ACC IS A 1
SETB SDA ; SET SDA HIGH (1)
JMP ONE
NOTONE:
CLR SDA ; CLR SDA LOW (0)
ONE:
LCALL SCL_HIGH ; TRANSITION SCL LOW-TO-HIGH
RL A ; ROTATE ACC LEFT ONE BIT
CLR SCL ; TRANSITION SCL HIGH-TO-LOW
DJNZ BITCOUNT,SB_LOOP ; LOOP FOR 8 BITS
SETB SDA ; SET SDA HIGH TO LOOK FOR ACKNOWLEDGE PULSE
LCALL SCL_HIGH ; TRASITION SCL LOW-TO-HIGH
CLR ACK ; CLEAR ACKNOWLEDGE FLAG
JNB SDA,SB_EX ; CHECK FOR ACK OR NOT ACK
SETB ACK ; SET ACKNOWLEDGE FLAG FOR NOT ACK
SB_EX:
LCALL DELAY ; DELAY FOR AN OPERATION
CLR SCL ; TRANSITION SCL HIGH-TO-LOW
LCALL DELAY ; DELAY FOR AN OPERATION
RET






Edit:


What do you mean by this?


Code ASM - [expand]
1
mov 0dh,#10000000b but i didnt get



The 0x0D is the address of CLKOUT register of PCF8563. You are sending 0x80 to 0x0D register of 8052.

Use I2C routine posted above and send these bytes one after another.

I2C start
I2C Write 0xA2 [PCF 8563 Device address]
I2C Write 0x0D [CLKOUT control register address]
I2C Write 0x80 or 0x81 or 0x82 or 0x83 [value for particular frequency]
I2C Stop

CLKOUT pin should be pulled-up using 10k as it a open-drain output.
 
Last edited:

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…