Difference: RealTimeClock (1 vs. 6)

Revision 62022-12-06 - PeterSchmid

Line: 1 to 1
 
META TOPICPARENT name="WebHome"
%DASHBOARD{ section="banner"
Line: 7 to 7
  titlestyle="color:#F00000;" }%
Intro
Changed:
<
<
Most MCUs integrate a real time clock as peripheral. STM32 MCUs are no different. Many designs have its own 32.768 kHz quartz for precise timing, about 10 ppm without trimming.
>
>
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.
 
Contents

Revision 52022-12-04 - PeterSchmid

Line: 1 to 1
 
META TOPICPARENT name="WebHome"
Changed:
<
<

Real Time Clock

>
>
Real Time Clock
Intro
Most MCUs integrate a real time clock as peripheral. STM32 MCUs are no different. Many designs have its own 32.768 kHz quartz for precise timing, about 10 ppm without trimming.

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.


Changed:
<
<
time@ ( -- u ) Returns the unix time stamp. time! ( u -- ) Sets the real time clock. .time ( -- ) Prints the current date and time (YYYY-MM-DDTHH:MM:SS ISO 8601).
>
>
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) *

 
Changed:
<
<
date Prints date unix style Mon Jan 1 01:57:52 2000
>
>
date Print date unix style Mon Jan 1 01:57:52 2000
  wait-alarm ( -- ) Wait for an alarm
Changed:
<
<
alarm! (h m s -- ) Sets the alarm, invalid parameters e.g. -1 mask the parameter
>
>
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

 
Added:
>
>
 
Changed:
<
<

How to set the current date and time?

>
>

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/:

Line: 83 to 112
 0 Launch! ok.
Added:
>
>

  -- Peter Schmid - 2020-10-11

Revision 42022-06-18 - PeterSchmid

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Real Time Clock

Changed:
<
<
Epoch is 1.1.1970 (Unix time stamp). But valid dates are from 1.1.2000 to 31.12.2099 because of the STM32WB RTC peripheral.
>
>
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.
 
time@          (  -- u )      Returns the unix time stamp. 

Revision 32021-01-28 - PeterSchmid

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Real Time Clock

Line: 86 to 86
  -- Peter Schmid - 2020-10-11
Changed:
<
<

Comments

<--/commentPlugin-->
>
>
Creative Commons License
This work by Peter Schmid is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
 \ No newline at end of file

Revision 22020-12-24 - PeterSchmid

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Real Time Clock

Epoch is 1.1.1970 (Unix time stamp). But valid dates are from 1.1.2000 to 31.12.2099 because of the STM32WB RTC peripheral.


Changed:
<
<
time! ( -- u ) Returns the unix time stamp. time@ ( u -- ) Sets the real time clock.
>
>
time@ ( -- u ) Returns the unix time stamp. time! ( u -- ) Sets the real time clock.
 .time ( -- ) Prints the current date and time (YYYY-MM-DDTHH:MM:SS ISO 8601).
Changed:
<
<
date
>
>
date Prints date unix style Mon Jan 1 01:57:52 2000

wait-alarm ( -- ) Wait for an alarm alarm! (h m s -- ) Sets the alarm, invalid parameters e.g. -1 mask the parameter

 
Added:
>
>
 

How to set the current date and time?

Copy the current time stamp from a Unix machine (GNU/Linux box) or from https://www.unixtimestamp.com/:

Line: 29 to 33
 Sun Oct 11 15:36:02 2020
Added:
>
>

Set Alarms

Wake me at 06:00

6 0 0 alarm! wait-alarm .( Get Up!)[RET] Get Up! ok.

If you want an alarm every second:

-1 -1 -1 alarm![RET]  ok.

for every minute:

-1 -1 0 alarm![RET]  ok.

Stop the alarms:

0 0 0 alarm![RET]  ok.

: count-down ( -- )
 -1 -1 -1 alarm!  \ an alarm every second
  10 0 do
    cr 10 i - .
    wait-alarm  
  loop
  cr ." 0 Launch!"
;

count-down[RET]
10 
9 
8 
7 
6 
5 
4 
3 
2 
1 
0 Launch! ok. 
 -- Peter Schmid - 2020-10-11

Comments

Revision 12020-10-11 - PeterSchmid

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="WebHome"

Real Time Clock

Epoch is 1.1.1970 (Unix time stamp). But valid dates are from 1.1.2000 to 31.12.2099 because of the STM32WB RTC peripheral.

time!          (  -- u )      Returns the unix time stamp. 
time@          ( u --  )      Sets the real time clock.
.time          ( -- )         Prints the current date and time (YYYY-MM-DDTHH:MM:SS ISO 8601).

date

How to set the current date and time?

Copy the current time stamp from a Unix machine (GNU/Linux box) or from https://www.unixtimestamp.com/:

$ date +%s
1602430522

Paste the time stamp in the Mecrisp-Cube console:

 ok.
1602430522 time![RET]  ok.
.time[RET] 2020-10-11T15:35:27 ok.
date[RET] 
Sun Oct 11 15:36:02 2020

-- Peter Schmid - 2020-10-11

Comments

<--/commentPlugin-->
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 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