Hi, The interface DS12887 to MCU(I use 89c52) is all right.But I can't programe it with C51.My application is very simple.I just want to initiate and read the RTC.What can I do? Many thanks for any help!
Hi,Rajesh Thanks for your help! Yesterday,I initialized and read the RTC with the following two functions,and they worked: #include "absacc.h" #define Rtc_a XBYTE[0xff0a] ... sbit Rtc_CS=P1^1; unsigned char xdata *px; unsigned char Buf[128]; void Init(void) { Rtc_CS=0; Rtc_b=0x82; Rtc_a=0xa0; //2002/9/17 13:30:30 BCD mode Rtc_0=0x30; Rtc_1=0xff; Rtc_2=0x30; Rtc_3=0xff; Rtc_4=0x13; Rtc_5=0xff; Rtc_6=0x03; Rtc_7=0x17; Rtc_8=0x09; Rtc_9=0x02; Rtc_a=0x20; Rtc_b=0x02; Rtc_CS=1; } void read(void) { unsigned char i; Rtc_CS=0; px=0xff00; for(i=0;i<128;i++) Buf[i]=*px++; Rtc_CS=1; } But,I found a big question this morning.In order to testify that the RTC can run in the absence of Power,I powered off it when I was off duty yesterday.However,the date and time were still 2002/9/17 17:53:30,as I just used the read() fuc to read it this morning(about at 09:30:00 2002/9/18/).What's happened?The date should be 2002/9/18!I need ur help! regards, vidarson.
Hi Vidarson, Sorry, I could not reply immediately as the internet here is down.The problem is obvious. Inorder for the RTC (internal)oscillator to run the Register A bits DV2,DV1 andDV0 should be made as 010.That should solve ur problem. Let me know if u have any problems. All the best with ur work. Regards, Rajesh
Hi Rajesh, It works!When I return my lab this Monday,I'm so happy that it works very well.Perhaps,the Moon Festival in my country,china, gives me a big luck.However,I didn't change any codes in my program at all.I just commented the 'init' func in the main procedure,and the RTC can run freely in the absence of the power.So,I can draw a conclusion that, 1.If the bits DV2,DV1,DV0 in the register A is set to 010,as u say,the internal oscillator could be turned on.When powered off,the internal lithium battery will work and the oscillator will not stop.& 2.Writing the Set bit in the Register B to a 1 stops the update tranfer.I just made the fault,forgetting to clear the Set bit. I dont's know whether there is any problem in the future.But,I think I can solve it with ur help. Many thanks for ur help! All the best with ur work too. regards, vidarson
Hi, Can I have ur mail id?Just to be in touch....thats all. Bye Rajesh.
Hi,Of course you can.It's my pleasure to be in touch u.My Email is:vidarson@jjeg.com.cn And,Could you tell me urs?Just keep in touch! Regards, vidarson
Hi Vidarson, My mail id is rajesht@cmcltd.com By the way, Howz ur work going on? Rgds, Rajesh