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.

I"m trying to read RTC using pic16f176a , but getting only 00 on lcd display

Status
Not open for further replies.

kushal nandanwar

Full Member level 3
Joined
Jun 9, 2013
Messages
177
Helped
6
Reputation
12
Reaction score
6
Trophy points
18
Activity points
1,258
i2c_init();
i2c_start();

i2c_send(0xa0);
i2c_send(0x00);
i2c_send(5);
i2c_stop();
__delay_ms(100);
i2c_start();
i2c_send(0xa0);
i2c_send(0x00);
i2c_restart();
i2c_send(0xa1);
sec = i2c_read();
i2c_stop();


void i2c_init()
{
TRISC3 = 1;
TRISC4 = 1;
SSPSTAT |= 0x80; //Slew Rate Disabled
SSPADD = 0x28;

SSPCON=0x28; //Master mode


}


void i2c_start(void)
{
SEN = 1;

while (SEN == 1)
continue;

}
 

Hi,

you think we all here waiting for your riddle?

But the answer is easy: You simply don´t output any data to a LCDisplay. So how can it change?

* Undocumented code
* only a snippet
* no info about RTC hardware
* no definiton of variables


Klaus
 

PIC16f876A and RTC1307


void i2c_restart(void)
{
RSEN = 1;

while (RSEN == 1)
continue;

}

void i2c_stop(void)
{
PEN=1;
while(PEN==1)
continue;
}

void i2c_wait(void)
{
while( RW == 1)
continue;
if(ACKSTAT == 1)
{
i2c_stop();
}

}

void i2c_send(unsigned char dat)
{
SSPBUF = dat;
while(BF);
i2c_wait();
}

unsigned char i2c_read(void)
{
unsigned char temp;
RCEN = 1;
while(BF == 0)
continue;
temp = SSPBUF;
i2c_wait();
ACKDT=1;
ACKEN=1;
while(ACKEN == 1)
continue;
i2c_stop();
return temp;
}


unsigned char rtc1307_read(unsigned char address)
{
unsigned char temp;
i2c_start();
i2c_send(0xD0);
i2c_send(address);
i2c_restart();
i2c_send(0xD1);
temp = i2c_read();

return temp;
}
 

Use CODE tags or SYNTAX tags to post the code. It is better if you post the full code.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top