CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

DS1307 again

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
hadeelqasaimeh



Joined: 05 Jan 2006
Posts: 105

View user's profile Send private message

DS1307 again
PostPosted: Fri Nov 02, 2007 6:18 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Nov 02, 2007 10:53 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Nov 03, 2007 5:17 am     Reply with quote

hi PCM programmer
i check the points you stated in your reply and its all right
still have the problem
Ttelmah
Guest







PostPosted: Sat Nov 03, 2007 6:06 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Nov 04, 2007 11:16 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Nov 04, 2007 12:52 pm     Reply with quote

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)
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group