Forum Rule: Always post complete source code & details to reproduce any issue!
-
teensy RTC, how to get access on linktime during run time
Hello forum,
I have read the explanations of Paul regarding teensy RTC on thread https://forum.pjrc.com/threads/47988...?highlight=RTC and found this very usefull.
My question is, how can I get the time, witch will be stored (hack in ardiuno during build) in case teensy RTC has stale timestamp, during run time of my code?
Any ideas?
Background of the question is, I want to determine whether the RTC has been reset.
Thanks
-

Originally Posted by
larry_berlin
Hello forum,
I have read the explanations of Paul regarding teensy RTC on thread
https://forum.pjrc.com/threads/47988...?highlight=RTC and found this very usefull.
My question is, how can I get the time, witch will be stored (hack in ardiuno during build) in case teensy RTC has stale timestamp, during run time of my code?
Any ideas?
Background of the question is, I want to determine whether the RTC has been reset.
Thanks
Had just to do it
Code:
uint32_t t0=rtc_get();
uint32_t t1=(uint32_t)&__rtc_localtime;
if((t1-t0)>100) rtc_set(t1);
this piece of code updates the clock if the RTC clock is at least 100 sec behind compile time.
to see if RTC is set at all see L1111 of mk20dx128.c in cores/teens3
-

Originally Posted by
WMXZ
Had just to do it
Code:
uint32_t t0=rtc_get();
uint32_t t1=(uint32_t)&__rtc_localtime;
if((t1-t0)>100) rtc_set(t1);
this piece of code updates the clock if the RTC clock is at least 100 sec behind compile time.
to see if RTC is set at all see L1111 of mk20dx128.c in cores/teens3
Thank you very much. I didn''t know where to look in the core files.
I had just to add globaly "extern void *__rtc_localtime;" to my sketch to avoid compiler error.
Unfortunatly my external circuit draws to much current to maintain RTC for 20 or 30 seconds (when changing battery).
Nevertheless something learned.
-

Originally Posted by
larry_berlin
I had just to add globaly "extern void *__rtc_localtime;" to my sketch to avoid compiler error.
that's correct, sorry for reduced cut/paste
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules