hi sir, i am new to this rtc ds1307 and want to know dat according to its datasheet it is battery backed....does that mean that you need not initialize it when you use it for the first time?????
and if i want to simulate it on proteus software it shows correct date and time automatically without writing it for the first time.....
i m unable to understand all this plzzz help me out....and i m sorry if i irritated you...
You don't show enough code.
One thing: You do
I2c_write(0x29);//hours
0x29 is obviously not any hours. Why do you use magic numbers like that? Why not make use of a constant saying HOURS_12H|HOURS_AM|9 or similar, to make it more obvious what the line does?
You use "word" a number of times. But you don't seem to mean it as a word in a sentence. And you don't seem to mean it as a word data type (which is normally the natural size of the accumulator for "larger" processors and normally a 16-bit number size for 8-bit processors).
If you have a function that prints a string until reaching a terminating zero '\0', then better call the parameter "str".
If you have a function that takes a numeric value, and the size is not important, then why not call it "num" or "val" or when the number has a specific meaning name the variable based on the meaning?
What is the meaning of:
delay(5); delay(5);
Doesn't delay(10) solve the problem? By the way - have you made sure that your busy-loop delays actually generate reasonable delays? Stupid busy-loop delays written in a high-level language is very dangerous since the compiler does not promise to produce any code that will actually generate the intended delay. In most situations, the compiler could optimize away the delay. And changes to compiler version or optimization levels can result in huge differences in speed.
If your BCD conversion results in '?' then your input byte was 0xff - so did you actually manage to read out any values from your 0x30 + 15 -> '?'. By the way: Why write 0x30 instead of '0'? Isn't it better that it is clearly visible that you want to add the offset for the ASCII representation of the digit zero?
See: www.8052.com/.../162556
"changes to compiler version or optimization levels can result in huge differences in speed"
Even without changing tool versions or optimisation settings, many things could still change the duration of your busy loop.
Even apparently unrelated source code changes could change the duration of your busy loop.
And, of course, the delay depends upon the clock frequency and whether the CPU has an "accelerated" core - have you checked these things?