| ??? 03/04/08 13:30 Read: times |
#151868 - perfect!! Responding to: ???'s previous message |
i have got it
thanks a lot!!! thanks to Stefan Kanev, Andy Neil and all others who advised me in this thread i am sending the modified and final program that got executed perfectly.
//interfacing ds12c887 real time clock using p89c61x2bn
/*pin out connections of the rtc with the micro controller.
micro controller <--> rtc
-------------------------
P0<---->ad0-ad7
ALE(pin 30)---->AS
!RD(pin16)----->Data strobe
;no other connections are made to the !RD pins
!WR(pin17)----->R/W
;no other connections are made to the !WR pins
--------------------------
other rtc connections;
MOT,CS,--->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;
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);
OSC=0X2f;//to turn on the oscillator
UPDATE=0X8b;//to stop update
SEC=0X01; //set time
MIN=0X01;
HR=0X01;
DD=0X01; //21-02-08
MM=0X01;
YY=0X08;
UPDATE=0X0b;//start update
while(1){
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
i have even modified the above code to generate square wave output and it worked brilliantly. thanks to 8052 forum. You can close this thread now. |
| Topic | Author | Date |
| Real Time Clock and other | 01/01/70 00:00 | |
| How to post source code | 01/01/70 00:00 | |
| post- source code | 01/01/70 00:00 | |
| internal XRAM? | 01/01/70 00:00 | |
| its not logical but | 01/01/70 00:00 | |
| modified code using UIF | 01/01/70 00:00 | |
| re | 01/01/70 00:00 | |
| UIP | 01/01/70 00:00 | |
| Will get stuck | 01/01/70 00:00 | |
| If you used _at_ instead of XBYTE .... | 01/01/70 00:00 | |
| Comments | 01/01/70 00:00 | |
| reply to coments | 01/01/70 00:00 | |
| _at_ instead of XBYTE | 01/01/70 00:00 | |
| pin assignments | 01/01/70 00:00 | |
| You still haven't answered the questions! | 01/01/70 00:00 | |
| xdata i/o | 01/01/70 00:00 | |
| just do it | 01/01/70 00:00 | |
| Default | 01/01/70 00:00 | |
| sorry i can't reply due to my ill health | 01/01/70 00:00 | |
| address | 01/01/70 00:00 | |
| perfect!! | 01/01/70 00:00 | |
| try to understand | 01/01/70 00:00 | |
yes i finally got the point | 01/01/70 00:00 | |
| Aside: Not a macro | 01/01/70 00:00 | |
| Delay? | 01/01/70 00:00 | |
| agree | 01/01/70 00:00 | |
| Keil know | 01/01/70 00:00 |



