View previous topic :: View next topic |
Author |
Message |
hadeelqasaimeh
Joined: 05 Jan 2006 Posts: 105
|
DS1307 again |
Posted: Fri Nov 02, 2007 6:18 pm |
|
|
hi
i want to print rtc on lcd
i use the driver on this web page:
http://www.sixca.com/micro/pic/ds1307/
this is my code:
Code: |
#include<16f877A.h> //Device initialization
#fuses NOWDT, XT, NOPROTECT //Fusues
#use delay (clock=4000000) //Operating Frequency is 4.0MHz
#include <ds1307.C> //DS1307 RTC including
#include "lcd_d.c"
int main()
{
int8 min,hr,key,sec;
init_DS1307();
LCD_Init();
while (1) {
hr = read_DS1307(2); //Read the current hour
min = read_DS1307(1); //Read the current minute
LCD_PutCmd ( CLEAR_DISP );
LCD_SetPosition ( LINE_16_1);
printf(LCD_PutChar,"Time : %02X:%02X\r\n",hr,min);
delay_ms(500);
}//main
}
|
i try to simulate it using proteus and its work perfect
but in real its not work,
it print "Time :FF:FF" alllllll the time
i check my hardware and its fine
help please |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Nov 02, 2007 10:53 pm |
|
|
1. Put 4.7K pull-up resistors on the SDA and SCL pins.
2. Put a 3v lithium battery on the Vbat pin.
3. Put a 32.768 KHz watch crystal on the X1 and X2 pins. |
|
|
hadeelqasaimeh
Joined: 05 Jan 2006 Posts: 105
|
|
Posted: Sat Nov 03, 2007 5:17 am |
|
|
hi PCM programmer
i check the points you stated in your reply and its all right
still have the problem |
|
|
Ttelmah Guest
|
|
Posted: Sat Nov 03, 2007 6:06 am |
|
|
What is the actual supply voltage, and the voltage on the battery pin?.
The DS1307, inhibits reading/writing, if the supply is below 1.25*Vbatt. If the battery is giving (say) 3.6v, then unless Vcc is above 4.5v, the chip will not respond. This used to be a common problem, when running these chips, with three cell NiCd rechargeable batteries.
Best Wishes |
|
|
hadeelqasaimeh
Joined: 05 Jan 2006 Posts: 105
|
|
Posted: Sun Nov 04, 2007 11:16 am |
|
|
hi
i make sure from all previous point ,nothing wrong!
however i will try to send rtc data to pc serial and use hyperterminal
any idea?
thank you |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sun Nov 04, 2007 12:52 pm |
|
|
Your initialization code is not complete. By default the DS1307 oscillator is disabled to conserve energy, your program has to enable it. See the example code that is supplied with the library.
Code: | init_ds1307(); // initial DS1307
sec=read_ds1307(0);
write_ds1307(0,sec & 0x7F); // enable oscillator(bit 7 =0) |
|
|
|
|