RTC issues with GR-Kaede

I am facing below issues with RTC time stamp, please suggest....

I am reading RTC time and date every second and printing to serial terminal.

Issue1 : "Second" is not getting rolled back to 0 after reaching >59, it continue to increment till 165, after 165 its rolled back to 0 and minute gets increment.

Issue2: when "second" reached to 15 after next second it should be 16 but it rolls back to 10 and start increment form 10.
This is happening not only at 15th second but also at 25,35,45,55.......till 155th second !!!!!!  (only at 5th second this is not happening)

please find output log and code below.

sketch/code -
#include <Arduino.h>
#include <Timer.h>
#include "HardwareSerial.h"
#include "RTC.h"

RTC_TIMETYPE t;

void time_stamp()
{
     rtc_get_time(&t);

     Serial.print(t.day);
     Serial.print('/');
     Serial.print(t.mon);
     Serial.print('/');
     Serial.print(t.year);

     Serial.print(' ');

     Serial.print(t.hour);
     Serial.print(':');
     Serial.print(t.min);
     Serial.print(':');
     Serial.print(t.second);

     Serial.println(' ');
}

void setup()
{
         Serial.begin(9600);
          rtc_init();
          t.year = 15;
          t.mon = 10;
          t.day = 23;
          t.weekday = RTC_WEEK_FRIDAY;
          t.hour = 18;
          t.min = 36;
          t.second = 0;
          rtc_set_time(&t);
}

void loop()
{
       static unsigned long currenttime, oldtime = 0;
       static unsigned long starttime = millis();

       currenttime = millis() - starttime;

       if ((currenttime - oldtime) >= 1000) //@1sec
       {
           time_stamp(); //print time stamp @1sec
           oldtime = currenttime;
       }
}

Output/Log-

23/10/15 18:36:0
23/10/15 18:36:1
23/10/15 18:36:2
23/10/15 18:36:3
23/10/15 18:36:4
23/10/15 18:36:5
23/10/15 18:36:6  <--- fine
23/10/15 18:36:7
23/10/15 18:36:8
23/10/15 18:36:9
23/10/15 18:36:10
23/10/15 18:36:11
23/10/15 18:36:12
23/10/15 18:36:13
23/10/15 18:36:14
23/10/15 18:36:15
23/10/15 18:36:10  <---- ?????
23/10/15 18:36:11
23/10/15 18:36:12
23/10/15 18:36:13
23/10/15 18:36:14
23/10/15 18:36:15
23/10/15 18:36:16
23/10/15 18:36:17
23/10/15 18:36:18
23/10/15 18:36:19
23/10/15 18:36:20
23/10/15 18:36:21
23/10/15 18:36:22
23/10/15 18:36:23
23/10/15 18:36:24
23/10/15 18:36:25
23/10/15 18:36:20  <--- ?????
23/10/15 18:36:21
23/10/15 18:36:22
23/10/15 18:36:23
23/10/15 18:36:24
23/10/15 18:36:25
23/10/15 18:36:26
23/10/15 18:36:27
23/10/15 18:36:28
23/10/15 18:36:29
23/10/15 18:36:30
23/10/15 18:36:31
23/10/15 18:36:32
23/10/15 18:36:33
23/10/15 18:36:34
23/10/15 18:36:35
23/10/15 18:36:30  <---?????
23/10/15 18:36:31
23/10/15 18:36:32
23/10/15 18:36:33
23/10/15 18:36:34
23/10/15 18:36:35
23/10/15 18:36:36
23/10/15 18:36:37
23/10/15 18:36:38
23/10/15 18:36:39
23/10/15 18:36:40
23/10/15 18:36:41
23/10/15 18:36:42
23/10/15 18:36:43
23/10/15 18:36:44
23/10/15 18:36:45
23/10/15 18:36:40
23/10/15 18:36:41
23/10/15 18:36:42
23/10/15 18:36:43
23/10/15 18:36:44
23/10/15 18:36:45
23/10/15 18:36:46
23/10/15 18:36:47
23/10/15 18:36:48
23/10/15 18:36:49
23/10/15 18:36:50
23/10/15 18:36:51
23/10/15 18:36:52
23/10/15 18:36:53
23/10/15 18:36:54
23/10/15 18:36:55
23/10/15 18:36:50
23/10/15 18:36:51
23/10/15 18:36:52
23/10/15 18:36:53
23/10/15 18:36:54
23/10/15 18:36:55
23/10/15 18:36:56
23/10/15 18:36:57
23/10/15 18:36:58
23/10/15 18:36:59
23/10/15 18:36:60  <----- ?????? it should be 0...!!!
23/10/15 18:36:61
23/10/15 18:36:62
23/10/15 18:36:63
23/10/15 18:36:64
23/10/15 18:36:65
23/10/15 18:36:60
23/10/15 18:36:61
23/10/15 18:36:62
23/10/15 18:36:63
23/10/15 18:36:64
....

