| View previous topic :: View next topic |
| Author |
Message |
Guest
|
|
Posted: Mon Jan 03, 2005 10:11 am |
|
|
Any code availabe?
Thanks |
|
 |
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Jan 03, 2005 10:12 am |
|
|
| How are you sending the data from the PC? |
|
 |
Guest
|
|
Posted: Mon Jan 03, 2005 10:16 am |
|
|
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
|
|
Posted: Mon Jan 03, 2005 10:33 am |
|
|
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
|
| wrong reading from ds1307 |
Posted: Mon Aug 15, 2005 8:03 pm |
|
|
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
|
|
Posted: Mon Aug 15, 2005 8:34 pm |
|
|
| Are the lines pulled up to 5V with a resistor? |
|
 |
noisepic
Joined: 24 Jul 2005 Posts: 20
|
|
Posted: Mon Aug 15, 2005 10:39 pm |
|
|
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
|
|
Posted: Wed Aug 17, 2005 4:28 am |
|
|
I'm looking for your reply. Anybody help me to find errors in hardware or program(the way for debug)? wrong reading time.
 |
|
 |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Aug 17, 2005 5:59 am |
|
|
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
|
|
Posted: Wed Aug 17, 2005 8:57 am |
|
|
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
|
|
Posted: Wed Aug 17, 2005 10:09 am |
|
|
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 |
|
 |
|