Tags:
create new tag
view all tags
%DASHBOARD{ section="dashboard_start" }% %DASHBOARD{ section="banner" image="%PUBURLPATH%/Cosmac/ForthSTM32WB/nucleo-header.jpg" title="Real Time Clock" titlestyle="color:#F00000;" }% %DASHBOARD{ section="box_start" title="Intro" width="485" height="150"}% Most MCUs integrate a real time clock as peripheral. STM32 MCUs are no different. Many designs have their own 32.768 kHz quartz for precise timing, about 10 ppm without trimming. %DASHBOARD{ section="box_end" }% %DASHBOARD{ section="box_start" title="Contents" width="460" height="150"}% %TOC% %DASHBOARD{ section="box_end" }% %DASHBOARD{ section="box_start" width="992" height="500" }% ---+ RTC Words Epoch is 1.1.1970 (Unix time stamp). But valid dates are from 1.1.2000 to 31.12.2099 because of the !STM32 RTC peripheral. <pre> time@ ( -- u ) Return the unix time stamp. time! ( u -- ) Set the real time clock. .time ( -- ) Print the current date and time (YYYY-MM-DDTHH:MM:SS ISO 8601). clktime ( -- u ) hour*10000 + minute*100 + second clkdate ( -- u ) Year*10000 + Month*100 + Day time&date ( -- n1 n2 n3 n4 n5 n6 ) Return the current time and date. n1 second {0...59}, n2 minute {0...59}, n3 hour {0...23}, n4 day {1...31} n5 month {1...12}, n6 year (e.g. 1991) * date Print date unix style <em>Mon Jan 1 01:57:52 2000</em> wait-alarm ( -- ) Wait for an alarm alarm! (h m s -- ) Set the alarm, invalid parameters e.g. -1 mask the parameter ms ( u -- ) Wait at least u millisecond (osDelay) * *) part of ansification.fs </pre> %DASHBOARD{ section="box_end" }% %DASHBOARD{ section="box_start" width="992" height="800" }% ---+ How to Use ---++ Set the current date and time Copy the current time stamp from a Unix machine (GNU/Linux box) or from https://www.unixtimestamp.com/: <pre> $ <b>date +%s</b> 1602430522 </pre> Paste the time stamp in the Mecrisp-Cube console: <pre> ok. <b>1602430522 time![RET]</b> ok. <b>.time[RET]</b> 2020-10-11T15:35:27 ok. <b>date[RET]</b> Sun Oct 11 15:36:02 2020 </pre> ---++ Set Alarms Wake me at 06:00 <pre> <b>6 0 0 alarm! wait-alarm .( Get Up!)[RET]</b> Get Up! ok. </pre> If you want an alarm every second: <pre> <b>-1 -1 -1 alarm![RET]</b> ok. </pre> for every minute: <pre> <b>-1 -1 0 alarm![RET]</b> ok. </pre> Stop the alarms: <pre> <b>0 0 0 alarm![RET]</b> ok. </pre> <pre> : count-down ( -- ) -1 -1 -1 alarm! \ an alarm every second 10 0 do cr 10 i - . wait-alarm loop cr ." 0 Launch!" ; </pre> <pre> <b>count-down[RET]</b> 10 9 8 7 6 5 4 3 2 1 0 Launch! ok. </pre> %DASHBOARD{ section="box_end" }% %DASHBOARD{ section="dashboard_end" }% -- %USERSIG{PeterSchmid - 2020-10-11}% <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" /></a><br />This work by <a xmlns:cc="http://creativecommons.org/ns#" href="http://spyr.ch" property="cc:attributionName" rel="cc:attributionURL">Peter Schmid</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>.
E
dit
|
A
ttach
|
Watch
|
P
rint version
|
H
istory
: r6
<
r5
<
r4
<
r3
<
r2
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r6 - 2022-12-06
-
PeterSchmid
Home
Site map
Cosmac web
MRR web
MecrispCube web
SuperRandonnee web
TWiki web
Ursula web
Velo web
MecrispCube Web
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
View
Raw View
Print version
Find backlinks
History
More topic actions
Edit
Raw edit
Attach file or image
Edit topic preference settings
Set new parent
More topic actions
Account
Log In
E
dit
A
ttach
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback