OSDN Git Service

V208 Modified ACCEPT COLD WARM ?ABORT, S".
[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_xMPY.4TH  to \CORETEST.4TH        (x=S for FR4133, else x=H; suppr _xMPY in the window opened by TERATERM)
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 [DEFINED] {SD_TEST} [IF] {SD_TEST} [THEN]   \ remove {SD_TEST} 
73
74 [UNDEFINED] {SD_TEST} [IF]   \ requirements test
75
76 MARKER {SD_TEST}
77
78 [UNDEFINED] MAX [IF]   \ MAX and MIN are defined in {ANS_COMP}
79     CODE MAX    \    n1 n2 -- n3       signed maximum
80         CMP @PSP,TOS    \ n2-n1
81         S< ?GOTO FW1    \ n2<n1
82     BW1 ADD #2,PSP
83         MOV @IP+,PC
84     ENDCODE
85
86     CODE MIN    \    n1 n2 -- n3       signed minimum
87         CMP @PSP,TOS    \ n2-n1
88         S< ?GOTO BW1    \ n2<n1
89     FW1 MOV @PSP+,TOS
90         MOV @IP+,PC
91     ENDCODE
92 [THEN]
93
94 [UNDEFINED] U.R [IF]    \ defined in {UTILITY}
95 : U.R                       \ u n --           display u unsigned in n width (n >= 2)
96 >R  <# 0 # #S #>  
97 R> OVER - 0 MAX SPACES TYPE
98 ;
99 [THEN]
100
101 [UNDEFINED] DUMP [IF]    \ defined in {UTILITY}
102 \ https://forth-standard.org/standard/tools/DUMP
103 CODE DUMP                   \ adr n  --   dump memory
104 PUSH IP
105 PUSH &BASE                  \ save current base
106 MOV #$10,&BASE              \ HEX base
107 ADD @PSP,TOS                \ -- ORG END
108 LO2HI
109   SWAP OVER OVER            \ -- END ORG END ORG 
110   U. 1 - U.                 \ -- END ORG        display org end-1  
111   $FFF0 AND                 \ -- END ORG_modulo_16
112   DO  CR                    \ generate line
113     I 7 U.R SPACE           \ generate address
114       I $10 + I             \ display 16 bytes
115       DO I C@ 3 U.R LOOP  
116       SPACE SPACE
117       I $10 + I             \ display 16 chars
118       DO I C@ $7E MIN BL MAX EMIT LOOP
119   $10 +LOOP
120   R> BASE !                 \ restore current base
121 ;
122 [THEN]
123
124 : SD_TEST
125 \ BEGIN
126     ECHO CR
127     ."    0 Set date and time" CR
128     ."    1 Load {UTILITY} words" CR
129     ."    2 Load {SD_TOOLS} words" CR
130     ."    3 Load {ANS_COMP} words" CR
131     ."    4 Load ANS core tests" CR
132     ."    5 Load a 100k program " CR
133     ."    6 Read only this source file" CR
134     ."    7 Write a dump of FORTH to YOURFILE.TXT" CR
135     ."    8 append a dump of FORTH to YOURFILE.TXT" CR
136     ."    9 Load TST_WORDS" CR
137     ."    your choice : "
138     KEY CR
139     48 - ?DUP
140     0= IF
141         LOAD" RTC.4TH"
142     ELSE 1 - ?DUP
143         0= IF
144             LOAD" UTILITY.4TH"
145         ELSE 1 - ?DUP
146             0= IF
147                 LOAD" SD_TOOLS.4TH"
148             ELSE 1 - ?DUP
149                 0= IF
150                     LOAD" ANS_COMP.4TH"
151                 ELSE 1 - ?DUP
152                     0= IF
153                         LOAD" CORETEST.4TH"
154                         PWR_STATE   \ remove words
155                     ELSE 1 - ?DUP
156                         0= IF
157                             NOECHO
158                             LOAD" PROG100K.4TH"
159                             PWR_STATE   \ remove words
160                             ECHO
161                         ELSE 1 - ?DUP
162                             0= IF
163                                 READ" PROG100K.4TH"
164                                 BEGIN
165                                     READ    \ sequentially read 512 bytes
166                                 UNTIL       \ prog10k.4TH is closed
167                             ELSE 1 - ?DUP
168                                 0= IF
169                                     DEL" YOURFILE.TXT"
170                                     WRITE" YOURFILE.TXT"
171                                     ['] SD_EMIT IS EMIT
172                                     MAIN_ORG HERE OVER - DUMP
173                                     ['] EMIT >BODY IS EMIT
174                                     CLOSE
175                                 ELSE 1 - ?DUP
176                                     0= IF
177                                         WRITE" YOURFILE.TXT"
178                                         ['] SD_EMIT IS EMIT
179                                         CR
180                                         MAIN_ORG HERE OVER - DUMP
181                                         ['] EMIT >BODY IS EMIT
182                                         CLOSE
183                                     ELSE 1 - ?DUP
184                                         0= IF
185                                             LOAD" TSTWORDS.4TH"
186                                         ELSE
187                                             DROP EXIT
188                                         THEN                                        
189                                     THEN
190                                 THEN
191                             THEN
192                         THEN
193                     THEN
194                 THEN
195             THEN
196         THEN
197     THEN
198     ECHO ."    it's done"
199
200 \ AGAIN          \ LOAD" don't work with loop tests.......
201 ;
202
203 PWR_HERE \ to don't forget, otherwise SD_TEST destroys itself by downloading files comprising "PWR_HERE" command...
204
205 [THEN]
206
207 ECHO SD_TEST