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 - no days shown

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



Joined: 09 Mar 2013
Posts: 20

View user's profile Send private message

DS1307 - no days shown
PostPosted: Wed Jan 01, 2014 6:17 pm     Reply with quote

Hello!
I use this DS1307 driver
http://www.ccsinfo.com/forum/viewtopic.php?t=23255
Code:
////////////////////////////////////////////////////////////////////////////////
///                               DS1307.C                                   ///
///                     Driver for Real Time Clock                           ///
///                                                                          ///
/// ds1307_init() - Enable oscillator without clearing the seconds register -///
///                 used when PIC loses power and DS1307 run from 3V BAT     ///
///               - Disable squarewave output                                ///
///                                                                          ///
/// ds1307_set_date_time(day,mth,year,dow,hour,min,sec)  Set the date/time   ///
///                                                                          ///
/// ds1307_get_date(day,mth,year,dow)               Get the date             ///
///                                                                          ///
/// ds1307_get_time(hr,min,sec)                     Get the time             ///
///                                                                          ///
////////////////////////////////////////////////////////////////////////////////

#define RTC_SDA  PIN_C4
#define RTC_SCL  PIN_C3

#use i2c(master, sda=RTC_SDA, scl=RTC_SCL)

BYTE bin2bcd(BYTE binary_value);
BYTE bcd2bin(BYTE bcd_value);

void ds1307_init(void)
{
   BYTE seconds = 0;

   i2c_start();
   i2c_write(0xD0);      // WR to RTC
   i2c_write(0x00);      // REG 0
   i2c_start();
   i2c_write(0xD1);      // RD from RTC
   seconds = bcd2bin(i2c_read(0)); // Read current "seconds" in DS1307
   i2c_stop();
   seconds &= 0x7F;

   delay_us(3);

   i2c_start();
   i2c_write(0xD0);      // WR to RTC
   i2c_write(0x00);      // REG 0
   i2c_write(bin2bcd(seconds));     // Start oscillator with current "seconds value
   i2c_start();
   i2c_write(0xD0);      // WR to RTC
   i2c_write(0x07);      // Control Register
   i2c_write(0x80);     // Disable squarewave output pin
   i2c_stop();

}

void ds1307_set_date_time(BYTE day, BYTE mth, BYTE year, BYTE dow, BYTE hr, BYTE min, BYTE sec)
{
  sec &= 0x7F;
  hr &= 0x3F;

  i2c_start();
  i2c_write(0xD0);            // I2C write address
  i2c_write(0x00);            // Start at REG 0 - Seconds
  i2c_write(bin2bcd(sec));      // REG 0
  i2c_write(bin2bcd(min));      // REG 1
  i2c_write(bin2bcd(hr));      // REG 2
  i2c_write(bin2bcd(dow));      // REG 3
  i2c_write(bin2bcd(day));      // REG 4
  i2c_write(bin2bcd(mth));      // REG 5
  i2c_write(bin2bcd(year));      // REG 6
  i2c_write(0x80);            // REG 7 - Disable squarewave output pin
  i2c_stop();
}

void ds1307_get_date(BYTE &day, BYTE &mth, BYTE &year, BYTE &dow)
{
  i2c_start();
  i2c_write(0xD0);
  i2c_write(0x03);            // Start at REG 3 - Day of week
  i2c_start();
  i2c_write(0xD1);
  dow  = bcd2bin(i2c_read() & 0x7f);   // REG 3
  day  = bcd2bin(i2c_read() & 0x3f);   // REG 4
  mth  = bcd2bin(i2c_read() & 0x1f);   // REG 5
  year = bcd2bin(i2c_read(0));            // REG 6
  i2c_stop();
}

void ds1307_get_time(BYTE &hr, BYTE &min, BYTE &sec)
{
  i2c_start();
  i2c_write(0xD0);
  i2c_write(0x00);            // Start at REG 0 - Seconds
  i2c_start();
  i2c_write(0xD1);
  sec = bcd2bin(i2c_read() & 0x7f);
  min = bcd2bin(i2c_read() & 0x7f);
  hr  = bcd2bin(i2c_read(0) & 0x3f);
  i2c_stop();

}

BYTE bin2bcd(BYTE binary_value)
{
  BYTE temp;
  BYTE retval;

  temp = binary_value;
  retval = 0;

  while(TRUE)
  {
    // Get the tens digit by doing multiple subtraction
    // of 10 from the binary value.
    if(temp >= 10)
    {
      temp -= 10;
      retval += 0x10;
    }
    else // Get the ones digit by adding the remainder.
    {
      retval += temp;
      break;
    }
  }

  return(retval);
}


