5 \ ==============================================================================
6 \ routines RTC for MSP430fr5xxx and MSP430FR6xxx families only
7 \ your target must have a LF_XTAL 32768Hz
8 \ add a LF_XTAL line for your target in target.inc.
9 \ ==============================================================================
12 \ TARGET SELECTION (MSP430FR5xxx or MSP430FR6xxx only)
13 \ MSP_EXP430FR5739 MSP_EXP430FR5969 MSP_EXP430FR5994 MSP_EXP430FR6989
14 \ MY_MSP430FR5738_1 MY_MSP430FR5738 MY_MSP430FR5948 MY_MSP430FR5948_1
19 \ R4 to R7 must be saved before use and restored after
20 \ scratch registers Y to S are free for use
21 \ under interrupt, IP is free for use
23 \ PUSHM order : PSP,TOS, IP, S, T, W, X, Y, R7, R6, R5, R4
24 \ example : PUSHM IP,Y
26 \ POPM order : R4, R5, R6, R7, Y, X, W, T, S, IP,TOS,PSP
29 \ ASSEMBLER conditionnal usage after IF UNTIL WHILE : S< S>= U< U>= 0= 0<> 0>=
30 \ ASSEMBLER conditionnal usage before GOTO ?GOTO : S< S>= U< U>= 0= 0<> <0
32 \ FORTH conditionnal usage after IF UNTIL WHILE : 0= 0< = < > U<
37 \ to set date, type : d m y DATE!
38 \ to view date, type DATE?
39 \ to set time, type : h m s TIME!, or h m TIME!
40 \ to view time, type TIME?
42 \ allow to write a file on a SD_Card with a valid date and a valid time
47 [DEFINED] {RTC} [IF] {RTC} [THEN] \ remove application
49 [DEFINED] ASM [IF] \ security test
55 CODE MAX \ n1 n2 -- n3 signed maximum
62 CODE MIN \ n1 n2 -- n3 signed minimum
73 : U.R \ u n -- display u unsigned in n width (n >= 2)
75 R> OVER - 0 MAX SPACES TYPE
84 BIT.B #RTCRDY,&RTCCTL1 \ test RTCRDY flag
85 0<> UNTIL \ wait until RTCRDY high
86 MOV &RTCYEARL,2(PSP) \ year
88 MOV TOS,0(PSP) \ month
89 MOV.B &RTCDAY,TOS \ day
98 MOV TOS,&RTCYEARL \ year
99 MOV.B @PSP,&RTCMON \ month \ @PSP+ don't work because byte format !
100 MOV.B 2(PSP),&RTCDAY \ day \ @PSP+ don't work because byte format !
110 MOV TOS,4(PSP) \ save TOS
112 BIT.B #RTCRDY,&RTCCTL1 \
113 0<> UNTIL \ wait until RTCRDY high
115 MOV TOS,2(PSP) \ seconds
117 MOV TOS,0(PSP) \ minutes
118 MOV.B &RTCHOUR,TOS \ hours
126 DEPTH 2 = IF 0 THEN \ to allow "hour min TIME!" scheme
128 MOV TOS,&RTCSEC \ seconds
129 MOV.B @PSP,&RTCMIN \ minutes \ @PSP+ don't work because byte format !
130 MOV.B 2(PSP),&RTCHOUR \ hours \ @PSP+ don't work because byte format !
142 CR CR ." DATE (DMY): "
143 [DEFINED] LOAD" [IF] \ ACCEPT is a dEFERed word and redirected to SD_ACCEPT!
144 ABUF ABUF 20 (ACCEPT) EVALUATE CR 3 SPACES DATE!
145 CR CR ." TIME (HMS or HM): "
146 ABUF ABUF 20 (ACCEPT) EVALUATE CR 3 SPACES TIME!
147 [ELSE] \ ACCEPT is not a DEFERed word
148 ABUF ABUF 20 ACCEPT EVALUATE CR 3 SPACES DATE!
149 CR CR ." TIME (HMS or HM): "
150 ABUF ABUF 20 ACCEPT EVALUATE CR 3 SPACES TIME!
154 MOV #PSTACK,PSP \ to avoid stack empty error if lack of typed values.