| ??? 02/19/08 18:51 Read: times |
#151161 - modified code using UIF Responding to: ???'s previous message |
hi stefan,
i have modified the code with adding the UIF monitoring. but still it the output is same. i ams ending u the updated code. the code is verified under keil compiler.
//program to set,read time and send it serially
#include<reg51.h>
#include<absacc.h>//to use XBYTE
unsigned char hr,min,sec,UIP;
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){
UIP=XBYTE[10];// update in progress, UIP IS A VARIABLE DECLARED AS CHAR
UIP=UIP&0X80; // TO GET UIP BIT
while(UIP); // AS LONG AS UIP IS HIGH THERE IS NO READING OF TIME
//WHEN UIP IS LOW USER HAS 244uSEC....BEFORE THE NEXT UPDATE
hr=XBYTE[4];
min=XBYTE[2];
sec=XBYTE[0];
bcdconvert(hr);
serialsend(':');
bcdconvert(min);
serialsend(':');
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++);
}
i shall be back in 12hrs............... |
| 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 |