// Input range - 00 to 99.
BYTE bcd2bin(BYTE bcd_value)
{
  BYTE temp;

  temp = bcd_value;
  // Shifting upper digit right by 1 is same as multiplying by 8.
  temp >>= 1;
  // Isolate the bits for the upper digit.
  temp &= 0x78;

  // Now return: (Tens * 8) + (Tens * 2) + Ones

  return(temp + (temp >> 2) + (bcd_value & 0x0f));
}

When I start PIC first time, it works normal. But if I turn off and then turn on, I have no days on clock. Time goes from battery, but there is no days. It shows 00.
I use this code:
before while(TRUE)
Code:
if(read_eeprom(0) != 1) {
      ds1307_set_date_time(9,9,13,1,22,42,00);
      write_eeprom(0, 1);
  }

And Then
Code:
while(TRUE)
  {
    delay_ms(1000);
   
    ds1307_get_date(day,month,yr,dow);
    ds1307_get_time(hrs,min,sec);
   
    //fprintf(PC,"\f\%02d:\%02d:\%02d\r\n",hrs,min,sec);
    fprintf(PC,"\f\%02d:\%02d:\%02d-",hrs,min,sec);
    fprintf(PC,"\%02d/\%02d/\%02d",day,month,yr);
  }
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jan 02, 2014 12:56 am     Reply with quote

Post your complete test program that calls the ds1307 driver functions.
I.e., post the #include line for the PIC, #fuses, #use delay, etc. Post your variable declarations. In other words, post the complete program.

Post the output that you see on the terminal window. Copy and paste it
into your reply post.

Post your CCS compiler version.

Post other details like your battery voltage. Also post if you built the
ds1307 board by yourself, or if you bought a factory-built board. If so,
post the manufacturer and model number of the board.
pavelustinov



Joined: 09 Mar 2013
Posts: 20

View user's profile Send private message

PostPosted: Thu Jan 02, 2014 1:55 am     Reply with quote

PCM programmer wrote:
Post your complete test program that calls the ds1307 driver functions.
I.e., post the #include line for the PIC, #fuses, #use delay, etc. Post your variable declarations. In other words, post the complete program.

Post the output that you see on the terminal window. Copy and paste it
into your reply post.

Post your CCS compiler version.

Post other details like your battery voltage. Also post if you built the
ds1307 board by yourself, or if you bought a factory-built board. If so,
post the manufacturer and model number of the board.


Code:
#include <16F877a.h>
#device adc=8
#fuses NOWDT, XT, NOPROTECT, NOBROWNOUT, PUT, NODEBUG, NOLVP, NOWRT, NOCPD
#use delay(clock=4000000, RESTART_WDT)
#use rs232(baud=9600, parity=N, xmit=PIN_C6, rcv=PIN_C7, bits=8, stream=PC, errors)

#include <ds1307.c>

void main()
{
  BYTE sec;
  BYTE min;
  BYTE hrs;
  BYTE day;
  BYTE month;
  BYTE yr;
  BYTE dow;
 
  ds1307_init();
 
  if(read_eeprom(0) != 1) {
      ds1307_set_date_time(9,9,13,1,22,42,00);
      write_eeprom(0, 1);
  }
 
  while(TRUE)
  {
    delay_ms(1000);
   
    ds1307_get_date(day,month,yr,dow);
    ds1307_get_time(hrs,min,sec);
   
    fprintf(PC,"\f\%02d:\%02d:\%02d-",hrs,min,sec);
    fprintf(PC,"\%02d/\%02d/\%02d",day,month,yr);
  }
}

On my terminal window I see:
First start (when ds1307_set_date_time() calls)
22:42:00-09/09/13
ALL OK.
But when I turn off and then turn on my board (battery works) I see
22:43:00-00/09/13
Day must to be 09, but these is 00
CCS compiler version is 4.084
I use battery 3V and 3.6V, 2 different factory-built DS1307 boards,
Board like this http://thumbs1.ebaystatic.com/d/l225/m/meK88KqzDJos7rnQHtkkE8A.jpg
Ttelmah



Joined: 11 Mar 2010
Posts: 19550

View user's profile Send private message

PostPosted: Thu Jan 02, 2014 5:33 am     Reply with quote

Try using force_hw on the I2C, and see if anything changes.

Also explicitly set the I2C clock rate to 'SLOW' (the chip only supports this). With your CPU clock it is unlikely that there is a speed problem, but worth ruling out.

