Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/28/09 17:56
Read: times


 
#162953 - with the help of Xbyte or XDATA
Responding to: ???'s previous message
I am accessing the RTC as an external memory. I am sending you a modified program which too worked but with the same problem (able to access RTC even when !cs==1)

//interfacing ds12c887 real time clock using p89c61x2bn
/*pin out connections of the rtc with the micro controller.
micro controller <--> rtc
-------------------------
P0<---->ad0-ad7
!cs<---P2.5
ALE(pin 30)---->AS
!RD(pin16)----->Data strobe
!WR(pin17)----->R/W
--------------------------
other rtc connections;
MOT,--->GND; intel bus timimg is selected.
RST-->Vcc; rest all i have left as no connection(SQW and IRQ).

note: the other micro controller pins such as 
!PSEN , RST, XLAT0, XLAT1 and the max232 connections 
are made accordingly. and i am pretty sure about them*/
//program
#include<reg51.h>
#include<absacc.h>
volatile char xdata OSC _at_ 0x800a;//register a
volatile char xdata UPDATE _at_ 0x800b;//register b
volatile char xdata SEC _at_ 0x8000;
volatile char xdata HR _at_ 0x8004;
volatile char xdata MIN _at_ 0x8002;
volatile char xdata DD _at_ 0x8007;
volatile char xdata MM _at_ 0x8008;
volatile char xdata YY _at_ 0x8009;
sbit rtcce=P2^5;
#define output P0
void bcdconvert(unsigned x);
void serialsend(unsigned x);
void Delay(unsigned int);
unsigned char second,hour,minute;
void main(void)
{
	TMOD=0x20;//serial communication settings
	TH1=0xfd;
	SCON=0x50;
	TR1=1;
	Delay(200);
	rtcce=1;

	OSC=0X2f;//to turn on the oscillator
        //RTC is already initialised & time is set.
	while(1){
	rtcce=0;//here comes the problem whether it  
	//is high or low. 
        //the micro controller can read RTC.
	
        while( OSC & 0x80 );//to monitor uip
	   	second=SEC;
		hour=HR;
		minute=MIN;

		bcdconvert(hour);
		serialsend(':');
		bcdconvert(minute);
		serialsend(':');
		bcdconvert(second);
		serialsend(0x0d);
		serialsend(0x0a);
						  
	}
}
void bcdconvert(unsigned mybyte){
	unsigned  char x,y;
	x=mybyte&0x0f;
	x=x|0x30;
	y=mybyte&0xf0;
	y=y>>4;
	y=y|0x30;
	serialsend(y);
	serialsend(x);
	}
void serialsend(unsigned x){
	SBUF=x;	
	while(TI==0);
	TI=0;
	}
void Delay(unsigned int itime){
	unsigned int i,j,k;
	for(i=0;i<=itime;i++)
		for(j=0;j<=0xff;j++)
			for(k=0;k<=0x08;k++);
	}

//end of program

 

if there is no wrong with the connections and if there is another way of reading RTC. Please suggest me.
thanks you.

List of 20 messages in thread
TopicAuthorDate
RTC DS12c887 Chip select            01/01/70 00:00      
   WHY ON EARTH            01/01/70 00:00      
      with the help of Xbyte or XDATA            01/01/70 00:00      
         Speaking the Truth.......            01/01/70 00:00      
            I don't see            01/01/70 00:00      
               what you said is true. but there is another            01/01/70 00:00      
         Even with !CS == 1 ??            01/01/70 00:00      
            I have done that before posting this thread!            01/01/70 00:00      
               How fast multimeter            01/01/70 00:00      
                  actually..            01/01/70 00:00      
   I just saw it            01/01/70 00:00      
      then I am in real trouble            01/01/70 00:00      
         replace the XBYTE with ...            01/01/70 00:00      
            sorry but...            01/01/70 00:00      
               or            01/01/70 00:00      
         Play with the ports            01/01/70 00:00      
            thank god            01/01/70 00:00      
   sorry I could not reply due to my ill health            01/01/70 00:00      
      it is            01/01/70 00:00      
         and Erik one last..            01/01/70 00:00      

Back to Subject List