4.1 RTC, what's the paradigm here

tomicdesu

Active member
I need to use the RTC standalone, eg. no external sync source. It will be set manually, YMD/HMS. Example TimeTeensy3 works fine, but does not reveal much. Pretty much all the threads about the RTC involve synchronization with some external source.

I take it the RTC is a set of functions internal to the ARM chip. There's reference to DS1307, but I don't see one in the schematic, the library TimeLib.h, buried deep in the hardware folders, is pretty obscure.

Is there any docs for how to poke time into the RTC "chip"? Does it only accept millisec since some epoch (1/1/2013)? I can do that, but it's ugly in this application.
 
The example sketch TimeTeensy3 has information that should be what you are looking for. Note that the current time also gets sent by your PC to the Teensy every time you download your code.

Mark J Culross
KD5RXT
 
You don't need TimeLib at all. The applicable code is here in the core: https://github.com/PaulStoffregen/cores/blob/master/teensy4/rtc.c

The SNVS_LP* registers refer to the low-power block; that's the module that is kept running by the battery. The SNVS_HP* registers are the high power module, powered by the regular power supply; as part of the default startup function the low power RTC counters are copied into the high power RTC counters and then those are accessed whenever the time is read.
 
Ahh! Thanks @jmarsh! So the internal RTC is just a long int of ticks. That's what I needed to know. OK nice and simple. Except for the time and date math, lol.
 
Back
Top