Teensy 3.2 + RTC question. keep time when off?

Status
Not open for further replies.

skidd

Member
I have a question about the built in RTC feature of the Teensy 3.2.
Is it supposed to maintain the time when not powered up?
I soldered in a 32.768 crystal, and attached a 2025 battery to vbat and gnd.
I'm using the same initial setup for the RTC that is floating around in here.


Code:
   setSyncProvider(getTeensy3Time);
    if (timeStatus() != timeSet)
    {
        Serial.println("ERR: Unable to sync with RTC");
    }
    else
    {
        Serial.println("RTC Has set the system time");
    }

I have a remote and an IR receiver that I use to set the time with.
On each button press, I increment the clock by 10 seconds (+-).

Code:
time_t tNow = now();
tNow += TIME_INCREASE_SECONDS * (_buttonRepeatCount > TIME_MULTIPLIER_REPEAT_THRESHOLD ? TIME_INCREASE_MULTIPLIER : 1);
Teensy3Clock.set(tNow);
setTime(tNow);

Watching the serial output, I have a simple serial out in the loop() to see the time change.
Code:
Serial.print(hour()); Serial.print(':'); Serial.print(minute()); Serial.print(':'); Serial.print(second());

Here is where I'm not sure what I'm supposed to expect.
When I set the time with the remote, it changes the output time to the serial.
When I unplug the USB to the teensy (the only power I was using).. wait about 10 seconds or so.. and plug it back in.
The time picks up exactly where it left off. Not the 10 seconds additional that I waited.

What should have happened? should it have kept proper time? Or just restored the "powered down" time?
See bellow for a snippet of the serial output. I ran the sketch, unplugged the usb, waited 10 seconds, and plugged it back in.

Code:
16:13:43
16:13:43
16:13:44
16:13:44
16:13:45
16:13:45

--- exit ---
Exception in thread rx:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/spowell/.local/lib/python2.7/site-packages/serial/tools/miniterm.py", line 445, in reader
    data = self.serial.read(self.serial.in_waiting or 1)
  File "/home/spowell/.local/lib/python2.7/site-packages/serial/serialposix.py", line 501, in read
    'device reports readiness to read but returned no data '
SerialException: device reports readiness to read but returned no data (device disconnected or multiple access on port?)

 $ pio device monitor
--- Miniterm on /dev/ttyACM0  250000,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
Setup RTC Has set the system time
16:13:45
16:13:45
16:13:46
16:13:46
16:13:47


If it's supposed to keep time when unplugged.. where should I look for the problem?
Is it the crystal? bad solder job (dang that thing is tiny to solder).

P.S. As expected, if I remove the 2025 battery, and do the same as above, the "clock" get reset to the compile time. So.. I know at least that the batter must be doing something right.

*edit* I put my voltage tester to see if the pins of the crystal are correctly linked to the pins on the teensy, and they both seem to map out correctly. Shows a good connection on them both to the pins on the CPU itself.

Cheers
 
Last edited:
The Time Library and RTC are two separate things.

// This sets the system time in Time Library (NOT the Teensy RTC Clock)
setTime(tNow); //
setTime(time, minute(), second(), day(), month(), year()); // seting the Time Library only here.

// This sets the RTC Clock from System Time Library - epoch stylee, just like it wants :)
Teensy3Clock.set(now());

EDIT: oops nevermind, looks like you do have Teensy3Clock.set(); in code.
 
Update.. found the answer.
I wasn't really keen on de-soldering the crystal to try another... but.. what ever.. had to find out if that was the cause.
Sure enough it was. The new crystal soldered in, and she keeps time with the USB unplugged. just as I expected it was supposed to.
 
Status
Not open for further replies.
Back
Top