6 \ ==============================================================================
7 \ routines RTC for MSP430fr5xxx and MSP430FR6xxx families only
8 \ your target must have a LF_XTAL 32768Hz
9 \ if no present, add a LF_XTAL line for your target in ThingsInFirst.inc.
10 \ ==============================================================================
12 \ to see kernel options, download FastForthSpecs.f
13 \ FastForth kernel options: MSP430ASSEMBLER, CONDCOMP
16 \ MSP_EXP430FR5739 MSP_EXP430FR5969 MSP_EXP430FR5994 MSP_EXP430FR6989
17 \ MSP_EXP430FR4133 CHIPSTICK_FR2433 MSP_EXP430FR2433 MSP_EXP430FR2355
20 \ R4 to R7 must be saved before use and restored after
21 \ scratch registers Y to S are free for use
22 \ under interrupt, IP is free for use
24 \ PUSHM order : PSP,TOS, IP, S, T, W, X, Y, rEXIT,rDOVAR,rDOCON, rDODOES, R3, SR,RSP, PC
25 \ PUSHM order : R15,R14,R13,R12,R11,R10, R9, R8, R7 , R6 , R5 , R4 , R3, R2, R1, R0
27 \ example : PUSHM #6,IP pushes IP,S,T,W,X,Y registers to return stack
29 \ POPM order : PC,RSP, SR, R3, rDODOES,rDOCON,rDOVAR,rEXIT, Y, X, W, T, S, IP,TOS,PSP
30 \ POPM order : R0, R1, R2, R3, R4 , R5 , R6 , R7 , R8, R9,R10,R11,R12,R13,R14,R15
32 \ example : POPM #6,IP pop Y,X,W,T,S,IP registers from return stack
35 \ FORTH conditionnals: unary{ 0= 0< 0> }, binary{ = < > U< }
37 \ ASSEMBLER conditionnal usage with IF UNTIL WHILE S< S>= U< U>= 0= 0<> 0>=
38 \ ASSEMBLER conditionnal usage with ?JMP ?GOTO S< S>= U< U>= 0= 0<> 0<
41 \ to set date, type : d m y DATE!
42 \ to view date, type DATE?
43 \ to set time, type : h m s TIME!, or h m TIME!
44 \ to view time, type TIME?
46 \ allow to write a file on a SD_Card with a valid date and a valid time
51 [DEFINED] {RTC} [IF] {RTC} [THEN] \ remove application
57 CODE MAX \ n1 n2 -- n3 signed maximum
64 CODE MIN \ n1 n2 -- n3 signed minimum
74 : U.R \ u n -- display u unsigned in n width (n >= 2)
76 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
127 MOV TOS,&RTCSEC \ seconds
128 MOV.B @PSP,&RTCMIN \ minutes \ @PSP+ don't work because byte format !
129 MOV.B 2(PSP),&RTCHOUR \ hours \ @PSP+ don't work because byte format !
139 \ create a word to test DEFERred words
140 : [DEFERRED] \ [DEFERRED] <name> -- flag
141 ' @ $4030 = \ CFA of <name> = MOV @PC+,PC ?
147 PWR_STATE \ after PWR_HERE, all will be lost
148 CR CR ." DATE (DMY): "
151 [IF] ['] ACCEPT >BODY EXECUTE \ execute default part of ACCEPT
154 EVALUATE CR 3 SPACES DATE!
155 CR CR ." TIME (HMS): "
158 [IF] ['] ACCEPT >BODY EXECUTE \ execute default part of ACCEPT
161 EVALUATE CR 3 SPACES TIME!