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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/19/08 13:09
Read: times


 
#151121 - Real Time Clock and other
I am interfacing ds12c887, P89c60x2 in c language. the aim is to read time and send it serially to PC. With the program shown below i am getting the time displayed on the system hyper terminal. but WITHOUT UPDATE!. THE TIME IS NOT GETTING UPDATED. please tell me the mistakes in my program.
//-------------PROGRAM TO READ TIME AND SEND IT SERIALLY-------
#include<reg51.h>
#include<absacc.h>//to use XBYTE

unsigned char hr,min,sec;

void bcdconvert(unsigned char);
void serialsend(unsigned char);
void Delay(unsigned char);

void main(void){
Delay(200);

//55SEC 48 MIN 3 HR 15-02-08

XBYTE[10]=0X20;//TURN ON OSC

XBYTE[11]=0X83;//TURN OFF TIME UPDATE

XBYTE[0]=0X55;
XBYTE[2]=0X48;
XBYTE[4]=0X15;
XBYTE[7]=0X15;
XBYTE[8]=0X02;
XBYTE[9]=0X08;

XBYTE[11]=0X03;//start updating time

TMOD=0x20;
TH1=0xfd;
SCON=0x50;
TR1=1;

while(1){

hr=XBYTE[4];
bcdconvert(hr);
serialsend(':');

min=XBYTE[2];
bcdconvert(min);
serialsend(':');

sec=XBYTE[0];
bcdconvert(sec);

serialsend(0x0d); //CARRIAGE RETURN
serialsend(0x0a); //NEWLINE
}
}
//To covert bcd to hex code
void bcdconvert(unsigned char mybyte){
unsigned char x,y;
x=mybyte&0x0f;
x=x|0x30;
y=mybyte&0xf0;
y=y>>4;
y=y|0x30;
serialsend(y);
serialsend(x);
}
//send serially to pc
void serialsend(unsigned char x){
SBUF=x;
while(TI==0);
TI=0;
}
//osc takes 200ms to power on.
void Delay(unsigned char x){
unsigned char i,j;
for(i=0;i<x;i++)
for(j=0;j<1000;j++);
}
//-----------------------THANK YOU---------------------

List of 27 messages in thread
TopicAuthorDate
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      

Back to Subject List