OSDN Git Service

Merge framagit.org:Jean-Mi/FAST-FORTH
[fast-forth/master.git] / MSP430-FORTH / SD_TEST.f
1
2 ; -----------
3 ; SD_TEST.f
4 ; -----------
5 \
6 \ to see kernel options, download FastForthSpecs.f
7 \ FastForth kernel options: MSP430ASSEMBLER, CONDCOMP, SD_CARD_READ_WRITE
8 \
9 \ TARGET SELECTION
10 \ MSP_EXP430FR5739  MSP_EXP430FR5969    MSP_EXP430FR5994    MSP_EXP430FR6989
11 \ MSP_EXP430FR4133  MSP_EXP430FR2433    MSP_EXP430FR2355    CHIPSTICK_FR2433
12 \
13 \
14 \ how to test SD_CARD driver on your launchpad:
15 \
16 \
17 \ remove the jumpers RX, TX of programming port (don't remove GND, TST, RST and VCC)
18 \ wire PL2303TA/HXD: GND <-> GND, RX <-- TX, TX --> RX
19 \ connect it to your PC on a free USB port
20 \ connect the PL2303TA/HXD cable to your PC on another free USB port
21 \ configure TERATERM as indicated in forthMSP430FR.asm
22 \
23 \
24 \ if you have a MSP-EXP430FR5994 launchpad, program it with MSP_EXP430FR5994_3Mbds_SD_CARD.txt
25 \ to do, drag and drop this file onto prog.bat
26 \ nothing else to do!
27 \
28 \
29 \ else edit forthMSP430FR.asm with scite editor
30 \   uncomment your target, copy it
31 \   paste it into (SHIFT+F8) param1
32 \   set DTC .equ 1
33 \       FREQUENCY   .equ 16
34 \       THREADS     .equ 16
35 \       TERMINALBAUDRATE    .equ 3000000
36 \         
37 \   uncomment:  CONDCOMP
38 \               MSP430ASSEMBLER
39 \               SD_CARD_LOADER
40 \               SD_CARD_READ_WRITE
41
42 \   compile for your target (CTRL+0)
43 \
44 \   program your target via TI interface (CTRL+1)
45 \
46 \   then wire your SD_Card module as described in your MSP430-FORTH\target.pat file
47 \
48 \
49 \
50 \ format FAT16 or FAT32 a SD_CARD memory (max 64GB) with "FRxxxx" in the disk name
51 \ drag and drop \MSP430_COND\MISC folder on the root of this SD_CARD memory (FastForth doesn't do yet)
52 \ put it in your target SD slot
53 \ if no reset, type COLD from the console input (teraterm) to reset FAST FORTH
54 \
55 \ with MSP430FR5xxx or MSP430FR6xxx targets, you can first set RTC:
56 \ by downloading RTC.f with SendSourceFileToTarget.bat
57 \ then terminal input asks you to type (with spaces) (DMY), then (HMS),
58 \ So, subsequent copied files will be dated:
59 \
60 \ with CopySourceFileToTarget_SD_Card.bat (or better, from scite editor, menu tools):
61 \
62 \   copy TESTASM.4TH        to \MISC\TESTASM.4TH    (add path \MISC in the window opened by TERATERM)
63 \   copy TSTWORDS.4TH       to \TSTWORDS.4TH
64 \   copy CORETEST.4TH       to \CORETEST.4TH
65 \   copy SD_TOOLS.f         to \SD_TOOLS.4TH
66 \   copy SD_TEST.f          to \SD_TEST.4TH
67 \   copy PROG100k.f         to \PROG100k.4TH
68 \   copy RTC.f              to \RTC.4TH             ( doesn't work with if FR2xxx or FR4xxx)
69
70 PWR_STATE
71
72 [UNDEFINED] {SD_TEST} [IF]   \
73
74 MARKER {SD_TEST}
75
76 [UNDEFINED] AND [IF]
77 \ https://forth-standard.org/standard/core/AND
78 \ C AND    x1 x2 -- x3           logical AND
79 CODE AND
80 AND @PSP+,TOS
81 MOV @IP+,PC
82 ENDCODE
83 [THEN]
84
85 [UNDEFINED] MAX [IF]   \ MAX and MIN are defined in {ANS_COMP}
86     CODE MAX    \    n1 n2 -- n3       signed maximum
87         CMP @PSP,TOS    \ n2-n1
88         S< ?GOTO FW1    \ n2<n1
89     BW1 ADD #2,PSP
90         MOV @IP+,PC
91     ENDCODE
92
93     CODE MIN    \    n1 n2 -- n3       signed minimum
94         CMP @PSP,TOS    \ n2-n1
95         S< ?GOTO BW1    \ n2<n1
96     FW1 MOV @PSP+,TOS
97         MOV @IP+,PC
98     ENDCODE
99 [THEN]
100
101 [UNDEFINED] U.R [IF]    \ defined in {UTILITY}
102 : U.R                       \ u n --           display u unsigned in n width (n >= 2)
103 >R  <# 0 # #S #>  
104 R> OVER - 0 MAX SPACES TYPE
105 ;
106 [THEN]
107
108 [UNDEFINED] DUMP [IF]    \ defined in {UTILITY}
109 \ https://forth-standard.org/standard/tools/DUMP
110 CODE DUMP                   \ adr n  --   dump memory
111 PUSH IP
112 PUSH &BASE                  \ save current base
113 MOV #$10,&BASE              \ HEX base
114 ADD @PSP,TOS                \ -- ORG END
115 LO2HI
116   SWAP OVER OVER            \ -- END ORG END ORG 
117   U.  U.                 \ -- END ORG        display org end 
118   $FFF0 AND                 \ -- END ORG_modulo_16
119   DO  CR                    \ generate line
120     I 7 U.R SPACE           \ generate address
121       I $10 + I             \ display 16 bytes
122       DO I C@ 3 U.R LOOP  
123       SPACE SPACE
124       I $10 + I             \ display 16 chars
125       DO I C@ $7E MIN BL MAX EMIT LOOP
126   $10 +LOOP
127   R> BASE !                 \ restore current base
128 ;
129 [THEN]
130
131 : SD_TEST
132 PWR_HERE    \ remove all volatile programs from MAIN memory
133 ECHO CR
134 ." 0 Set date and time" CR
135 ." 1 Load {TOOLS} words" CR
136 ." 2 Load {SD_TOOLS} words" CR
137 ." 3 Load {ANS_COMP} words" CR
138 ." 4 Load ANS core tests" CR
139 ." 5 Load a 100k program " CR
140 ." 6 Read only this source file" CR
141 ." 7 append a dump of FORTH to YOURFILE.TXT" CR
142 ." 8 delete YOURFILE.TXT" CR
143 ." 9 Load TST_WORDS" CR
144 ." your choice : "
145 KEY
146 48 - ?DUP
147 0= IF
148     ." LOAD RTC.4TH" CR
149     LOAD" RTC.4TH"
150 ELSE 1 - ?DUP
151     0= IF
152         ." LOAD UTILITY.4TH" CR
153         LOAD" UTILITY.4TH"
154     ELSE 1 - ?DUP
155         0= IF
156             ." LOAD SD_TOOLS.4TH" CR
157             LOAD" SD_TOOLS.4TH"
158         ELSE 1 - ?DUP
159             0= IF
160                 ." LOAD ANS_COMP.4TH" CR
161                 LOAD" ANS_COMP.4TH"
162             ELSE 1 - ?DUP
163                 0= IF
164                     ." LOAD CORETEST.4TH" CR
165                     LOAD" CORETEST.4TH"
166                     PWR_STATE
167                 ELSE 1 - ?DUP
168                     0= IF
169                         ." LOAD PROG100K.4TH" CR
170                         NOECHO
171                         LOAD" PROG100K.4TH"
172                     ELSE 1 - ?DUP
173                         0= IF
174                             ." READ PROG100K.4TH" CR
175                             READ" PROG100K.4TH"
176                             BEGIN
177                                 READ    \ sequentially read 512 bytes
178                             UNTIL       \ prog10k.4TH is closed
179                         ELSE 1 - ?DUP
180                             0= IF
181                                 ." WRITE YOURFILE.TXT" CR
182                                 WRITE" YOURFILE.TXT"
183                                 ['] SD_EMIT IS EMIT
184                                 MAIN_ORG HERE OVER - DUMP
185                                 ['] EMIT >BODY IS EMIT
186                                 CLOSE
187                             ELSE 1 - ?DUP
188                                 0= IF
189                                     ." DEL YOURFILE.TXT" CR
190                                     DEL" YOURFILE.TXT"
191                                 ELSE 1 - ?DUP
192                                     0= IF
193                                         ." LOAD TSTWORDS.4TH" CR
194                                         LOAD" TSTWORDS.4TH"
195                                     ELSE
196                                         ." abort" CR EXIT
197                                     THEN                                        
198                                 THEN
199                             THEN
200                         THEN
201                     THEN
202                 THEN
203             THEN
204         THEN
205     THEN
206 THEN
207 ;
208
209 RST_HERE
210
211 [THEN]
212
213 SD_TEST