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 Real Time Clock question
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








PostPosted: Mon Jan 03, 2005 10:11 am     Reply with quote

Any code availabe?

Thanks
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Mon Jan 03, 2005 10:12 am     Reply with quote

How are you sending the data from the PC?
Guest








PostPosted: Mon Jan 03, 2005 10:16 am     Reply with quote

by uart serial port c6=tx and c7=rx
using keyboard to set the date & time.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Mon Jan 03, 2005 10:33 am     Reply with quote

Here are some snippets that will give you some ideas.

Here is a sscanf() function
http://www.ccsinfo.com/forum/viewtopic.php?t=20225&highlight=sscanf

buffer contains the time like say "13:45:12"
Code:


  int8 hour = 0;
  int8 minute = 0;
  int8 second = 0;
  int8 count = 0;

  if (isdigit(buffer[0]))
  {
    count = sscanf(pArgs, "%b:%b:%b", &hour, &minute, &second);
    if (count >= 2)
    {
      SetTime(hour, minute, second))
    }
  }

  return;
}



Code:

gca_ds1307_regs[DS1307_SECONDS_REG] = second;
gca_ds1307_regs[DS1307_MINUTES_REG] = minute;
gca_ds1307_regs[DS1307_HOURS_REG] = hour;


The same thing could be done for the date as well. You could do something like

"Enter the hours"
"Enter the minutes"
"Enter the seconds"

and use the gets() function to get the data and then convert that into a number using the atoi() function.
noisepic



Joined: 24 Jul 2005
Posts: 20

View user's profile Send private message

wrong reading from ds1307
PostPosted: Mon Aug 15, 2005 8:03 pm     Reply with quote

hi Tullos!
I have used your code. I only display hour:minutes:seconds but they always 45:85:85
I check 3V battery- lithium--> OK
Check square wave out put--> OK

I used 16F84A, and PIN_B5 as SDA, PIN_B6 as SCL.
and in my display routine i use PORTB?
what's wrong?
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Mon Aug 15, 2005 8:34 pm     Reply with quote

Are the lines pulled up to 5V with a resistor?
noisepic



Joined: 24 Jul 2005
Posts: 20

View user's profile Send private message

PostPosted: Mon Aug 15, 2005 10:39 pm     Reply with quote

there is 1k pull up resitor to 5V , each pin SDA and SCL?
this project can work with 16F84?
noisepic



Joined: 24 Jul 2005
Posts: 20

View user's profile Send private message

PostPosted: Wed Aug 17, 2005 4:28 am     Reply with quote

I'm looking for your reply. Anybody help me to find errors in hardware or program(the way for debug)? wrong reading time.
Sad
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Wed Aug 17, 2005 5:59 am     Reply with quote

The time you read is equal to that of the first post in this thread, the problem there was a hardware problem. Please double check your battery connection (between ground and Vbat).

Quote:
there is 1k pull up resitor to 5V , each pin SDA and SCL?
With the question mark '?' I'm not sure this is an answer or a question?
Yes, you need a pull-up on both SDA and SCL.

Quote:
Check square wave out put--> OK
Can you tell us how you tested this? Can you make the DS1307 to output a 1Hz signal on this output? (change DS1307_CONTROL_REG_INIT_VALUE from 0x80 to 0x10).
noisepic



Joined: 24 Jul 2005
Posts: 20

View user's profile Send private message

PostPosted: Wed Aug 17, 2005 8:57 am     Reply with quote

thanks ckielstra for your reply

I have measured PIN3 and GND by voltmeter. It's 3V
I wire both 1k pull up resitor on SDA and SCL PIN

Quote:
Can you tell us how you tested this? Can you make the DS1307 to output a 1Hz signal on this output?

I connect a Led on PIN 7 of DS1307 to GND. I see it flash (dim, not strong).
Quote:
Can you tell us how you tested this? Can you make the DS1307 to output a 1Hz signal on this output?

I have done it.

I double that i use PIN_B5 and PIN_B6 for SDA and SCL . I use PIN_B0,PIN_B1,PIN_B2,PIN_B3 for displaying on 7 segment led.
for ex PORTB=0x34.
In display routine i configure TRISB=0x00; // output
Ttelmah
Guest







PostPosted: Wed Aug 17, 2005 10:09 am     Reply with quote

What is the voltage on pin8?.
The internal RAM is 'locked out', until this reaches _nominally_ Vbat*1.25. I had some problems with the device, when using a rechargeable lithium, that some examples were just not switching to allow the access, till the supply went over 1.3* Vbat.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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