0

Teensy 4.0 RTC
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Teensy 4.0 RTC

by Remowylliams on Tue Apr 06, 2021 1:17 am

I've Googled the best I can, but my foo just can't save me tonight.
I've got a Teensy 4.0 board and since Micropython doesn't run on it, I figured I'd try Circuitpython.
Installing it was a snap. But it's what came after that has been my struggle.

I have vbat hooked up no troubles.
But I've tried all the Circuitpython code I can find to set the RTC in the chip so it keeps time when unplugged.
And so far can not find any specific module or class that deals with setting the rtc and reading from it.

Lots of code for Adafruit RTC products but nothing I can find for the noble Teensy 4.0

Please help me find a way to use Circuitpython for this or I have to abandon it.

Thanks

Remowylliams
 
Posts: 4
Joined: Tue Apr 06, 2021 1:10 am

Re: Teensy 4.0 RTC

by tannewt on Tue Apr 06, 2021 11:54 am

I'm not sure if it is implemented for the iMX RT yet. If it was, it'd be the `rtc` module: https://circuitpython.readthedocs.io/en ... C.datetime

tannewt
 
Posts: 2349
Joined: Thu Oct 06, 2016 8:48 pm

Re: Teensy 4.0 RTC

by Remowylliams on Tue Apr 06, 2021 1:01 pm

tannewt wrote:I'm not sure if it is implemented for the iMX RT yet. If it was, it'd be the `rtc` module: https://circuitpython.readthedocs.io/en ... C.datetime


Yes I'm using the rtc module. yes it sets an rtc somewhere but it never stores it in the rtc so when it recovers power it is not reading the datetime as expected

I've done further digging into the processor manual. the rtc is in the SNVS domain, Secure RTC or SRTC and it has a bunch of fun getting it to set it.
I've gone down the rabbit whole, and grabbed the source for circuitpython to dig this out....
I do not believe it is properly implemented at this time for this device. Which is to say my simple project likely can't use circuitpython

Thanks for the reply.

Remowylliams
 
Posts: 4
Joined: Tue Apr 06, 2021 1:10 am

Re: Teensy 4.0 RTC

by tannewt on Tue Apr 06, 2021 8:34 pm

I wouldn't expect it to keep time over a full power loss. You'd need a battery for that.

tannewt
 
Posts: 2349
Joined: Thu Oct 06, 2016 8:48 pm

Re: Teensy 4.0 RTC

by Remowylliams on Tue Apr 06, 2021 10:31 pm

tannewt wrote:I wouldn't expect it to keep time over a full power loss. You'd need a battery for that.


Interesting you would think I wouldn't have provided a vbat source before trying out the RTC keeping time after disconnecting from vcc.
Thanks again for your reply. But yes I know what I need to make it work if the software running it will actually work.
Else how could I validate the design?

Much appreciated. If you know of anyone who actually has a battery backed Teensy 4.0 without adding on something other than a battery and using Circuitpython, I would very much appreciate to hear from them.

Cheers

Remowylliams
 
Posts: 4
Joined: Tue Apr 06, 2021 1:10 am

Re: Teensy 4.0 RTC

by tannewt on Wed Apr 07, 2021 11:39 am

Ah, sorry about that. I was assuming that Teensy didn't break out the battery pin. My mistake.

No one has tested this (which I'm sure you realize.) I can try and point you to the relevant places in CircuitPython but don't expect us to get it going soon.

tannewt
 
Posts: 2349
Joined: Thu Oct 06, 2016 8:48 pm

Re: Teensy 4.0 RTC

by Remowylliams on Wed Apr 07, 2021 7:45 pm

Thanks. Yes the vbat pin is quite easy to find. Why no one has run into this before now is kind of interesting.
Being open source I can go through the code and see what might fix it, Which is what I've have spent several hours on
trying to dig it out. It's not as simple with this processor because much of the code in the SNVS is split between the HP (high power)
and LP (low power) processing states.

As it is I'm still wondering how it keeps time just setting time on it and keeping it powered. It does keep time well enough but I can't believe
people are so in love with setting the clock on their microwave when the device is ready to keep time for you. It provides 2 alarms
that would be very useful for operating it in low power sleep mode etc.

Much thanks for the conversation.

Remowylliams
 
Posts: 4
Joined: Tue Apr 06, 2021 1:10 am

Re: Teensy 4.0 RTC

by tannewt on Thu Apr 08, 2021 1:18 pm

No problem. If you have more questions about the core code, the discord is a good place to ask. https://adafru.it/discord Thanks!

tannewt
 
Posts: 2349
Joined: Thu Oct 06, 2016 8:48 pm

Please be positive and constructive with your questions and comments.