Then 3.6v, is too high for the battery. The battery voltage must be less than Vmain/1.284 for reliable switching. With 3.6v as a battery, and the possibility that this is only 'nominal', so could easily be higher, the unit may not actually turn 'on' properly. This is why the specification has Vbat (max) at 3.5v. Stick with the 3v battery and check that it is giving 3v.

4.084, is a rather early V4 compiler (V4, didn't really start working till the mid to later 4.07x versions), so there might well be problems here. It might be worth changing the driver to use pointers, rather than reference parameters, which did have a few problems around this time.

Best Wishes
pavelustinov



Joined: 09 Mar 2013
Posts: 20

View user's profile Send private message

PostPosted: Thu Jan 02, 2014 4:41 pm     Reply with quote

Ttelmah wrote:
Try using force_hw on the I2C, and see if anything changes.

Also explicitly set the I2C clock rate to 'SLOW' (the chip only supports this). With your CPU clock it is unlikely that there is a speed problem, but worth ruling out.

Then 3.6v, is too high for the battery. The battery voltage must be less than Vmain/1.284 for reliable switching. With 3.6v as a battery, and the possibility that this is only 'nominal', so could easily be higher, the unit may not actually turn 'on' properly. This is why the specification has Vbat (max) at 3.5v. Stick with the 3v battery and check that it is giving 3v.

4.084, is a rather early V4 compiler (V4, didn't really start working till the mid to later 4.07x versions), so there might well be problems here. It might be worth changing the driver to use pointers, rather than reference parameters, which did have a few problems around this time.

Best Wishes


I added
Code:
#use i2c(master,slow,i2c1,force_hw)

after #use rs232, nothing works at all,
on my Terminal Window I get 45:85:85-45/25/-1
Maybe, I was wrong?
I use board this 3V battery
Try to 4.130 version of the Compiler, result the same - no days.
temtronic



Joined: 01 Jul 2010
Posts: 9245
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Jan 02, 2014 4:56 pm     Reply with quote

comment: on my Terminal Window I get 45:85:85-45/25/-1
45:85:85 looks familiar! Have you got the proper I2C bus pullup resistors? With 5 Volts I use 4k7, in fact have a 46k22 using ds1307 in front of me,running.
Also you MUST have a battery ( coin cell) attached to the DS1307..or it will not run....pin 3 is the Vbat pin. The datasheet says that...
Also, for test purposes it's a good idea to 'preset' the date/time info to unique numbers . IE day = 5 month = 9, year=14, never the same number for 2 variables.It'll help with debugging.

Please post your complete program but not the DS1307 driver, we may then see why adding use rs232(....) stops the program.

hth
jay
pavelustinov



Joined: 09 Mar 2013
Posts: 20

View user's profile Send private message

PostPosted: Thu Jan 02, 2014 5:14 pm     Reply with quote

temtronic wrote:
comment: on my Terminal Window I get 45:85:85-45/25/-1
45:85:85 looks familiar! Have you got the proper I2C bus pullup resistors? With 5 Volts I use 4k7, in fact have a 46k22 using ds1307 in front of me,running.
Also you MUST have a battery ( coin cell) attached to the DS1307..or it will not run....pin 3 is the Vbat pin. The datasheet says that...
Also, for test purposes it's a good idea to 'preset' the date/time info to unique numbers . IE day = 5 month = 9, year=14, never the same number for 2 variables.It'll help with debugging.

Please post your complete program but not the DS1307 driver, we may then see why adding use rs232(....) stops the program.

hth
jay

Code:
#include <16F877a.h>
#device adc=8
#fuses NOWDT, XT, NOPROTECT, NOBROWNOUT, PUT, NODEBUG, NOLVP, NOWRT, NOCPD
#use delay(clock=4000000, RESTART_WDT)
#use rs232(baud=9600, parity=N, xmit=PIN_C6, rcv=PIN_C7, bits=8, stream=PC, errors)

#include <ds1307.c>
//#include <flex_lcd.c>

void main()
{
  BYTE sec;
  BYTE min;
  BYTE hrs;
  BYTE day;
  BYTE month;
  BYTE yr;
  BYTE dow;
 
  ds1307_init();
 
  if(read_eeprom(0) != 1) {
      ds1307_set_date_time(9,9,13,1,22,42,00);
      write_eeprom(0, 1);
  }
 
  while(TRUE)
  {
    output_toggle(PIN_D0);
    delay_ms(1000);
   
    ds1307_get_date(day,month,yr,dow);
    ds1307_get_time(hrs,min,sec);
   
    fprintf(PC,"\f\%02d:\%02d:\%02d-",hrs,min,sec);
    fprintf(PC,"\%02d/\%02d/\%02d",day,month,yr);
  }
}

This program works.
On my terminal window I see:
First start (when ds1307_set_date_time() calls)
22:42:00-09/09/13
ALL OK.
But when I turn off and then turn on my board (battery works) I see
22:43:00-00/09/13
Day must to be 09, but these is 00
I use factory-built board, it has pullup resistors. I tried on 2 different boards - result the same, no days.
temtronic



Joined: 01 Jul 2010
Posts: 9245
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Jan 02, 2014 8:09 pm     Reply with quote

comment: Well I'm at a loss to explain why you've lost the day data. I'm even using your fprintf to the PC to view the data on Realterm and it's 100% right, even after yanking off the power for 10 minutes, power up and it's 100% right data.
My coin cell battery measures 3.000 volts, 15 year old white breadboard with 22ga solid copper interconnect wire, USB<>TTL module supplies power and communication to PC. PICkit3 attached to ICSP all the time. Using a PIC18F46K22 with 4 MHz xtal, 22puff caps, 2x16 LCD. Nothing special and kinda messy wiring too.
Only suggestion I have is to remark out the eeprom code, reboot and see what happens. It's the only code you have, that I don't have.
Curious about your time display. You've always shown :00. Odds are you'ld have something other than :00 .

Please report back with what happens...the more info we get, maybe we can narrow down what's going wrong.

hth
jay
pavelustinov



Joined: 09 Mar 2013
Posts: 20

View user's profile Send private message

PostPosted: Thu Jan 02, 2014 9:12 pm     Reply with quote

temtronic wrote:
comment: Well I'm at a loss to explain why you've lost the day data. I'm even using your fprintf to the PC to view the data on Realterm and it's 100% right, even after yanking off the power for 10 minutes, power up and it's 100% right data.
My coin cell battery measures 3.000 volts, 15 year old white breadboard with 22ga solid copper interconnect wire, USB<>TTL module supplies power and communication to PC. PICkit3 attached to ICSP all the time. Using a PIC18F46K22 with 4 MHz xtal, 22puff caps, 2x16 LCD. Nothing special and kinda messy wiring too.
Only suggestion I have is to remark out the eeprom code, reboot and see what happens. It's the only code you have, that I don't have.
Curious about your time display. You've always shown :00. Odds are you'ld have something other than :00 .

Please report back with what happens...the more info we get, maybe we can narrow down what's going wrong.

hth
jay

I've added button like this
Code:
while(TRUE)
  {
    output_toggle(PIN_D0);
    delay_ms(1000);
   
    if(input(PIN_B1)) {
         // button pressed
         ds1307_set_date_time(14,9,13,1,22,42,00);
         delay_ms(1000);
    }
   
    ds1307_get_date(day,month,yr,dow);
    ds1307_get_time(hrs,min,sec);
   
    fprintf(PC,"\f\%02d:\%02d:\%02d-",hrs,min,sec);
    fprintf(PC,"\%02d/\%02d/\%02d",day,month,yr);
  }

When button pressed, function ds1307_set_date_time() calls.
First start I see normal date and time, turn off, turn on - I see day = 00,
BUT then I push the button, ds1307_set_date_time() calls and I see normal date and time again.
I think, there are 2 reasons: error in ds1307_get_date() function or in ds1307_set_date_time().

Code:
void ds1307_set_date_time(BYTE day, BYTE mth, BYTE year, BYTE dow, BYTE hr, BYTE min, BYTE sec)
{
  sec &= 0x7F;
  hr &= 0x3F;

  i2c_start();
  i2c_write(0xD0);            // I2C write address
  i2c_write(0x00);            // Start at REG 0 - Seconds
  i2c_write(bin2bcd(sec));      // REG 0
  i2c_write(bin2bcd(min));      // REG 1
  i2c_write(bin2bcd(hr));      // REG 2
  i2c_write(bin2bcd(dow));      // REG 3
  i2c_write(bin2bcd(day));      // REG 4
  i2c_write(bin2bcd(mth));      // REG 5
  i2c_write(bin2bcd(year));      // REG 6
  i2c_write(0x80);            // REG 7 - Disable squarewave output pin
  i2c_stop();
}

void ds1307_get_date(BYTE &day, BYTE &mth, BYTE &year, BYTE &dow)
{
  i2c_start();
  i2c_write(0xD0);
  i2c_write(0x03);            // Start at REG 3 - Day of week
  i2c_start();
  i2c_write(0xD1);
  dow  = bcd2bin(i2c_read() & 0x7f);   // REG 3
  day  = bcd2bin(i2c_read() & 0x3f);   // REG 4
  mth  = bcd2bin(i2c_read() & 0x1f);   // REG 5
  year = bcd2bin(i2c_read(0));            // REG 6
  i2c_stop();
}
temtronic



Joined: 01 Jul 2010
Posts: 9245
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Jan 02, 2014 10:00 pm     Reply with quote

comment: Well I checked your drivers vs mine and they are the same except for the order of the variables.
I chose to do this...
void ds1307_get_date_time(BYTE &yer, BYTE &mth, BYTE &day, BYTE &dow, BYTE &hrs, BYTE &min, BYTE &sec)

since I think of time in that order, saves me a lot of confusion.

one test you might try.
hard code the date and time variables,compile,burn,and let the PIC set the date and time based on them,be sure battery is connected.
Power down.
Now edit program to NOT set date/time,compile,burn and powerup PIC.
The PIC should grab the RTC date/time info and send to PC.

I'm thinking the problem is not the RTC or the PIC but might be switch bounce on the input.If the driver was at fault, I'd have seen it in the past 2-3 years, or others would.It's odd that ONLY the day data is being corrupted.If timing was off, it should affect other data registers.
I know it's frustrating! Try to eliminate more code if possible.

!!!!!!

new test...

Please remove the restart_WDT from the clock (options).
I just re-read your earlier code and I never use it.
Something else you can try.


hth
jay
pavelustinov



Joined: 09 Mar 2013
Posts: 20

View user's profile Send private message

PostPosted: Thu Jan 02, 2014 10:43 pm     Reply with quote

temtronic wrote:
comment: Well I checked your drivers vs mine and they are the same except for the order of the variables.
I chose to do this...
void ds1307_get_date_time(BYTE &yer, BYTE &mth, BYTE &day, BYTE &dow, BYTE &hrs, BYTE &min, BYTE &sec)

since I think of time in that order, saves me a lot of confusion.

one test you might try.
hard code the date and time variables,compile,burn,and let the PIC set the date and time based on them,be sure battery is connected.
Power down.
Now edit program to NOT set date/time,compile,burn and powerup PIC.
The PIC should grab the RTC date/time info and send to PC.

I'm thinking the problem is not the RTC or the PIC but might be switch bounce on the input.If the driver was at fault, I'd have seen it in the past 2-3 years, or others would.It's odd that ONLY the day data is being corrupted.If timing was off, it should affect other data registers.
I know it's frustrating! Try to eliminate more code if possible.

!!!!!!

new test...

Please remove the restart_WDT from the clock (options).
I just re-read your earlier code and I never use it.
Something else you can try.


hth
jay

First of all I run on PIC this program
Code:
#include <16F877a.h>
#device adc=8
#fuses NOWDT, XT, NOPROTECT, NOBROWNOUT, PUT, NODEBUG, NOLVP, NOWRT, NOCPD
#use delay(clock=4000000)
#use rs232(baud=9600, parity=N, xmit=PIN_C6, rcv=PIN_C7, bits=8, stream=PC, errors)

#include <ds1307.c>

void main()
{
  ds1307_init();
  delay_ms(1000);
 
  while(TRUE) {
      ds1307_set_date_time(14,9,13,1,22,42,00);
      delay_ms(1000);
      output_toggle(PIN_D0);
  }
}

This program set date and time.
Then I've burned this program
Code:
#include <16F877a.h>
#device adc=8
#fuses NOWDT, XT, NOPROTECT, NOBROWNOUT, PUT, NODEBUG, NOLVP, NOWRT, NOCPD
#use delay(clock=4000000)
#use rs232(baud=9600, parity=N, xmit=PIN_C6, rcv=PIN_C7, bits=8, stream=PC, errors)

#include <ds1307.c>

void main()
{
  BYTE sec;
  BYTE min;
  BYTE hrs;
  BYTE day;
  BYTE month;
  BYTE yr;
  BYTE dow;
 
  ds1307_init();
  delay_ms(1000);
 
  while(TRUE)
  {
    output_toggle(PIN_D0);
    delay_ms(1000);
   
    ds1307_get_date(day,month,yr,dow);
    ds1307_get_time(hrs,min,sec);
   
    fprintf(PC,"\f\%02d:\%02d:\%02d-",hrs,min,sec);
    fprintf(PC,"\%02d/\%02d/\%02d",day,month,yr);
  }
}

This program only reads data from DS1307.
And there is NO day on my Terminal Window.
Ttelmah



Joined: 11 Mar 2010
Posts: 19550

View user's profile Send private message

PostPosted: Fri Jan 03, 2014 3:02 am     Reply with quote

There seem to be rather a lot of known issues with these modules....

<http://forum.arduino.cc/index.php?topic=177297.0>

I found similar threads in half a dozen other forums for different processors.

There are some oddities in the schematic, which does not follow the Maxim recommendations in a couple of areas.

Strong suspicion is that the actual chip may be a 'clone', not the genuine Maxim part, with some odd issues.

Best Wishes
temtronic



Joined: 01 Jul 2010
Posts: 9245
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Jan 03, 2014 7:07 am     Reply with quote

comment: I think Mr. T is onto the real problem since we've eliminated the PIC and the code, only thing left is the actual RTC module.I've always used real Maxim DS1307 chips.Had a quick read of the 'link' Mr. T. supplied. yeesh, my setup is a 15 year old breadboard, rtc xtal not grounded and it keep great time.Coin cell is in a holder with wire jumpers to gnd and pin 3.Not neat and tidy like a pro PCB but it works reliably.
Only suggestion I have is to follow M. T. and 'google' that module and read what others using it have found out.
comment:Hard to believe anyone can make real money 'cloning' an RTC chip!

You may find out it needs 'special' timing or non standard 'access' to get it use it.I see in the picture there's a 2nd chip setup on the board,maybe (?) it's affecxting the RTC ?

sorry but I'm kinda out of ideas for now.
please keep us informed though.

hth
jay
temtronic



Joined: 01 Jul 2010
Posts: 9245
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Jan 03, 2014 7:39 am     Reply with quote

comment: Like a dog with a bone, I'm back.Think I've found the OEM of the module. http://www.emartee.com/product/42059/ appears to be it.I've downloaded the schematic and pictures.It does show a real Dallas chip,well looks real to my old eyes.I also now see that the other chip is an Atmel memory device.
comment:I'm not 'happy' about the R5-R4 on the Vbat line and would remove them and the R5-D1 as well. A coin cell should last 10 years powering the RTC so the 'recharge' circuit isn't needed.I've never needed the voltage divider,just a coin cell battery direct.The 680K from xtal to +3 might be needed depending on the xtal,but I've never needed that either.
If you've got a very steady hand and good eyesight,I'd remove those components on one of your pcbs then test again.

comment:also check out the address of the mem. device.Maybe it's in conflict but I doubt it...check with the atmel datasheet,confirm that the a2,a1,a0 pins ARE grounded.If one is 'floating' it might make the mem chip address conflict with the RTC chip address.

comment: edit your program to reduce I2C speed to say 50 KHz.Maybe your compiler version is coding for hi-speed( >100KHz)? Again, I'm grabbing at straws, as all the other registers are fine.A speed problem should affect more than just ONE register!

comment: for test purposes, hardcode(preset) the date/time info to be near midnight in order to let the RTC update after 'midnight'.

again, please keep us informed !!

hth
jay
pavelustinov



Joined: 09 Mar 2013
Posts: 20

View user's profile Send private message

PostPosted: Fri Jan 03, 2014 8:33 am     Reply with quote

temtronic wrote:
comment: Like a dog with a bone, I'm back.Think I've found the OEM of the module. http://www.emartee.com/product/42059/ appears to be it.I've downloaded the schematic and pictures.It does show a real Dallas chip,well looks real to my old eyes.I also now see that the other chip is an Atmel memory device.
comment:I'm not 'happy' about the R5-R4 on the Vbat line and would remove them and the R5-D1 as well. A coin cell should last 10 years powering the RTC so the 'recharge' circuit isn't needed.I've never needed the voltage divider,just a coin cell battery direct.The 680K from xtal to +3 might be needed depending on the xtal,but I've never needed that either.
If you've got a very steady hand and good eyesight,I'd remove those components on one of your pcbs then test again.

comment: for test purposes, hardcode(preset) the date/time info to be near midnight in order to let the RTC update after 'midnight'.

again, please keep us informed !!

hth
jay

Thanks for all!!!
This DS1307 "works" through midnight, day doesn't update.
I will do the experiments. I will modify one of my boards or I will make scheme on solderless board.
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