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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/01/09 13:16
Read: times


 
#162970 - what you said is true. but there is another
Responding to: ???'s previous message
I too doubted it. but now it is confirmed..
but there is another problem too. as I have mentioned in the previous post, I have connected the LCD's DB0 to DB7 to Port 0.
when I included the LCD access in my RTC program i.e. to read the time and display it on LCD, I am unable to read RTC. it gives me no time display. all other parts of program are working fine. even the time is not being displayed at hyper terminal.
it is getting stuck at
while(OSC & 0x80);
I am sending you the program.
#include<reg51.h>
#include<absacc.h>
#define output P0
sbit EN=P2^6;
sbit RS=P3^7;
sbit RW=P3^6;

#define controlport P2
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);
void lcd_write(unsigned char);
void delay(void);

unsigned char second,hour,minute,i,j,k;
unsigned char s1[15]=" TLN's Trainer ";//all these three	 
unsigned char s2[15]="   is ready    ";//comes on LCD
unsigned char s3[15]="   HH:MM:SS    ";
void main(void)
{
	TMOD=0x20;//serial communication settings
	TH1=0xfd;
	SCON=0x50;
	TR1=1;

	delay();//give RTC a startup delay of 200ms
	delay();

	OSC=0X2f;//to turn on the oscillator
	
	//lcd initialisation

	//lcd function set 2 line, 8 bit 5x7
	RS=0;
	lcd_write(0x38);

	//lcd function set 2 line, 8 bit 5x7
	RS=0;
	lcd_write(0x38);
	//display on , cursor underline
	RS=0;
	lcd_write(0x0e);

	//charcter entry. increment, display shift
	RS=0;
	lcd_write(0x06);

	//clear lcd
	RS=0;
	lcd_write(0x02);

	//CURSOR HOME
	RS=0;
	lcd_write(0x01);
	//------------------------------------------

	while(1){
					   
	//set display address line1
	RS=0;
	lcd_write(0x80);
	//writing text "TLN's Tainer" 
	for(j=0;j<15;j++)
	{
		RS=1;
		lcd_write(s1[j]);
	}
	delay();			   	
	
	//set display address line 2
	RS=0;
	lcd_write(0xC0);
	//writing text 	"is ready"
	for(i=0;i<15;i++)
	{
		RS=1;
		lcd_write(s2[i]);
	}
	delay();
	
	//clear lcd
	RS=0;
	lcd_write(0x01);
	delay();

	//set display address line 1
	RS=0;
	lcd_write(0x80);
	//writing text "HH:MM;SS"
	for(k=0;k<16;k++)
	{
		RS=1;
		lcd_write(s3[k]);
	}
	//read RTC when uip is low.
	while( OSC & 0x80 );
		
		second=SEC;
		hour=HR;
		minute=MIN;

		//set display address line 2
		RS=0;
		lcd_write(0xc0);
		//writing time.....
		bcdconvert(hour);
		serialsend(':'); 
		RS=1;
		lcd_write(':');

		bcdconvert(minute);
		serialsend(':');
		RS=1;
		lcd_write(':');

		bcdconvert(second);
		serialsend(0x0d);
		serialsend(0x0a);				  
	}

}
void bcdconvert(unsigned mybyte){
	//Read RTC and convert to ASQII
	//send it to LCD and serial Port
	unsigned  char x,y;
	x=mybyte&0x0f;
	x=x|0x30;
	y=mybyte&0xf0;
	y=y>>4;
	y=y|0x30;
	serialsend(y);
	RS=1;
	lcd_write(y);
	serialsend(x);
	RS=1;
	lcd_write(x);
	}
void serialsend(unsigned x){
	SBUF=x;	
	while(TI==0);
	TI=0;
	}

//delay 250 milli secondss appx.
void delay()
{
unsigned char a3,b1;
for(a3=0;a3<200;a3++)
	for(b1=0;b1<200;b1++);
return;
}

//lcd_write
void lcd_write(unsigned char ch)
{
output=ch;
RW=0;
EN=1;
EN=0;
//wait_lcd
delay();
return;
}
 

apart from this the SQW output is also not comming.
I have even tried to read the TIME by stopping UPDATE, reading RTC and then enabling UPDATE.
UPDATE=0x8b;then reading RTC
UPDATE=0x0b;
and I am getting '?'s as output!

Please tell me if there is any wrong in my program.

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