Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Error in a code which reads RTC and displays on LCD

Status
Not open for further replies.

shanishp

Newbie level 6
Joined
Sep 11, 2007
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,422
hi
my project includes an RTC and LCD. I had read the rtc by i2c protocol and tries to out in an lcd. but iam getting some error
my output is
TIME : 1? : 2? :3?
a question mark is there when i tried to mask my received data from rtc with 0f .e some problems regarding the LSB (4 bits) of received data.
please help me.

the rtc is outing the data in BCD format, shall i need to convert it back into bcd by pic microcontroller


my routine to read the rtc is given below

void read_DS1307(void)
{
i2c_start();
i2c_write(0xd0);
i2c_write(0x00);
i2c_start();
i2c_write(0xd1);

data=i2c_read(1); // * reading seconds
sec=data;
disp[16]=48+((data & 0x70)>>4);
disp[17]=48+(data & 0x0F);
disp[15]=' ';

data=i2c_read(1); // * reading minutes
min=data;
disp[13]=48+((data & 0x70)>>4);
disp[14]=48+(data & 0x0F);
disp[12]=' ';

data=i2c_read(1); // * reading hour
hr=data;
disp[10]=48+((data & 0x30)>>4);
disp[11]=48+(data & 0x0F);
disp[9]=' ';

data=i2c_read(1); // * reading date
dt=data;
disp[7]=48+((data & 0x30)>>4);
disp[8]=48+(data & 0x0F);
disp[6]=' ';

data=i2c_read(1); // * reading month
mnt=data;
disp[4]=48+((data & 0x10)>>4);
disp[5]=48+(data & 0x0F);
disp[3]=' ';

data=i2c_read(0); // * reading year
yr=data;
disp[1]=48+((data & 0xF0)>>4);
disp[2]=48+(data & 0x0F);
disp[0]=' ';

i2c_stop();

}
 

Re: RTC and LCD

Confirm that the RTC sends the time out as BCD?
 

Re: RTC and LCD

use bcdtostr() functio in mikroc
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top