....
23/10/15 18:36:159
23/10/15 18:36:160
23/10/15 18:36:161
23/10/15 18:36:162
23/10/15 18:36:163
23/10/15 18:36:164
23/10/15 18:36:165      <----- seconds is incrementing till 165
23/10/15 18:37:0            <------ here seconds rolls back to 0 and minute getting increment
23/10/15 18:37:1
23/10/15 18:37:2
23/10/15 18:37:3
23/10/15 18:37:4
23/10/15 18:37:5
23/10/15 18:37:6
23/10/15 18:37:7
23/10/15 18:37:8
23/10/15 18:37:9
23/10/15 18:37:10
23/10/15 18:37:11
23/10/15 18:37:12
23/10/15 18:37:13
23/10/15 18:37:14
23/10/15 18:37:15
23/10/15 18:37:10
23/10/15 18:37:11
23/10/15 18:37:12
23/10/15 18:37:13
23/10/15 18:37:14
23/10/15 18:37:15
23/10/15 18:37:16

  • I tried your code after remove "Timer.h" that doesn't included in Web compiler.

    As a result, I couldn't repeat your problem. What development environment did you use?

    23/10/15 18:36:0

    23/10/15 18:36:1

    23/10/15 18:36:2

    23/10/15 18:36:3

    23/10/15 18:36:4

    23/10/15 18:36:5

    23/10/15 18:36:6

    23/10/15 18:36:7

    23/10/15 18:36:8

    23/10/15 18:36:9

    23/10/15 18:36:10

    23/10/15 18:36:11

    23/10/15 18:36:12

    23/10/15 18:36:13

    23/10/15 18:36:14

    23/10/15 18:36:15

    23/10/15 18:36:16

    23/10/15 18:36:17

    23/10/15 18:36:18

    23/10/15 18:36:19

    23/10/15 18:36:20

    23/10/15 18:36:21

    23/10/15 18:36:22

    23/10/15 18:36:23

    23/10/15 18:36:24

    23/10/15 18:36:25

    23/10/15 18:36:26

    23/10/15 18:36:27

    23/10/15 18:36:28

    23/10/15 18:36:29

    23/10/15 18:36:30

    23/10/15 18:36:31

    23/10/15 18:36:32

    23/10/15 18:36:33

    23/10/15 18:36:34

    23/10/15 18:36:35

    23/10/15 18:36:36

    23/10/15 18:36:37

    23/10/15 18:36:38

    23/10/15 18:36:39

    23/10/15 18:36:40

    23/10/15 18:36:41

    23/10/15 18:36:42

    23/10/15 18:36:43

    23/10/15 18:36:44

    23/10/15 18:36:45

    23/10/15 18:36:46

    23/10/15 18:36:47

    23/10/15 18:36:48

    23/10/15 18:36:49

    23/10/15 18:36:50

    23/10/15 18:36:51

    23/10/15 18:36:52

    23/10/15 18:36:53

    23/10/15 18:36:54

    23/10/15 18:36:55

    23/10/15 18:36:56

    23/10/15 18:36:57

    23/10/15 18:36:58

    23/10/15 18:36:59

    23/10/15 18:37:0

    23/10/15 18:37:1

    23/10/15 18:37:2

    23/10/15 18:37:3

    23/10/15 18:37:4

    23/10/15 18:37:5

    23/10/15 18:37:6

    23/10/15 18:37:7

    23/10/15 18:37:8

    23/10/15 18:37:9

  • In reply to Okamiya Yuuki:

    Thanks Okamiya Yuuki for your reply.

    I am using E2studio, i have also tried in web compiler but result is same as previous.

  • In reply to Pratyush:

    Hi there,

    how to set time to RTC module and how to use it later in program?

    can you please explain step by step?

  • In reply to Krishnaraj V:

    Your code is no problem. Actually, your code operates with my GR-KAEDE.

    rtc_init(); // -> run sub-clock operation to RTC (remain stop count-up).

    rtc_set_time(&t); // -> set time and run RTC to count-up.

    Let me consider a little.